void handle_init(AppContextRef ctx) { srand(time(NULL));//seed randmoness! window_init(&window, "Window Name"); window_stack_push(&window, true /* Animated */); text_layer_init(&dateLayer, GRect(0, 0, 144, 50)); text_layer_set_text_alignment(&dateLayer, GTextAlignmentCenter); text_layer_set_font(&dateLayer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21)); text_layer_set_background_color(&dateLayer, GColorBlack); text_layer_set_text_color(&dateLayer, GColorWhite); text_layer_set_overflow_mode(&dateLayer, GTextOverflowModeWordWrap); layer_add_child(&window.layer, &dateLayer.layer); text_layer_init(&busLayer, GRect(0, 93, 144, 75)); text_layer_set_text_alignment(&busLayer, GTextAlignmentCenter); text_layer_set_font(&busLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_background_color(&busLayer, GColorBlack); text_layer_set_text_color(&busLayer, GColorWhite); text_layer_set_overflow_mode(&busLayer, GTextOverflowModeWordWrap); layer_add_child(&window.layer, &busLayer.layer); // Init the layer for the display layer_init(&display_layer, window.layer.frame); display_layer.update_proc = &display_layer_update_callback; layer_add_child(&window.layer, &display_layer); adjX = ((int) ( (144-((bitRect.size.w+BIT_SPACING)*ROW_WIDTH))/2)) -2;//change the -2 if needed adjY = ((int) ( ((168-YSTART)-((bitRect.size.h+BIT_SPACING)*COL_HEIGHT) )/2)) - YSHORT/2; handle_minute_tick(ctx, NULL); }
void end_round() { round_started = false; club_menu_index = 0; text_layer_set_text(&club, club_menu[club_menu_index]); window_init(&finalscore, "Final Score"); window_stack_push(&finalscore, true /* Animated */); text_layer_init(&finalscore_score, GRect(0, 0, 144, 168-16)); text_layer_set_background_color(&finalscore_score, GColorWhite); text_layer_set_text_color(&finalscore_score, GColorBlack); text_layer_set_font(&finalscore_score,fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD)); mini_snprintf(s_final_score, 25, "Final Score %d", totalshots); text_layer_set_text(&finalscore_score, s_final_score); text_layer_set_text_alignment(&finalscore_score, GTextAlignmentCenter); layer_add_child(&finalscore.layer, &finalscore_score.layer); text_layer_init(&finalscore_putts, GRect(0, 126, 144, 168-16-126)); text_layer_set_background_color(&finalscore_putts, GColorWhite); text_layer_set_text_color(&finalscore_putts, GColorBlack); text_layer_set_font(&finalscore_putts,fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); mini_snprintf(s_final_putts, 25, "Total Putts: %d", totalputts); text_layer_set_text(&finalscore_putts, s_final_putts); text_layer_set_text_alignment(&finalscore_putts, GTextAlignmentCenter); layer_add_child(&finalscore.layer, &finalscore_putts.layer); vibes_double_pulse(); // Need to destroy list_of_shots array. }
void handle_init_app(AppContextRef app_ctx) { window_init(&window, "Less Simple"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); text_layer_init(&date_layer, GRect(PADDING*1.5, PADDING + DATE_TOP_PADDING, SCREEN_WIDTH-PADDING, LINE_HEIGHT)); text_layer_set_text_color(&date_layer, GColorWhite); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); layer_add_child(&window.layer, &date_layer.layer); text_layer_init(&time_layer, GRect(0, PADDING + LINE_HEIGHT*1, SCREEN_WIDTH, LINE_HEIGHT)); text_layer_set_text_color(&time_layer, GColorWhite); text_layer_set_text_alignment(&time_layer, GTextAlignmentCenter); text_layer_set_background_color(&time_layer, GColorClear); text_layer_set_font(&time_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_MEDIUM_NUMBERS)); layer_add_child(&window.layer, &time_layer.layer); text_layer_init(&second_layer, GRect(0, LINE_HEIGHT*2, SCREEN_WIDTH, LINE_HEIGHT)); text_layer_set_text_color(&second_layer, GColorWhite); text_layer_set_text_alignment(&second_layer, GTextAlignmentCenter); text_layer_set_background_color(&second_layer, GColorClear); text_layer_set_font(&second_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_LIGHT)); layer_add_child(&window.layer, &second_layer.layer); // Ensures time is displayed immediately (will break if NULL tick event accessed). // (This is why it's a good idea to have a separate routine to do the update itself.) handle_second_tick(app_ctx, NULL); layer_init(&lineLayer, window.layer.frame); lineLayer.update_proc = &line_layer_update_callback; layer_add_child(&window.layer, &lineLayer); }
void init_handler(AppContextRef ctx) { window_init(&window, "pbl-index"); window_set_background_color(&window, GColorBlack); window_stack_push(&window, true); for (int i=0; i<NUM_LINES; i++) { text_layer_init(&textLayer[0][i], GRect(5, 7+i*30, 144-5-COLUMN2_WIDTH, 30)); text_layer_init(&textLayer[1][i], GRect(144-COLUMN2_WIDTH, 7+i*30, COLUMN2_WIDTH, 30)); text_layer_set_font(&textLayer[0][i], fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_font(&textLayer[1][i], fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_background_color(&textLayer[0][i], GColorBlack); text_layer_set_background_color(&textLayer[1][i], GColorBlack); text_layer_set_text_color(&textLayer[0][i], GColorWhite); text_layer_set_text_color(&textLayer[1][i], GColorWhite); text_layer_set_text_alignment(&textLayer[1][i], GTextAlignmentRight); } text_layer_set_text(&textLayer[0][0], "pbl-index"); text_layer_set_text(&textLayer[0][1], "by epatel"); text_layer_set_text(&textLayer[0][3], "loading..."); for (int i=0; i<NUM_LINES; i++) { layer_add_child(&window.layer, &textLayer[0][i].layer); layer_add_child(&window.layer, &textLayer[1][i].layer); } http_set_app_id(PBLINDEX_NAMES_COOKIE); http_register_callbacks((HTTPCallbacks){ .failure = failed, .success = success, .reconnect = reconnect, }, NULL);
void handle_init(AppContextRef ctx) { window_init(&window, "Simplicity"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); layer_init(&time_layer, GRect(0, 12, 144, 168-68)); layer_add_child(&window.layer, &time_layer); text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(8, 0, 144-8, 168-68)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&time_layer, &text_date_layer.layer); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(7, 24, 144-7, 168-92)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49))); layer_add_child(&time_layer, &text_time_layer.layer); layer_init(&line_layer, window.layer.frame); line_layer.update_proc = &line_layer_update_callback; layer_add_child(&time_layer, &line_layer); layer_init(&car_layer, GRect(0, 90, 144, 168-90)); layer_add_child(&window.layer, &car_layer); text_layer_init(&text_rated_layer, window.layer.frame); text_layer_set_text_color(&text_rated_layer, GColorWhite); text_layer_set_background_color(&text_rated_layer, GColorClear); layer_set_frame(&text_rated_layer.layer, GRect(8, 0, 144-8, 168-68)); text_layer_set_font(&text_rated_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&car_layer, &text_rated_layer.layer); text_layer_init(&text_state_layer, window.layer.frame); text_layer_set_text_color(&text_state_layer, GColorWhite); text_layer_set_background_color(&text_state_layer, GColorClear); layer_set_frame(&text_state_layer.layer, GRect(8, 20, 144-8, 168-68)); text_layer_set_font(&text_state_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&car_layer, &text_state_layer.layer); layer_init(&battery_layer, GRect(72, 10, 144-70, 10)); battery_layer.update_proc = &battery_layer_update_callback; layer_add_child(&car_layer, &battery_layer); Tuplet initial_values[] = { TupletInteger(TESLA_RATED_REMAIN_KEY, (uint16_t) 148), TupletCString(TESLA_STATE_STRING_KEY, "Charging"), TupletInteger(TESLA_BATTERY_PERCENT_KEY, (uint8_t) 72), }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Demo"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&FUZZYZEIT_RESOURCES); custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_MPC_32)); custom_font2 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_MPBC_32)); window_set_background_color(&window, GColorBlack); graphics_context_set_text_color(ctx, GColorWhite); text_layer_init(&min_layer, GRect(4, 35, 144 /* width */, 50 /* height */)); text_layer_set_text_color(&min_layer, GColorWhite); text_layer_set_text(&min_layer, ""); text_layer_set_font(&min_layer, custom_font); text_layer_set_background_color(&min_layer, GColorClear); layer_add_child(&window.layer, &min_layer.layer); layer_mark_dirty(&min_layer.layer); text_layer_init(&hour_layer, GRect(4, 80, 144 /* width */, 50 /* height */)); text_layer_set_text_color(&hour_layer, GColorWhite); text_layer_set_text(&hour_layer, ""); text_layer_set_font(&hour_layer, custom_font2); text_layer_set_background_color(&hour_layer, GColorClear); layer_add_child(&window.layer, &hour_layer.layer); layer_mark_dirty(&hour_layer.layer); update_layer(ctx); }
void timer_window_load(Window *me) { static char headerText[16]; snprintf(headerText, sizeof(headerText), "Timer %d", curTimer+1); updateTimerValueText(); text_layer_init(&timerSelectHeader, timerUpdateWindow.layer.frame); text_layer_set_text_color(&timerSelectHeader, GColorBlack); text_layer_set_background_color(&timerSelectHeader, GColorClear); layer_set_frame(&timerSelectHeader.layer, GRect(8, 8, 144-8, 168-68)); text_layer_set_font(&timerSelectHeader, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK)); text_layer_set_text(&timerSelectHeader, headerText); layer_add_child(&timerUpdateWindow.layer, &timerSelectHeader.layer); text_layer_init(&timerSelectValue, timerUpdateWindow.layer.frame); text_layer_set_text_color(&timerSelectValue, GColorBlack); text_layer_set_background_color(&timerSelectValue, GColorClear); layer_set_frame(&timerSelectValue.layer, GRect(40, 50, 144-8, 168-68)); text_layer_set_font(&timerSelectValue, fonts_get_system_font(FONT_KEY_GOTHAM_42_LIGHT)); text_layer_set_text(&timerSelectValue, timerValueText); layer_add_child(&timerUpdateWindow.layer, &timerSelectValue.layer); text_layer_init(&timerSelectFooter, timerUpdateWindow.layer.frame); text_layer_set_text_color(&timerSelectFooter, GColorBlack); text_layer_set_background_color(&timerSelectFooter, GColorClear); layer_set_frame(&timerSelectFooter.layer, GRect(8, 110, 144-8, 168-68)); text_layer_set_font(&timerSelectFooter, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK)); text_layer_set_text(&timerSelectFooter, "minutes"); layer_add_child(&timerUpdateWindow.layer, &timerSelectFooter.layer); window_set_click_config_provider(&timerUpdateWindow, (ClickConfigProvider) timer_click_config_provider); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Modern Watch"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); #if DISPLAY_DATE_ANALOG bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_DATEBOX, &background_image_container); #elif INVERTED bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_INVERTED, &background_image_container); #else bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); #endif layer_add_child(&window.layer, &background_image_container.layer.layer); #if DISPLAY_DATE_ANALOG date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_MEDIUM_12)); text_layer_init(&date_layer, GRect(116, 77, 20, 20)); #else date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITALDREAM_NARROW_12)); text_layer_init(&date_layer, GRect(27, 110, 90, 30)); #endif #if DISPLAY_DATE_ANALOG text_layer_set_text_color(&date_layer, GColorBlack); #elif INVERTED text_layer_set_text_color(&date_layer, GColorBlack); #else text_layer_set_text_color(&date_layer, GColorWhite); #endif text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, date_font); layer_add_child(&window.layer, &date_layer.layer); draw_date(); layer_init(&hour_display_layer, window.layer.frame); hour_display_layer.update_proc = &hour_display_layer_update_callback; layer_add_child(&window.layer, &hour_display_layer); gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS); gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame)); layer_init(&minute_display_layer, window.layer.frame); minute_display_layer.update_proc = &minute_display_layer_update_callback; layer_add_child(&window.layer, &minute_display_layer); gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS); gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame)); layer_init(¢er_display_layer, window.layer.frame); center_display_layer.update_proc = ¢er_display_layer_update_callback; layer_add_child(&window.layer, ¢er_display_layer); #if DISPLAY_SECONDS layer_init(&second_display_layer, window.layer.frame); second_display_layer.update_proc = &second_display_layer_update_callback; layer_add_child(&window.layer, &second_display_layer); #endif }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Orbit"); window_stack_push(&window, false /* Not Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage); layer_add_child(&window.layer, &faceImage.layer.layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_PLANET_WHITE, RESOURCE_ID_IMAGE_MINUTE_PLANET_BLACK, &minuteImage); layer_add_child(&window.layer, &minuteImage.layer.layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_PLANET_WHITE, RESOURCE_ID_IMAGE_HOUR_PLANET_BLACK, &hourImage); layer_add_child(&window.layer, &hourImage.layer.layer); text_layer_init(&minuteText, GRect(0,0,0,0)); text_layer_set_text_color(&minuteText, GColorWhite); text_layer_set_background_color(&minuteText, GColorClear); text_layer_set_text_alignment(&minuteText, GTextAlignmentCenter); text_layer_set_font(&minuteText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_14))); layer_add_child(&window.layer, &minuteText.layer); text_layer_init(&hourText, GRect(0,0,0,0)); text_layer_set_text_color(&hourText, GColorWhite); text_layer_set_background_color(&hourText, GColorClear); text_layer_set_text_alignment(&hourText, GTextAlignmentCenter); text_layer_set_font(&hourText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_22))); layer_add_child(&window.layer, &hourText.layer); update_rings(); }
void handle_init(AppContextRef ctx) { window_init(&window, "Simplicity"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(8, 28, 144-8, 40)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TEST_21))); layer_add_child(&window.layer, &text_date_layer.layer); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(1, 62, 144-2, 168-62)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TEST_48))); layer_add_child(&window.layer, &text_time_layer.layer); layer_init(&line_layer, window.layer.frame); line_layer.update_proc = &line_layer_update_callback; layer_add_child(&window.layer, &line_layer); // TODO: Update display here to avoid blank display on launch? }
static void handle_init(AppContextRef ctx) { (void) ctx; window_init(&s_data.window, "Clock_Window"); const bool animated = true; window_stack_push(&s_data.window, animated); window_set_background_color(&s_data.window, GColorBlack); resource_init_current_app(&APP_RESOURCES); //GFont gotham = fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD); GFont fontPlain = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SANSATION_LIGHT_42)); GFont fontBold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SANSATION_BOLD_42)); text_layer_init(&s_data.label, GRect(0, 0, s_data.window.layer.frame.size.w, 100)); text_layer_init(&s_data.label2, GRect(0, 37, s_data.window.layer.frame.size.w, s_data.window.layer.frame.size.h - 37)); text_layer_set_background_color(&s_data.label, GColorClear); text_layer_set_background_color(&s_data.label2, GColorClear); text_layer_set_text_color(&s_data.label, GColorWhite); text_layer_set_text_color(&s_data.label2, GColorWhite); text_layer_set_font(&s_data.label, fontBold); text_layer_set_font(&s_data.label2, fontPlain); layer_add_child(&s_data.window.layer, &s_data.label.layer); layer_add_child(&s_data.window.layer, &s_data.label2.layer); PblTm t; get_time(&t); update_time(&t); }
void handle_init(AppContextRef ctx) { // Create the main window and push it in fullscreen mode window_init(&window, "Window Name"); window_stack_push(&window, true /* Animated */); window_set_fullscreen(&window, true); // Initialize ressources and load the background image resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_BACKGROUND_IMAGE, &background_image); layer_add_child(&window.layer, &background_image.layer.layer); // Create a text field to display the time until the next pass text_layer_init(&nextpass_text_layer, GRect(0, 126, 144, 34)); text_layer_set_font(&nextpass_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS)); text_layer_set_text_alignment(&nextpass_text_layer, GTextAlignmentCenter); text_layer_set_background_color(&nextpass_text_layer, GColorClear); layer_add_child(window_get_root_layer(&window), (Layer*)&time_text_layer); // Create a text field to display the current time text_layer_init(&time_text_layer, GRect(37, 0, 70, 24)); text_layer_set_font(&time_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_text_alignment(&time_text_layer, GTextAlignmentCenter); text_layer_set_background_color(&time_text_layer, GColorClear); layer_add_child(window_get_root_layer(&window), (Layer*)&nextpass_text_layer); // Add background and both text fields to the window // Start an HTTP Request start_http_request(); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Main"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); frame_animation_init(&gif_animation, &window.layer, GPoint(0,0), RESOURCE_ID_FRAME_1, 12, false, true); timer_handle = app_timer_send_event(ctx, 100, 1); text_layer_init(&text_time_layer, GRect(0, 5, 144, 30)); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter); text_layer_set_font(&text_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); layer_add_child(&window.layer, &text_time_layer.layer); text_layer_init(&date_layer, GRect(0, 130, 144, 30)); text_layer_set_text_color(&date_layer, GColorWhite); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); text_layer_set_font(&date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); layer_add_child(&window.layer, &date_layer.layer); }
void handle_init(AppContextRef ctx) { (void) ctx; window_init(&window, "Totoro"); window_stack_push(&window, true); resource_init_current_app(&APP_RESOURCES); // Set up a layer for the static watch face background bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); layer_add_child(&window.layer, &background_image_container.layer.layer); // Date // Initialises the date and sets the text, font and background colour text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorBlack); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(69, 150, 80, 15)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHIC_REGULAR_12))); layer_add_child(&window.layer, &text_date_layer.layer); // Time // Initialises the time and sets the text, font and background colour text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorBlack); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(0, 0, 144, 44)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHIC_REGULAR_36))); text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter); layer_add_child(&window.layer, &text_time_layer.layer); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Window Name"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); Minutes_Open = 0; //Texts //Year text_layer_init(&year_layer, GRect(8, 7, 144-16, 7+12)); text_layer_set_text_color(&year_layer, GColorWhite); text_layer_set_background_color(&year_layer, GColorClear); text_layer_set_font(&year_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&year_layer, "Year"); layer_add_child(&window.layer, &year_layer.layer); //Month text_layer_init(&month_layer, GRect(8, 38, 144-16, 38+12)); text_layer_set_text_color(&month_layer, GColorWhite); text_layer_set_background_color(&month_layer, GColorClear); text_layer_set_font(&month_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&month_layer, "Month"); layer_add_child(&window.layer, &month_layer.layer); //Week text_layer_init(&week_layer, GRect(8, 69, 144-16, 69+12)); text_layer_set_text_color(&week_layer, GColorWhite); text_layer_set_background_color(&week_layer, GColorClear); text_layer_set_font(&week_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&week_layer, "Week"); layer_add_child(&window.layer, &week_layer.layer); //Day text_layer_init(&day_layer, GRect(8, 100, 144-16, 100+12)); text_layer_set_text_color(&day_layer, GColorWhite); text_layer_set_background_color(&day_layer, GColorClear); text_layer_set_font(&day_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&day_layer, "Day"); layer_add_child(&window.layer, &day_layer.layer); //Clock text text_layer_init(&text_time_layer, GRect(0, 127, 144, 127+26)); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); text_layer_set_font(&text_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter); text_layer_set_text(&text_time_layer, "00:00"); layer_add_child(&window.layer, &text_time_layer.layer); layer_init(&bars_layer, window.layer.frame); bars_layer.update_proc = &bars_update_callback; layer_add_child(&window.layer, &bars_layer); layer_init(&main_layer, window.layer.frame); main_layer.update_proc = &progress_update_callback; layer_add_child(&window.layer, &main_layer); }
static void handle_init(AppContextRef app_ctx) { window_init(&s_data.window, "Simple Analog Watch"); s_data.day_buffer[0] = '\0'; s_data.num_buffer[0] = '\0'; // init hand paths gpath_init(&s_data.minute_arrow, &MINUTE_HAND_POINTS); gpath_init(&s_data.hour_arrow, &HOUR_HAND_POINTS); const GPoint center = grect_center_point(&s_data.window.layer.bounds); gpath_move_to(&s_data.minute_arrow, center); gpath_move_to(&s_data.hour_arrow, center); // init clock face paths for (int i = 0; i < NUM_CLOCK_TICKS; ++i) { gpath_init(&s_data.tick_paths[i], &ANALOG_BG_POINTS[i]); } // init layers layer_init(&s_data.simple_bg_layer, s_data.window.layer.frame); s_data.simple_bg_layer.update_proc = &bg_update_proc; layer_add_child(&s_data.window.layer, &s_data.simple_bg_layer); // init date layer -> a plain parent layer to create a date update proc layer_init(&s_data.date_layer, s_data.window.layer.frame); s_data.date_layer.update_proc = &date_update_proc; layer_add_child(&s_data.window.layer, &s_data.date_layer); // init day text_layer_init(&s_data.day_label, GRect(46, 114, 27, 20)); text_layer_set_text(&s_data.day_label, s_data.day_buffer); text_layer_set_background_color(&s_data.day_label, GColorBlack); text_layer_set_text_color(&s_data.day_label, GColorWhite); GFont norm18 = fonts_get_system_font(FONT_KEY_GOTHIC_18); text_layer_set_font(&s_data.day_label, norm18); layer_add_child(&s_data.date_layer, &s_data.day_label.layer); // init num text_layer_init(&s_data.num_label, GRect(73, 114, 18, 20)); text_layer_set_text(&s_data.num_label, s_data.num_buffer); text_layer_set_background_color(&s_data.num_label, GColorBlack); text_layer_set_text_color(&s_data.num_label, GColorWhite); GFont bold18 = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); text_layer_set_font(&s_data.num_label, bold18); layer_add_child(&s_data.date_layer, &s_data.num_label.layer); // init hands layer_init(&s_data.hands_layer, s_data.simple_bg_layer.frame); s_data.hands_layer.update_proc = &hands_update_proc; layer_add_child(&s_data.window.layer, &s_data.hands_layer); // Push the window onto the stack const bool animated = true; window_stack_push(&s_data.window, animated); }
void handle_init(AppContextRef ctx) { (void)ctx; firstblood = true; window_init(&window, "Clock_Window"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); fontHour = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLDITALIC_35)); fontUhr = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_LIGHTITALIC_30)); fontMinutes = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_ITALIC_33)); fontDate = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_ITALIC_13)); memset(row_1_buffer,0,20); memset(row_3_buffer,0,20); memset(row_4_buffer,0,20); memset(row_5_buffer,0,20); text_layer_init(&row_2, window.layer.frame); text_layer_init(&row_3, window.layer.frame); text_layer_init(&row_4, window.layer.frame); text_layer_init(&row_5, window.layer.frame); text_layer_init(&row_3b, window.layer.frame); text_layer_init(&row_4b, window.layer.frame); text_layer_init(&row_5b, window.layer.frame); text_layer_init(&row_1, window.layer.frame); text_layer_init(&row_1b, window.layer.frame); get_time(&t); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "SunClock"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorWhite); resource_init_current_app(&APP_RESOURCES); fontBig = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SUNCLOCK_30)); fontSmall = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SUNCLOCK_16)); fontMoonPhases = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MOON_PHASES_30)); layer_init(&graphics_sun_layer, window.layer.frame); graphics_sun_layer.update_proc = &graphics_sun_layer_update_callback; layer_add_child(&window.layer, &graphics_sun_layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_WATCHFACE_WHITE, RESOURCE_ID_IMAGE_WATCHFACE_BLACK, &watchface_container); layer_add_child(&graphics_sun_layer, &watchface_container.layer.layer); watchface_container.layer.layer.frame.origin.x = (144/2) - (watchface_container.layer.layer.frame.size.w/2); watchface_container.layer.layer.frame.origin.y = (168/2) - (watchface_container.layer.layer.frame.size.h/2); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_WHITE, RESOURCE_ID_IMAGE_HOUR_BLACK, &bitmap_hour_container); rotbmp_pair_layer_set_src_ic(&bitmap_hour_container.layer, GPoint(6,56)); layer_add_child(&window.layer, &bitmap_hour_container.layer.layer); PblTm t; get_time(&t); rotbmp_pair_layer_set_angle(&bitmap_hour_container.layer, TRIG_MAX_ANGLE * get24HourAngle(t.tm_hour, t.tm_min)); bitmap_hour_container.layer.layer.frame.origin.x = (144/2) - (bitmap_hour_container.layer.layer.frame.size.w/2); bitmap_hour_container.layer.layer.frame.origin.y = (168/2) - (bitmap_hour_container.layer.layer.frame.size.h/2); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorBlack); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(0, 35, 144, 30)); text_layer_set_font(&text_time_layer, fontBig); layer_add_child(&window.layer, &text_time_layer.layer); text_layer_init(&text_sunrise_layer, window.layer.frame); text_layer_set_text_color(&text_sunrise_layer, GColorWhite); text_layer_set_background_color(&text_sunrise_layer, GColorClear); layer_set_frame(&text_sunrise_layer.layer, GRect(0, 150, 144, 18)); text_layer_set_font(&text_sunrise_layer, fontSmall); layer_add_child(&window.layer, &text_sunrise_layer.layer); text_layer_init(&text_sunset_layer, window.layer.frame); text_layer_set_text_color(&text_sunset_layer, GColorWhite); text_layer_set_background_color(&text_sunset_layer, GColorClear); layer_set_frame(&text_sunset_layer.layer, GRect(0, 150, 144, 18)); text_layer_set_font(&text_sunset_layer, fontSmall); layer_add_child(&window.layer, &text_sunset_layer.layer); updateDayAndNightInfo(); }
void message_layer_init(Window * window) { messageLayer.unreadGmails = 0; messageLayer.unreadSms = 0; messageLayer.missedCalls = 0; messageLayer.hangouts = 0; //Load font messageLayer.messageFont = get_font_15(); // initialize base layer layer_init(&messageLayer.baseLayer, baseLayerBounds); layer_add_child(&window->layer, &messageLayer.baseLayer); // initalize sms layers layer_init(&messageLayer.smsImageLayer, smsImageBounds); messageLayer.smsImageLayer.update_proc = load_sms_image; layer_add_child(&messageLayer.baseLayer, &messageLayer.smsImageLayer); text_layer_init(&messageLayer.smsTextLayer, smsTextBounds); text_layer_set_font(&messageLayer.smsTextLayer, *messageLayer.messageFont); text_layer_set_text_alignment(&messageLayer.smsTextLayer, GTextAlignmentCenter); text_layer_set_background_color(&messageLayer.smsTextLayer, GColorBlack); text_layer_set_text_color(&messageLayer.smsTextLayer, GColorWhite); layer_add_child(&messageLayer.baseLayer, &messageLayer.smsTextLayer.layer); // initalize gmail layers layer_init(&messageLayer.gmailImageLayer, gmailImageBounds); messageLayer.gmailImageLayer.update_proc = load_gmail_image; layer_add_child(&messageLayer.baseLayer, &messageLayer.gmailImageLayer); text_layer_init(&messageLayer.gmailTextLayer, gmailTextBounds); text_layer_set_font(&messageLayer.gmailTextLayer, *messageLayer.messageFont); text_layer_set_text_alignment(&messageLayer.gmailTextLayer, GTextAlignmentCenter); text_layer_set_background_color(&messageLayer.gmailTextLayer, GColorBlack); text_layer_set_text_color(&messageLayer.gmailTextLayer, GColorWhite); layer_add_child(&messageLayer.baseLayer, &messageLayer.gmailTextLayer.layer); // initalize missed calls layers layer_init(&messageLayer.missedCallImageLayer, missedCallImageBounds); messageLayer.missedCallImageLayer.update_proc = load_phone_image; layer_add_child(&messageLayer.baseLayer, &messageLayer.missedCallImageLayer); text_layer_init(&messageLayer.missedCallTextLayer, missedCallTextBounds); text_layer_set_font(&messageLayer.missedCallTextLayer, *messageLayer.messageFont); text_layer_set_text_alignment(&messageLayer.missedCallTextLayer, GTextAlignmentCenter); text_layer_set_background_color(&messageLayer.missedCallTextLayer, GColorBlack); text_layer_set_text_color(&messageLayer.missedCallTextLayer, GColorWhite); layer_add_child(&messageLayer.baseLayer, &messageLayer.missedCallTextLayer.layer); // initalize hangout layers layer_init(&messageLayer.hangoutImageLayer, hangoutImageBounds); messageLayer.hangoutImageLayer.update_proc = load_hangout_image; layer_add_child(&messageLayer.baseLayer, &messageLayer.hangoutImageLayer); text_layer_init(&messageLayer.hangoutTextLayer, hangoutTextBounds); text_layer_set_font(&messageLayer.hangoutTextLayer, *messageLayer.messageFont); text_layer_set_text_alignment(&messageLayer.hangoutTextLayer, GTextAlignmentCenter); text_layer_set_background_color(&messageLayer.hangoutTextLayer, GColorBlack); text_layer_set_text_color(&messageLayer.hangoutTextLayer, GColorWhite); layer_add_child(&messageLayer.baseLayer, &messageLayer.hangoutTextLayer.layer); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Window Name"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorWhite); //resource_init_current_app(&APP_RESOURCES); // Init the text layer used to show the weeks text_layer_init(&weekLayer, GRect(80, 0, 144-20 /* width */, 168-54 /* height */)); text_layer_set_text_color(&weekLayer, GColorBlack); text_layer_set_background_color(&weekLayer, GColorClear); text_layer_set_font(&weekLayer, fonts_get_system_font(FONT_KEY_GOTHAM_34_MEDIUM_NUMBERS)); // Init the text layer used to show the wife text_layer_init(&wifeLayer, GRect(5, 10, 144-20 /* width */, 168-54 /* height */)); text_layer_set_text_color(&wifeLayer, GColorBlack); text_layer_set_background_color(&wifeLayer, GColorClear); text_layer_set_font(&wifeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); // Init the text layer used to show the baby text_layer_init(&papaLayer, GRect(0, 70, 144 /* width */, 168-54 /* height */)); text_layer_set_text_color(&papaLayer, GColorWhite); text_layer_set_background_color(&papaLayer, GColorBlack); text_layer_set_font(&papaLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_text_alignment(&papaLayer, GTextAlignmentCenter); // Init the text layer used to show the comparison text_layer_init(&compLayer, GRect(0, 97, 144 /* width */, 168-54 /* height */)); text_layer_set_text_color(&compLayer, GColorWhite); text_layer_set_background_color(&compLayer, GColorBlack); text_layer_set_font(&compLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_text_alignment(&compLayer, GTextAlignmentCenter); // Init the text layer used to show the fruit text_layer_init(&fruitLayer, GRect(0, 125, 144 /* width */, 168-54 /* height */)); text_layer_set_text_color(&fruitLayer, GColorWhite); text_layer_set_background_color(&fruitLayer, GColorBlack); text_layer_set_font(&fruitLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(&fruitLayer, GTextAlignmentCenter); // Ensures time is displayed immediately (will break if NULL tick event accessed). // (This is why it's a good idea to have a separate routine to do the update itself.) handle_minute_tick(ctx, NULL); layer_add_child(&window.layer, &wifeLayer.layer); layer_add_child(&window.layer, &weekLayer.layer); layer_add_child(&window.layer, &papaLayer.layer); layer_add_child(&window.layer, &compLayer.layer); layer_add_child(&window.layer, &fruitLayer.layer); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Triforce"); window_stack_push(&window, true /*animated */); window_set_background_color(&window,GColorBlack); // Display the black and white image with transparency. resource_init_current_app(&APP_RESOURCES); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_TRIFORCE_WHITE, RESOURCE_ID_IMAGE_TRIFORCE_BLACK, &triforce); triforce.layer.layer.frame.origin.x = 5; triforce.layer.layer.frame.origin.y = -10; layer_add_child(&window.layer, &triforce.layer.layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_DOTS_WHITE, RESOURCE_ID_IMAGE_DOTS_BLACK, &dots); dots.layer.layer.frame.origin.x = 5; dots.layer.layer.frame.origin.y = -10; layer_add_child(&window.layer, &dots.layer.layer); //Initializes the timeLayer text_layer_init(&timeLayer, GRect(0, 168-42, 144 /* width */, 42 /* height */)); text_layer_set_text_alignment(&timeLayer, GTextAlignmentCenter); text_layer_set_text_color(&timeLayer, GColorWhite); layer_set_frame(&timeLayer.layer, GRect(0, 100, 144, 168-100)); text_layer_set_background_color(&timeLayer, GColorClear); text_layer_set_font(&timeLayer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TRIFORCE_30))); layer_add_child(&window.layer, &timeLayer.layer); //Initializes the Date layer text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(40, 140, 144-40, 168-140)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TRIFORCE_20))); layer_add_child(&window.layer, &text_date_layer.layer); //Initializes the AM/PM layer text_layer_init(&M, window.layer.frame); text_layer_set_text_color(&M, GColorWhite); text_layer_set_background_color(&M, GColorClear); layer_set_frame(&M.layer, GRect(110, 107, 144-110, 168-107)); layer_add_child(&window.layer, &M.layer); update_time_display(); }
void displayHelp() { static Window window; static Layer chromeLayer; static TextLayer helpTextLayer; window_init(&window, "Help"); window_set_fullscreen(&window, true); window.layer.frame.origin.x = 5; window.layer.frame.origin.y = 5; // TODO: Should have get/set bounds functions public? window.layer.bounds.size.w -= 10; window.layer.bounds.size.h -= 10; window_set_background_color(&window, GColorClear); // TODO: Set proper/better frame/bounds values here? layer_init(&chromeLayer, window.layer.frame); chromeLayer.update_proc = &help_window_update_callback; layer_add_child(&window.layer, &chromeLayer); text_layer_init(&helpTextLayer, GRect(16, 16, 144-24-8 /* width */, 168-24-8 /* height */)); text_layer_set_text_color(&helpTextLayer, GColorWhite); text_layer_set_background_color(&helpTextLayer, GColorBlack); text_layer_set_font(&helpTextLayer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&helpTextLayer, ">Select (long press)<\nChange edit mode.\n\n>Up/Down<\nIncrease/decrease axis value\n\n(Press back to close)"); layer_add_child(&window.layer, &helpTextLayer.layer); window_stack_push(&window, false /* Not animated */); }
void InitializeTextLayer(TextLayer *textLayer, GRect frame, GFont font) { text_layer_init(textLayer, frame); text_layer_set_text_color(textLayer, GColorWhite); text_layer_set_background_color(textLayer, GColorClear); text_layer_set_font(textLayer, font); }
// Handle the start-up of the app void handle_init_app(AppContextRef app_ctx) { // Create our app's base window window_init(&window, "Tic Tock Toe watch"); window_stack_push(&window, true); window_set_background_color(&window, COLOR_BACKGROUND); // Init the layer that shows the board layer_init(&boardLayer, window.layer.frame); // Associate with layer object and set dimensions boardLayer.update_proc = &boardLayer_update_callback; // Set the drawing callback function for the layer. layer_add_child(&window.layer, &boardLayer); // Add the child to the app's base window // Init the layer that shows the player marks // TODO: Wrap this boilerplate in a function? layer_init(&playersLayer, window.layer.frame); playersLayer.update_proc = &playersLayer_update_callback; layer_add_child(&window.layer, &playersLayer); // Init the text layer used to show the time // TODO: Determine best practice for text. e.g. TextLayer with standard update proc vs Layer with custom update proc // TODO: Wrap this boilerplate in a function? text_layer_init(&timeLayer, GRect(0, 168-42, 144 /* width */, 42 /* height */)); text_layer_set_text_alignment(&timeLayer, GTextAlignmentCenter); text_layer_set_text_color(&timeLayer, COLOR_FOREGROUND); text_layer_set_background_color(&timeLayer, GColorClear); text_layer_set_font(&timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); update_time_display(); layer_add_child(&window.layer, &timeLayer.layer); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Bar Graph"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage); layer_add_child(&window.layer, &faceImage.layer.layer); layer_init(&hourLayer, window.layer.frame); hourLayer.update_proc = &update_hour; layer_add_child(&window.layer, &hourLayer); layer_init(&minLayer, window.layer.frame); minLayer.update_proc = &update_minute; layer_add_child(&window.layer, &minLayer); text_layer_init(&dateText, GRect(0,138,144,30)); text_layer_set_text_color(&dateText, GColorWhite); text_layer_set_background_color(&dateText, GColorClear); text_layer_set_text_alignment(&dateText, GTextAlignmentCenter); text_layer_set_font(&dateText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_22))); layer_add_child(&window.layer, &dateText.layer); update_date(); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Hebrew Text"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); // If you neglect to call this, all `resource_get_handle()` requests // will return NULL. resource_init_current_app(&RESOURCES); font42 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SIMPLE_42)); font36 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SIMPLE_36)); font28 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SIMPLE_28)); text_layer_init(&timeLayer, GRect(0, 0, window.layer.frame.size.w, window.layer.frame.size.h)); text_layer_set_text_color(&timeLayer, GColorWhite); text_layer_set_text_alignment(&timeLayer, GTextAlignmentRight); text_layer_set_background_color(&timeLayer, GColorClear); handle_minute_tick(ctx, NULL); layer_add_child(&window.layer, &timeLayer.layer); }
void stop_after_win_init( void ) { stop_after = init_stop_after; window_init( &stop_after_win, "Stop After" ); stop_after_win.window_handlers.appear = (WindowHandler) &stop_after_win_appear; stop_after_win.window_handlers.disappear = (WindowHandler) &stop_after_win_disappear; spinner_init( &stop_after_spin, &stop_after_win, stop_after_up, stop_after_down, SPIN_NO_ADDITIONAL_CLICK_CONFIG, my_ctx ); text_layer_init( &stop_after_title_lay, GRect( 0, 0, SCREEN_WIDTH, 28 ) ); text_layer_set_font( &stop_after_title_lay, fonts_get_system_font( FONT_KEY_ROBOTO_CONDENSED_21 ) ); text_layer_set_text_alignment( &stop_after_title_lay, GTextAlignmentCenter ); text_layer_set_text( &stop_after_title_lay, stop_after_title_str ); layer_add_child( &stop_after_win.layer, &stop_after_title_lay.layer ); inverter_layer_init( &stop_after_title_inverter_lay, GRect( 0, 0, SCREEN_WIDTH, 30 ) ); layer_add_child( &stop_after_win.layer, (Layer*) &stop_after_title_inverter_lay ); text_layer_init( &stop_after_lay, GRect( 0, 55, SCREEN_WIDTH, 30 ) ); text_layer_set_font( &stop_after_lay, fonts_get_system_font( FONT_KEY_BITHAM_30_BLACK ) ); text_layer_set_text_alignment( &stop_after_lay, GTextAlignmentCenter ); text_layer_set_text( &stop_after_lay, get_str_for_stop_after() ); layer_add_child( &stop_after_win.layer, &stop_after_lay.layer ); text_layer_init( &stop_after_bpm_lay, GRect( 0, 85, SCREEN_WIDTH, 25 ) ); text_layer_set_font( &stop_after_bpm_lay, fonts_get_system_font( FONT_KEY_ROBOTO_CONDENSED_21 ) ); text_layer_set_text_alignment( &stop_after_bpm_lay, GTextAlignmentCenter ); text_layer_set_text( &stop_after_bpm_lay, beats_str ); layer_add_child( &stop_after_win.layer, &stop_after_bpm_lay.layer ); }
static void handle_init( AppContextRef ctx) { (void)ctx; // Fonts will NOT work without this! resource_init_current_app(&APP_RESOURCES); window_init(&window, "Hello, Pebble"); window_stack_push(&window, true /* Animated */); // Create a container for the static background image (recovery symbol) bmp_init_container(RESOURCE_ID_IMAGE_FANCY_FRAME, &bg_img); // place image bg_img.layer.layer.frame.origin.x = 0; bg_img.layer.layer.frame.origin.y = 0; layer_add_child(&window.layer, &bg_img.layer.layer); // draw the image layer_mark_dirty(&bg_img.layer.layer); // Tell it what font to use myfont = fonts_load_custom_font( resource_get_handle(RESOURCE_ID_FONT_QUMPELLKA_20)); // Add TIME // GRect takes x,y,w,h text_layer_init(&text_time, GRect(30,70,80,30)); text_layer_set_font(&text_time, myfont); text_layer_set_text(&text_time, ""); text_layer_set_background_color(&text_time, GColorClear); text_layer_set_text_color(&text_time, GColorWhite); text_layer_set_text_alignment(&text_time, GTextAlignmentCenter); layer_add_child(&window.layer, &text_time.layer); /*********************** CODE FOR INCLUDING DATE **************** // Add DAY OF THE MONTH // GRect takes x,y,w,h text_layer_init(&text_day, GRect(75,118,73,58)); text_layer_set_font(&text_day, myfont); text_layer_set_text(&text_day, ""); text_layer_set_background_color(&text_day, GColorClear); text_layer_set_text_color(&text_day, GColorBlack); layer_add_child(&window.layer, &text_day.layer); // Change fonts so the month won't be too big' myfont = fonts_load_custom_font( resource_get_handle(RESOURCE_ID_FONT_QARMIC_SANS_18)); // Add MONTH // GRect takes x,y,w,h text_layer_init(&text_month, GRect(75,144,73,58)); text_layer_set_font(&text_month, myfont); text_layer_set_text(&text_month, ""); text_layer_set_background_color(&text_month, GColorClear); text_layer_set_text_color(&text_month, GColorBlack); layer_add_child(&window.layer, &text_month.layer); *****************************************************************/ }
void handle_init( AppContextRef ctx ) { (void) ctx; window_init( &window, "Timberwolf" ); window_stack_push( &window, true ); resource_init_current_app( &APP_RESOURCES ); // Init the background image layer. bmp_init_container( RESOURCE_ID_IMAGE_BACKGROUND, &background_image ); layer_add_child( &window.layer, &background_image.layer.layer ); // Init the text layer used to show the time. text_layer_init( &time_layer, GRect( 2, -5, 144, 168 ) ); text_layer_set_text_color( &time_layer, GColorBlack ); text_layer_set_background_color( &time_layer, GColorClear ); text_layer_set_font( &time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD) ); layer_add_child( &window.layer, &time_layer.layer ); // Init the text layer used to show the date. text_layer_init( &date_layer, GRect( 83, 0, 144, 168 ) ); text_layer_set_text_color( &date_layer, GColorBlack ); text_layer_set_background_color( &date_layer, GColorClear ); text_layer_set_font( &date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14) ); layer_add_child( &window.layer, &date_layer.layer ); // Init the text layer used to show the weekday. text_layer_init( &wday_layer, GRect( 118, 13, 144, 168 ) ); text_layer_set_text_color( &wday_layer, GColorBlack ); text_layer_set_background_color( &wday_layer, GColorClear ); text_layer_set_font( &wday_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14) ); layer_add_child( &window.layer, &wday_layer.layer ); // Init the text layer used to show AM/PM in 12-hour mode. text_layer_init( &m_layer, GRect( 2, 22, 144, 168 ) ); text_layer_set_text_color( &m_layer, GColorBlack ); text_layer_set_background_color( &m_layer, GColorClear ); text_layer_set_font( &m_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14) ); layer_add_child( &window.layer, &m_layer.layer ); // Avoid a blank screen on watch start. PblTm tick_time; get_time( &tick_time ); update_display( &tick_time ); }
void init_text_layer(TextLayer *layer, GRect rect, char *text, GTextAlignment align) { text_layer_init(layer, rect); text_layer_set_background_color(layer, GColorBlack); text_layer_set_font(layer, big_font); text_layer_set_text_color(layer, GColorWhite); text_layer_set_text(layer, text); text_layer_set_text_alignment(layer, align); }