// define all the fonts used static void load_fonts() { s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_NHL_VAN_64)); s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_NHL_VAN_28)); s_temperature_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_NHL_VAN_22)); s_battery_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_NHL_VAN_22)); s_colon_font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); }
static void main_window_load(Window *window) { // Create GFonts s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_48)); s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20)); // Create GBitmap, then set to created BitmapLayer s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer)); // Create the weather TextLayer s_weather_layer = text_layer_create(GRect(0, 130, 144, 25)); text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, GColorWhite); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); text_layer_set_text(s_weather_layer, "Loading..."); text_layer_set_font(s_weather_layer, s_weather_font); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); // Create the time TextLayer s_time_layer = text_layer_create(GRect(5,52,139,50)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); }
static void window_load(Window *window) { font24 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_24)); font18 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_18)); Layer *window_layer = window_get_root_layer(window); // add the doge face image = gbitmap_create_with_resource(RESOURCE_ID_DOGEFACE); image_layer = bitmap_layer_create(GRect(8, 0, 132, 116)); bitmap_layer_set_bitmap(image_layer, image); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); text_time_layer = text_layer_create(GRect(12, 120, 132, 144)); text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter); text_layer_set_text_color(text_time_layer, GColorBlack); text_layer_set_background_color(text_time_layer, GColorClear); text_layer_set_font(text_time_layer, font24); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); text_price_layer = text_layer_create(GRect(12, 146, 132, 167)); text_layer_set_text_alignment(text_price_layer, GTextAlignmentCenter); text_layer_set_text_color(text_price_layer, GColorBlack); text_layer_set_background_color(text_price_layer, GColorClear); text_layer_set_font(text_price_layer, font18); layer_add_child(window_layer, text_layer_get_layer(text_price_layer)); }
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); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); const GPoint center = grect_center_point(&bounds); //Load bitmap image background_layer = layer_create(bounds); layer_set_update_proc(background_layer, background_layer_update); layer_add_child(window_layer, background_layer); custom_font_text = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BOXY_TEXT_20)); custom_font_outline = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BOXY_OUTLINE_20)); //Add analog hands analog_init(my_window); // Render layer ontop for cool transparency render_layer = layer_create(bounds); layer_set_update_proc(render_layer, render_layer_update); layer_add_child(window_layer, render_layer); //Force time update time_t current_time = time(NULL); struct tm *current_tm = localtime(¤t_time); tick_handler(current_tm, MINUTE_UNIT | DAY_UNIT); //Setup tick time handler tick_timer_service_subscribe((MINUTE_UNIT), tick_handler); }
void handle_init(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, GColorBlack); Layer *window_layer = window_get_root_layer(window); text_date_layer = text_layer_create(GRect(8, 68, 144-8, 168-68)); text_layer_set_text_color(text_date_layer, GColorWhite); text_layer_set_background_color(text_date_layer, GColorClear); text_layer_set_font(text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(window_layer, text_layer_get_layer(text_date_layer)); text_time_layer = text_layer_create(GRect(7, 92, 144-7, 168-92)); 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_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49))); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); GRect line_frame = GRect(8, 97, 139, 2); line_layer = layer_create(line_frame); layer_set_update_proc(line_layer, line_layer_update_callback); layer_add_child(window_layer, line_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.) time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_minute_tick(current_time, MINUTE_UNIT); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }
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(); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); font49 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49)); font39 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_39)); font21 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21)); // create time layer - this is where time goes text_time_layer = text_layer_create(GRect(8, 24, 144-7, 168-92)); 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, font49); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); // create date layer - this is where the date goes text_date_layer = text_layer_create(GRect(8, 0, 144-16, 24)); text_layer_set_text_alignment(text_date_layer, GTextAlignmentCenter); text_layer_set_text_color(text_date_layer, GColorWhite); text_layer_set_background_color(text_date_layer, GColorClear); text_layer_set_font(text_date_layer, font21); layer_add_child(window_layer, text_layer_get_layer(text_date_layer)); // create temperature layer - this is where the temperature goes text_temp_layer = text_layer_create(GRect(80, 108, 144-80, 168-108)); text_layer_set_text_color(text_temp_layer, GColorWhite); text_layer_set_background_color(text_temp_layer, GColorClear); text_layer_set_font(text_temp_layer, font39); layer_add_child(window_layer, text_layer_get_layer(text_temp_layer)); }
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); }
static void set_text_to_window() { //Time TextLayer s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CRYSTAL_36)); s_time_layer = text_layer_create(GRect(5, 50, 130, 40)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorWhite); text_layer_set_text(s_time_layer, "00:00"); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); //Time TextLayer s_timephase_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CRYSTAL_18)); timephase_layer = text_layer_create(GRect(85, 85, 30, 30)); text_layer_set_background_color(timephase_layer, GColorClear); text_layer_set_text_color(timephase_layer, GColorWhite); text_layer_set_text(timephase_layer, "00"); text_layer_set_font(timephase_layer, s_timephase_font); text_layer_set_text_alignment(timephase_layer, GTextAlignmentCenter); // Create current date TextLayer s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CRYSTAL_18)); current_date_layer = text_layer_create(GRect(12, 133, 120, 30)); text_layer_set_background_color(current_date_layer, GColorClear); text_layer_set_text_color(current_date_layer, GColorWhite); text_layer_set_text(current_date_layer, "00.00 000"); text_layer_set_font(current_date_layer, s_date_font); text_layer_set_text_alignment(current_date_layer, GTextAlignmentCenter); }
void handle_init( void ) { // Create the window, add it to the stack, and get its boundaries. window = window_create(); window_stack_push( window, true ); GRect window_bounds = layer_get_bounds( window_get_root_layer(window) ); // Init the background image layer. background_image = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BACKGROUND ); background_layer = bitmap_layer_create( window_bounds ); bitmap_layer_set_bitmap( background_layer, background_image ); layer_add_child( window_get_root_layer(window), bitmap_layer_get_layer(background_layer) ); // Init the text layer used to show the time. time_layer = text_layer_create( GRect( 54, 1, 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_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHICAGO_13)) ); layer_add_child( window_get_root_layer(window), text_layer_get_layer(time_layer) ); // Init the text layer used to show the date. date_layer = text_layer_create( GRect( 9, 86, 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_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GENEVA_12)) ); layer_add_child( window_get_root_layer(window), text_layer_get_layer(date_layer) ); // Avoid a blank screen on watch start. time_t t = time( NULL ); struct tm *tick_time = localtime( &t ); update_display( tick_time ); // Request an update signal every minute. tick_timer_service_subscribe( MINUTE_UNIT, handle_tick ); }
static void main_window_load(Window *window) { s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND_TEST); s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer)); s_time_layer = text_layer_create(GRect(5, 55, 139, 50)); s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_42)); init_text_layer(s_time_layer, s_time_font, GColorBlack, GColorClear, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); s_weather_layer = text_layer_create(GRect(5, 15, 139, 25)); s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20)); init_text_layer(s_weather_layer, s_weather_font, GColorWhite, GColorClear, GTextAlignmentCenter); text_layer_set_text(s_weather_layer, "Loading..."); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); s_wday_layer = text_layer_create(GRect(5, 115, 139, 25)); init_text_layer(s_wday_layer, s_weather_font, GColorWhite, GColorClear, GTextAlignmentCenter); text_layer_set_text(s_wday_layer, "..."); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_wday_layer)); s_date_layer = text_layer_create(GRect(5, 143, 139, 25)); init_text_layer(s_date_layer, s_weather_font, GColorWhite, GColorClear, GTextAlignmentCenter); text_layer_set_text(s_date_layer, "..."); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); update_time(); }
static void main_window_load(Window *window) { // Create Background Layer s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); // Create time Textlayer s_time_layer = text_layer_create(GRect(5, 52, 139, 50)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorWhite); // Create trends TextLayer s_trending_layer = text_layer_create(GRect(0, 110, 144, 25)); text_layer_set_background_color(s_trending_layer, GColorClear); text_layer_set_text_color(s_trending_layer, GColorWhite); text_layer_set_text(s_trending_layer, "Mewing..."); // Time Font s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_CONDENSED_BOLD_42)); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); // Trending Font s_trending_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_CONDENSED_LT_20)); text_layer_set_font(s_trending_layer, s_trending_font); text_layer_set_text_alignment(s_trending_layer, GTextAlignmentCenter); //Add layers in order as child layers to the Window's root layer layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_trending_layer)); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); // GRect bounds = layer_get_bounds(window_layer); deco_layer = layer_create(GRect(0, 0, 144, 8)); layer_set_update_proc(deco_layer, deco_layer_onupdate); arrow_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ARROW_24); image_layer = bitmap_layer_create(GRect(12, 20, 24, 24)); bitmap_layer_set_bitmap(image_layer, arrow_image); text_layer = text_layer_create(GRect(16, 113, 128, 24)); text_layer_set_background_color(text_layer, METRO_APP_BACK_COLOR); text_layer_set_text_color(text_layer, METRO_APP_TEXT_COLOR); text_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_OSWALD_LIGHT_18)); text_layer_set_font(text_layer, text_font); time_layer = text_layer_create(GRect(16, 58, 128, 48)); text_layer_set_background_color(time_layer, METRO_APP_BACK_COLOR); text_layer_set_text_color(time_layer, METRO_APP_TEXT_COLOR); time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_OSWALD_REGULAR_48)); text_layer_set_font(time_layer, time_font); layer_add_child(window_layer, deco_layer); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); layer_add_child(window_layer, text_layer_get_layer(text_layer)); layer_add_child(window_layer, text_layer_get_layer(time_layer)); }
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); }
static void window_load(Window *window) { window_set_background_color(window, GColorBlack); canvas = layer_create(GRect(0, 0, SCREEN_WIDTH , SCREEN_HEIGHT)); layer_set_update_proc(canvas, (LayerUpdateProc) render); layer_add_child(window_get_root_layer(window), canvas); mTimeFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_40)); mTimeFontBold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_BOLD_40)); mSmallFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_BOLD_24)); mTinyFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TREBUCHET_16)); // Init all text fields const int mTwoDigitTextSize = sizeof("00:00 "); mDayText = malloc(mTwoDigitTextSize); mMonthText = malloc(mTwoDigitTextSize); mYearText = malloc(mTwoDigitTextSize); mHourText = malloc(mTwoDigitTextSize); mMinuteText = malloc(mTwoDigitTextSize); mSecondText = malloc(mTwoDigitTextSize); // Set initial time so display isn't blank struct tm* t; time_t temp; temp = time(NULL); t = localtime(&temp); set_time_display(t); battery_handler(battery_state_service_peek()); }
static void init(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, GColorBlack); weather_data = malloc(sizeof(WeatherData)); init_network(weather_data); font_date = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_18)); font_time = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_CONDENSED_53)); time_layer = text_layer_create(TIME_FRAME); text_layer_set_text_color(time_layer, GColorWhite); text_layer_set_background_color(time_layer, GColorClear); text_layer_set_font(time_layer, font_time); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer)); date_layer = text_layer_create(DATE_FRAME); text_layer_set_text_color(date_layer, GColorWhite); text_layer_set_background_color(date_layer, GColorClear); text_layer_set_font(date_layer, font_date); text_layer_set_text_alignment(date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer)); // Add weather layer weather_layer = weather_layer_create(GRect(0, 90, 144, 80)); layer_add_child(window_get_root_layer(window), weather_layer); // Update the screen right away time_t now = time(NULL); handle_tick(localtime(&now), SECOND_UNIT | MINUTE_UNIT | HOUR_UNIT | DAY_UNIT ); // And then every second tick_timer_service_subscribe(SECOND_UNIT, handle_tick); }
static void main_window_load(Window *window) { // Create GBitmap, then set to created BitmapLayer s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND); s_background_layer = bitmap_layer_create(GRect(0,0,144,168)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer)); // Create temperature Layer s_weather_layer = text_layer_create(GRect(15,130,144,25)); text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, GColorWhite); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); text_layer_set_text(s_weather_layer, "Loading ..."); // Create time TextLayer s_time_layer = text_layer_create(GRect(5, 59, 139, 50)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorWhite); // Create GFonts s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_APERCU_30)); s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_APERCU_15)); // Improve the layout to be more like a watchface text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); text_layer_set_font(s_weather_layer, s_weather_font); // Add it as a child layer to the Window's root layer layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); }
static void init(void) { pebbleLocale = setlocale(LC_ALL, ""); window = window_create(); window_set_background_color(window, GColorBlack); window_stack_push(window, true); rootLayer = window_get_root_layer(window); srand(time(NULL)); layer = layer_create(GRect(0, 0, WIDTH, HEIGHT)); layer_set_update_proc(layer, updateScreen); layer_add_child(rootLayer, layer); fontHour = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BORIS_47)); #if defined(SHOWDATE) fontDate = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BORIS_18)); #endif setText(); initRects(); reset(); timer = app_timer_register(DELAY, timerCallback, NULL); tick_timer_service_subscribe(MINUTE_UNIT, minuteChange); accel_data_service_subscribe(0, NULL); accel_tap_service_subscribe(tapHandler); }
WeatherLayer *weather_layer_create(GRect frame) { // Create a new layer with some extra space to save our custom Layer infos WeatherLayer *weather_layer = layer_create_with_data(frame, sizeof(WeatherLayerData)); WeatherLayerData *wld = layer_get_data(weather_layer); large_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_40)); small_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_35)); // Add background layer wld->temp_layer_background = text_layer_create(GRect(0, 10, 144, 68)); text_layer_set_background_color(wld->temp_layer_background, GColorWhite); layer_add_child(weather_layer, text_layer_get_layer(wld->temp_layer_background)); // Add temperature layer wld->temp_layer = text_layer_create(GRect(70, 19, 72, 80)); text_layer_set_background_color(wld->temp_layer, GColorClear); text_layer_set_text_alignment(wld->temp_layer, GTextAlignmentCenter); text_layer_set_font(wld->temp_layer, large_font); layer_add_child(weather_layer, text_layer_get_layer(wld->temp_layer)); // Add bitmap layer wld->icon_layer = bitmap_layer_create(GRect(9, 13, 60, 60)); layer_add_child(weather_layer, bitmap_layer_get_layer(wld->icon_layer)); wld->icon = NULL; return weather_layer; }
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 multi_code_set_fonts(void) { fonts_changed = false; if (font_pin.isCustom) fonts_unload_custom_font(font_pin.font); switch(font_style) { case 1 : font_pin.font = fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS); font_pin.isCustom = false; pin_origin_y = 0; break; case 2 : font_pin.font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITAL_42)); font_pin.isCustom = true; pin_origin_y = -8; break; case 3 : font_pin.font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BD_CARTOON_30)); font_pin.isCustom = true; pin_origin_y = 2; break; default : font_style = 0; font_pin.font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BITWISE_32)); font_pin.isCustom = true; pin_origin_y = 0; break; } }
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 window_load(Window *window) { //Get resources ResHandle font_20 = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_20); ResHandle font_25 = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_25); ResHandle font_43 = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_43); //Bottom frame lower_layer = text_layer_create(GRect(0, 84, 144, 84)); text_layer_set_background_color(lower_layer, GColorBlack); layer_add_child(window_get_root_layer(window), text_layer_get_layer(lower_layer)); //TextLayers time_layer = cl_init_text_layer(GRect(1, 41, 150, 50), GColorBlack, GColorClear, font_43, GTextAlignmentLeft); layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer)); am_pm_layer = cl_init_text_layer(GRect(0, 0, 0, 0), GColorBlack, GColorClear, font_20, GTextAlignmentLeft); layer_add_child(window_get_root_layer(window), text_layer_get_layer(am_pm_layer)); day_layer = cl_init_text_layer(GRect(1, 75, 150, 50), GColorWhite, GColorClear, font_25, GTextAlignmentLeft); text_layer_set_text(day_layer, "MON"); layer_add_child(window_get_root_layer(window), text_layer_get_layer(day_layer)); date_layer = cl_init_text_layer(GRect(70, 75, 150, 50), GColorWhite, GColorClear, font_25, GTextAlignmentLeft); text_layer_set_text(date_layer, "25"); layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer)); month_layer = cl_init_text_layer(GRect(1, 95, 150, 50), GColorWhite, GColorClear, font_20, GTextAlignmentLeft); text_layer_set_text(month_layer, "JANUARY"); layer_add_child(window_get_root_layer(window), text_layer_get_layer(month_layer)); //Init display not blank time_t temp = time(NULL); struct tm *t = localtime(&temp); set_time(t); }
Layer *status_layer_create(GRect frame){ // Create a new layer with some extra space to save our custom Layer infos status_layer = layer_create(frame); large_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_40)); small_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_14)); // Add background layer background_layer = text_layer_create(GRect(0, 10, 144, 68)); text_layer_set_background_color(background_layer, GColorWhite); layer_add_child(status_layer, text_layer_get_layer(background_layer)); // Add temperature layer temp_layer = text_layer_create(GRect(60, 19, 82, 80)); text_layer_set_background_color(temp_layer, GColorClear); text_layer_set_text_alignment(temp_layer, GTextAlignmentCenter); text_layer_set_font(temp_layer, large_font); layer_add_child(status_layer, text_layer_get_layer(temp_layer)); // Add bitmap layer icon_layer = bitmap_layer_create(GRect(9, 10, 60, 60)); layer_add_child(status_layer, bitmap_layer_get_layer(icon_layer)); // Add duration layer duration_layer = text_layer_create(GRect(0, 63, 78, 16)); text_layer_set_background_color(duration_layer, GColorClear); text_layer_set_text_alignment(duration_layer, GTextAlignmentCenter); text_layer_set_font(duration_layer, small_font); layer_add_child(status_layer, text_layer_get_layer(duration_layer)); bitmap = NULL; return status_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); }
static void handle_init( AppContextRef ctx ) { (void) ctx; window_init(&window, "Main"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); // resource_init_current_app(&RESOURCES); resource_init_current_app(&APP_RESOURCES); int y = 15; int h = 30; font_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_22)); font_thin = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_28)); font_thick = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_BLACK_30)); // Stack top to bottom. Note that the hour can take up // two rows at midnight. text_layer(&m_small_word, GRect(4, y + 3*h+2, 144, h+8), font_small); text_layer(&m_word, GRect(4, y + 3*h, 144, h+8), font_thin); text_layer(&hour_word, GRect(4, y + 2*h-2, 144, 2*h+8), font_thick); text_layer(&rel_small_word, GRect(4, y + 1*h+2, 144, h+8), font_small); text_layer(&rel_word, GRect(4, y + 1*h, 144, h+8), font_thin); text_layer(&min_word, GRect(4, y + 0*h, 144, h+8), font_thin); }
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); }
static void main_window_load(Window *window) { // Load the custom font s_icons = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ICONS_32)); s_helvetic_bold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_HELVETICA_BOLD_20)); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); s_status_bar = status_bar_layer_create(); status_bar_layer_set_separator_mode(s_status_bar, StatusBarLayerSeparatorModeNone); status_bar_layer_set_colors(s_status_bar, GColorBlack, GColorWhite); // Create MenuLayer #if defined(PBL_RECT) s_menu_layer = menu_layer_create(GRect(0, STATUS_BAR_LAYER_HEIGHT, bounds.size.w, bounds.size.h)); #elif defined(PBL_ROUND) s_menu_layer = menu_layer_create(bounds); #endif menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks) { .get_num_sections = (MenuLayerGetNumberOfSectionsCallback)get_num_sections_callback, .get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback)get_num_rows_callback, .get_cell_height = (MenuLayerGetCellHeightCallback)get_cell_height_callback, .get_header_height = (MenuLayerGetHeaderHeightCallback)get_header_height_callback, .draw_row = (MenuLayerDrawRowCallback)draw_row_callback, .draw_header = (MenuLayerDrawHeaderCallback)draw_header_callback, .select_click = (MenuLayerSelectCallback)select_callback, });
static void do_init(void) { s_data.window = window_create(); const bool animated = true; window_stack_push(s_data.window, animated); window_set_background_color(s_data.window, GColorBlack); hours_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHAM_BOLD_36)); regular_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHAM_BOOK_28)); Layer *root_layer = window_get_root_layer(s_data.window); GRect frame = layer_get_frame(root_layer); int screen_width = frame.size.w; s_data.hours = text_layer_create(GRect(0, 5, screen_width, 45)); common_text_layer_init(s_data.hours, hours_font); s_data.middles = text_layer_create(GRect(0, 50, screen_width, 30)); common_text_layer_init(s_data.middles, regular_font); s_data.offsets = text_layer_create(GRect(0, 90, screen_width, 60)); common_text_layer_init(s_data.offsets, regular_font); time_t now = time(NULL); struct tm *t = localtime(&now); update_time(t); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }