/* * Build the settings window */ static void create_settings_window(void) { setting_window = window_create(); Layer *window_layer = window_get_root_layer(setting_window); GRect bounds = layer_get_bounds(window_layer); int16_t centre = bounds.size.w / 2; int16_t width = bounds.size.w; window_set_background_color(setting_window, SETTING_BACKGROUND_COLOR); is24hr = clock_is_24h_style(); // Get the resources we need large_font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); small_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); // Set click provider window_set_click_config_provider(setting_window, (ClickConfigProvider) setting_click_config_provider); // from_layer from_layer = macro_text_layer_create(GRect(SA_ROW_1_X, SA_ROW_1_Y, SA_ROW_1_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, SETTING_BACKGROUND_COLOR, small_font, GTextAlignmentCenter); text_layer_set_text(from_layer, EARLIEST); // fields[FROM_HOUR] fields[F_FROM_HOUR] = macro_text_layer_create(GRect(is24hr ? SA_HOUR_LEFT_24 : SA_HOUR_LEFT_12, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // fields[FROM_MINUTE] fields[F_FROM_MINUTE] = macro_text_layer_create(GRect(is24hr ? SA_MIN_LEFT_24 : SA_MIN_LEFT_12, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // fields[FROM_AMPM] if (!is24hr) { fields[F_FROM_AMPM] = macro_text_layer_create(GRect(SA_AMPM_LEFT, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); } // to_layer to_layer = macro_text_layer_create(GRect(SA_ROW_3_X, SA_ROW_3_Y, SA_ROW_3_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, SETTING_BACKGROUND_COLOR, small_font, GTextAlignmentCenter); text_layer_set_text(to_layer, LATEST); // fields[TO_HOUR] fields[F_TO_HOUR] = macro_text_layer_create(GRect(is24hr ? SA_HOUR_LEFT_24 : SA_HOUR_LEFT_12, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // fields[TO_MINUTE] fields[F_TO_MINUTE] = macro_text_layer_create(GRect(is24hr ? SA_MIN_LEFT_24 : SA_MIN_LEFT_12, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // fields[TO_AMPM] if (!is24hr) { fields[F_TO_AMPM] = macro_text_layer_create(GRect(SA_AMPM_LEFT, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); } current_field = F_FROM_HOUR; set_values(); write_values_to_fields(); highlight_field(current_field, true); }
EXTFN void chart_load(Window *window) { // Bring up chart chart_showing = true; chart_window = window; read_chart_data(); window_set_background_color(chart_window, BACKGROUND_COLOR); Layer *window_layer = window_get_root_layer(chart_window); GRect bounds = layer_get_bounds(window_layer); uint16_t width = bounds.size.w; int16_t centre = bounds.size.w / 2; macro_bitmap_layer_create(&chart_moon, MOON_START, window_layer, RESOURCE_ID_KEYBOARD_BG, true); #ifndef PBL_ROUND notice_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITAL_16)); chart_name_layer = macro_text_layer_create(GRect(5, 15, 134, 30), window_layer, GColorWhite, GColorClear, notice_font, GTextAlignmentRight); text_layer_set_text(chart_name_layer, APP_NAME); #endif window_set_click_config_provider(chart_window, (ClickConfigProvider) chart_click_config_provider); int16_t v_centre = bounds.size.h / 2; int16_t h_centre = bounds.size.w / 2; bar_height = bounds.size.h * 2 / 5 - 5; int16_t bar_top = v_centre - bar_height / 2; bar_width = bounds.size.w; int16_t bar_left = h_centre - bar_width / 2; #ifndef PBL_ROUND bar_top += 5; #endif chart_date = macro_text_layer_create(GRect(0, bar_top + bar_height - 5, width, 31), window_layer, GColorWhite, BACKGROUND_COLOR, fonts_get_system_font(FONT_KEY_GOTHIC_24), GTextAlignmentCenter); bar_layer = macro_layer_create(GRect(bar_left, bar_top, bar_width, bar_height), window_layer, &bar_layer_update_callback); moon_animation = property_animation_create_layer_frame(bitmap_layer_get_layer_jf(chart_moon.layer), &MOON_START, &MOON_FINISH); animation_set_duration((Animation*) moon_animation, 750); animation_set_handlers((Animation*) moon_animation, (AnimationHandlers ) { .stopped = (AnimationStoppedHandler) moon_animation_stopped, }, NULL /* callback data */);
/* * Build the settings window */ static void create_settings_window(void) { setting_window = window_create(); Layer *window_layer = window_get_root_layer(setting_window); window_set_background_color(setting_window, SETTING_BACKGROUND_COLOR); // Get the resources we need up_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_UP); next_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_NEXT); down_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_DOWN); tick_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_TICK); small_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); large_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); // button_layer button_layer = action_bar_layer_create(); action_bar_layer_add_to_window(button_layer, setting_window); action_bar_layer_set_background_color(button_layer, ACTION_BAR_BACKGROUND_COLOR); action_bar_layer_set_icon(button_layer, BUTTON_ID_UP, up_button_res); action_bar_layer_set_icon(button_layer, BUTTON_ID_SELECT, next_button_res); action_bar_layer_set_icon(button_layer, BUTTON_ID_DOWN, down_button_res); #ifdef PBL_PLATFORM_BASALT action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_UP, ActionBarLayerIconPressAnimationMoveUp); action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_SELECT, ActionBarLayerIconPressAnimationMoveRight); action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_DOWN, ActionBarLayerIconPressAnimationMoveDown); #endif layer_add_child(window_layer, (Layer *) button_layer); action_bar_layer_set_click_config_provider(button_layer, setting_click_config_provider); // title_layer title_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 6, 90, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft); text_layer_set_text(title_layer, SMART_ALARM); // from_layer from_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 30, 55, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft); text_layer_set_text(from_layer, EARLIEST); // fields[FROM_HOUR] fields[F_FROM_HOUR] = macro_text_layer_create(GRect(20, SETTING_FROM_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // from_colon_layer from_colon_layer = macro_text_layer_create(GRect(43, SETTING_FROM_TOP, 13, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); text_layer_set_text(from_colon_layer, COLON); // fields[FROM_MINUTE] fields[F_FROM_MINUTE] = macro_text_layer_create(GRect(52, SETTING_FROM_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // to_layer to_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 81, 48, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft); text_layer_set_text(to_layer, LATEST); // fields[TO_HOUR] fields[F_TO_HOUR] = macro_text_layer_create(GRect(20, SETTING_TO_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // to_color_layer to_color_layer = macro_text_layer_create(GRect(43, SETTING_TO_TOP, 13, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); text_layer_set_text(to_color_layer, COLON); // fields[TO_MINUTE] fields[F_TO_MINUTE] = macro_text_layer_create(GRect(52, SETTING_TO_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // fields[SMART_ALARM] fields[F_SMART_ALARM] = macro_text_layer_create(GRect(SA_LEFT, SA_TOP, 25, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); // fields[DONE] fields[F_DONE] = macro_text_layer_create(GRect(DONE_LEFT, DONE_TOP, 45, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter); current_field = F_SMART_ALARM; set_values(); write_values_to_fields(); highlight_field(current_field, true); }