/*! * Initializes graphic elements and subscribes to accelerometer * * \param window the app's main window */ void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MAIN); GRect bounds = layer_get_frame(window_layer); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_alignment(image_layer, GAlignCenter); note_layer = bitmap_layer_create(bounds); bitmap_layer_set_compositing_mode(note_layer, GCompOpAnd); bitmap_layer_set_alignment(note_layer, GAlignCenter); bitmap_layer_set_bitmap(note_layer, bitmap); bitmap_layer_set_bitmap(image_layer, bitmap); notes[NOTE_C] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_C); notes[NOTE_D] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_D); notes[NOTE_E] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_E); notes[NOTE_F] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_F); notes[NOTE_G] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_G); notes[NOTE_A] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_A); notes[NOTE_B] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_B); notes[NOTE_HI_C] = gbitmap_create_with_resource(RESOURCE_ID_NOTE_HI_C); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); /* layer_add_child(window_layer, bitmap_layer_get_layer(note_layer)); */ layer_insert_above_sibling(bitmap_layer_get_layer(note_layer), bitmap_layer_get_layer(image_layer)); accel_data_service_subscribe(0, accel_handler); accel_service_set_sampling_rate(ACCEL_SAMPLING_50HZ); }
static void main_window_load(Window *window) { int left = 0; left += LAYER_STATUS_LEFT_GAP; s_status_bt_layer = bitmap_layer_create(GRect(left, 0, LAYER_STATUS_BMP_WIDTH, LAYER_STATUS_HEIGHT)); bitmap_layer_set_alignment(s_status_bt_layer, GAlignRight); bitmap_layer_set_compositing_mode(s_status_bt_layer, GCompOpAssignInverted); layer_add_child(window_get_root_layer(window), (Layer *) s_status_bt_layer); left += LAYER_STATUS_BMP_WIDTH + LAYER_STATUS_GAP; s_status_battery_layer = bitmap_layer_create(GRect(left, 0, LAYER_STATUS_BMP_WIDTH, LAYER_STATUS_HEIGHT));\ bitmap_layer_set_alignment(s_status_battery_layer, GAlignLeft); bitmap_layer_set_compositing_mode(s_status_battery_layer, GCompOpAssignInverted); layer_add_child(window_get_root_layer(window), (Layer *) s_status_battery_layer); left += LAYER_STATUS_BMP_WIDTH; s_status_charge_layer = bitmap_layer_create(GRect(left, 0, LAYER_STATUS_BMP_WIDTH, LAYER_STATUS_HEIGHT));\ bitmap_layer_set_alignment(s_status_charge_layer, GAlignLeft); bitmap_layer_set_compositing_mode(s_status_charge_layer, GCompOpAssignInverted); layer_add_child(window_get_root_layer(window), (Layer *) s_status_charge_layer); left += LAYER_STATUS_BMP_WIDTH; s_status_text_layer = create_text_layer(window, GRect(left, 0, LAYER_STATUS_TEXT_WIDTH, LAYER_STATUS_HEIGHT)); text_layer_set_text_alignment(s_status_text_layer, GAlignRight); set_status_text(""); }
/*! * Processes the message received from the phone * * \param iterator the dictionary sent to the pebble * \param context unused */ void inbox_received_callback(DictionaryIterator *iterator, void *context) { // set the timeout if (!(app_timer_reschedule(phone_timer, PHONE_TIMEOUT))) { phone_timer = app_timer_register(PHONE_TIMEOUT, phone_timer_callback, NULL); } Tuple* tup = dict_find(iterator, 0); if (tup) { if (tup->type == TUPLE_UINT) { int val = -1; switch(tup->length) { case 1: val = tup->value->uint8; break; case 2: val = tup->value->uint16; break; case 4: val = tup->value->uint32; break; } if (val >= 0 && val < 8) { bitmap_layer_set_bitmap(note_layer, notes[val]); bitmap_layer_set_alignment(note_layer, GAlignRight); } else { bitmap_layer_set_bitmap(note_layer, bitmap); bitmap_layer_set_alignment(note_layer, GAlignCenter); } } } }
void LoadMainBmpImage(Window *window, int id, int floorId) { int resourceId = id; Layer *window_layer = window_get_root_layer(window); #if DISABLE_MENU_BMPS return; #endif if(!window) { DEBUG_LOG("Skipping image load due to window not yet available."); return; } if(mainImageLoaded) { if(mainImageResourceLoaded == resourceId) { DEBUG_LOG("Resource %d already loaded.", resourceId); if(floorImageLoaded) layer_add_child(window_layer, bitmap_layer_get_layer(floorImage)); layer_add_child(window_layer, bitmap_layer_get_layer(mainImage)); return; // already loaded the correct one. } DEBUG_LOG("Unloading resourceId %d.", mainImageResourceLoaded); UnloadMainBmpImage(); } DEBUG_LOG("Loading resourceId %d.", resourceId); #if defined(PBL_COLOR) if(floorId >= 0) { floorImageBitmap = gbitmap_create_with_resource(floorId); floorImage = bitmap_layer_create(mainFrame); bitmap_layer_set_bitmap(floorImage, floorImageBitmap); bitmap_layer_set_alignment(floorImage, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(floorImage)); floorImageLoaded = true; } #endif ProfileLogStart("LoadMainBmpImage"); mainImageBitmap = gbitmap_create_with_resource(resourceId); mainImage = bitmap_layer_create(mainFrame); bitmap_layer_set_bitmap(mainImage, mainImageBitmap); bitmap_layer_set_alignment(mainImage, GAlignCenter); #if defined(PBL_COLOR) bitmap_layer_set_compositing_mode(mainImage, GCompOpSet); #endif layer_add_child(window_layer, bitmap_layer_get_layer(mainImage)); mainImageLoaded = true; mainImageResourceLoaded = resourceId; ProfileLogStop("LoadMainBmpImage"); }
static void typicalIconLayerCreate(uint8_t layerNumber) { // A lot is assumed here, could be a source of problems s_checkIcons_layers[layerNumber] = bitmap_layer_create(GRect(0, CHECK_ICON_START + PBL_IF_RECT_ELSE(layerNumber, layerNumber + 1) * CHECK_ICON_HEIGHT, CHECK_ICON_HEIGHT, CHECK_ICON_HEIGHT)); bitmap_layer_set_background_color(s_checkIcons_layers[layerNumber], GColorWhite); bitmap_layer_set_alignment(s_checkIcons_layers[layerNumber], GAlignCenter); scroll_layer_add_child(s_checklist_scroll, bitmap_layer_get_layer(s_checkIcons_layers[layerNumber])); // Adds the root layer to the window }
int main(void) { window = window_create(); window_stack_push(window, true); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); //Load in logo image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_LOGO); //Draw the logo image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); //Start main loop app_event_loop(); //Unload the logo gbitmap_destroy(image); //Destroy the graphics layer bitmap_layer_destroy(image_layer); window_destroy(window); }
void LoadMainBmpImage(Window *window, int id) { DEBUG_LOG("Loading Main resourceId %d.", id); int resourceId = id; Layer *window_layer = window_get_root_layer(window); if(!window) { DEBUG_LOG("Skipping image load due to window not yet available."); return; } if(mainImageLayerLoaded) { if(mainImageLayerResourceLoaded == resourceId) { layer_add_child(window_layer, bitmap_layer_get_layer(mainImageLayer)); DEBUG_LOG("Already Loaded correct image"); return; // already loaded the correct one. } UnloadMainBmpImage(); } mainImage = gbitmap_create_with_resource(resourceId); mainImageLayer = bitmap_layer_create(mainFrame); bitmap_layer_set_bitmap(mainImageLayer, mainImage); bitmap_layer_set_alignment(mainImageLayer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(mainImageLayer)); mainImageLayerLoaded = true; mainImageLayerResourceLoaded = resourceId; DEBUG_LOG("LOADED Main resourceId %d.", resourceId); }
static void create_logo_layer(Window *window) { GRect logoBounds = logo_image->bounds; notification_layer = layer_create(GRect(0, bounds.size.h - logoBounds.size.h, bounds.size.w, logoBounds.size.h)); layer_add_child(window_get_root_layer(window), notification_layer); // display logo logo_layer = bitmap_layer_create(GRect(3, 0, bounds.size.w, logoBounds.size.h)); bitmap_layer_set_background_color(logo_layer, GColorWhite); bitmap_layer_set_alignment(logo_layer, GAlignTopLeft); bitmap_layer_set_bitmap(logo_layer, logo_image); layer_add_child(notification_layer, bitmap_layer_get_layer(logo_layer)); // display notofications int offset = 4; notification_text_layer = text_layer_create(GRect(logoBounds.size.w + 7, offset, bounds.size.w - logoBounds.size.w - 7, logoBounds.size.h - offset)); //text_layer_set_background_color(notification_text_layer, GColorClear); text_layer_set_font(notification_text_layer, statusFont); text_layer_set_text_alignment(notification_text_layer, GTextAlignmentLeft); text_layer_set_overflow_mode(notification_text_layer, GTextOverflowModeTrailingEllipsis); //text_layer_set_text(notification_text_layer, "noti"); layer_add_child(notification_layer, text_layer_get_layer(notification_text_layer)); // hide notification bar for state item, show for other items layer_set_hidden(notification_layer, (current_item == 0 ? true : false)); }
static void window_load(Window *window) { Loading = 1; Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_alignment(image_layer, GAlignTop); #ifdef PBL_COLOR bitmap_layer_set_background_color(image_layer, TRMainColor); #else bitmap_layer_set_background_color(image_layer, GColorBlack); #endif // display initial app graphic #ifdef PBL_COLOR image = gbitmap_create_with_resource(RESOURCE_ID_INIT_B); #else image = gbitmap_create_with_resource(RESOURCE_ID_INIT_A); #endif bitmap_layer_set_bitmap(image_layer, image); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); message_text_layer = text_layer_create(GRect(0, bounds.size.h - 160, bounds.size.w, bounds.size.h)); text_layer_set_text(message_text_layer, "Loading..."); text_layer_set_font(message_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(message_text_layer, GTextAlignmentCenter); text_layer_set_overflow_mode(message_text_layer, GTextOverflowModeWordWrap); #ifdef PBL_COLOR text_layer_set_text_color(message_text_layer, GColorBlack); #else text_layer_set_text_color(message_text_layer, GColorWhite); #endif text_layer_set_background_color(message_text_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(message_text_layer)); error_text_layer = text_layer_create(GRect(0, bounds.size.h - 148, bounds.size.w, 80)); text_layer_set_text(error_text_layer, ""); text_layer_set_font(error_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(error_text_layer, GTextAlignmentCenter); text_layer_set_text_color(error_text_layer, GColorWhite); text_layer_set_background_color(error_text_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(error_text_layer)); username_text_layer = text_layer_create(GRect(0, bounds.size.h - 25, bounds.size.w, 25)); text_layer_set_text(username_text_layer, ""); text_layer_set_font(username_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(username_text_layer, GTextAlignmentLeft); text_layer_set_background_color(username_text_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(username_text_layer, TRAltColor); #else text_layer_set_text_color(username_text_layer, GColorBlack); #endif layer_add_child(window_layer, text_layer_get_layer(username_text_layer)); }
/** * Create bitmap layer with all values **/ BitmapLayer* macro_bitmap_layer_create(GBitmap *bitmap, GRect frame, Layer *parent, bool visible) { BitmapLayer* layer = bitmap_layer_create(frame); bitmap_layer_set_compositing_mode(layer, BMP_COMPOSITING_MODE); bitmap_layer_set_alignment(layer, GAlignCenter); layer_add_child(parent, bitmap_layer_get_layer(layer)); if(bitmap != NULL) bitmap_layer_set_bitmap(layer, bitmap); layer_set_hidden(bitmap_layer_get_layer(layer), !visible); return layer; }
/*----------------------------------------------------------------------------*/ int main(void) { APP_LOG(APP_LOG_LEVEL_INFO, "main: entry: %s %s", __TIME__, __DATE__); /* * Commission App */ window = window_create(); WindowHandlers handlers = {.load = window_load, .unload = window_unload }; window_set_window_handlers(window, handlers); const bool animated = true; window_stack_push(window, animated); Layer * window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); /* Display the simple splash screen to indicate PebblePointer is running. */ image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PEBBLEPOINTER); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); /* Basic accelerometer initialization. Enable Tap-Tap functionality. */ accel_service_set_sampling_rate( SAMPLING_RATE ); accel_tap_service_subscribe( (AccelTapHandler) accel_tap_callback ); app_message_open(SYNC_BUFFER_SIZE, SYNC_BUFFER_SIZE); /* Request notfication on Bluetooth connectivity changes. */ bluetooth_connection_service_subscribe( bluetooth_connection_callback ); isConnected = bluetooth_connection_service_peek(); APP_LOG(APP_LOG_LEVEL_INFO, "initially %sonnected", (isConnected) ? "c" : "disc"); /* * Event Processing */ app_event_loop(); /* * Decommission App */ if (tapSwitchState == true) { accel_data_service_unsubscribe(); } /* Remove the Tap-Tap callback */ accel_tap_service_unsubscribe(); /* Release splash-screen resources */ gbitmap_destroy(image); bitmap_layer_destroy(image_layer); window_destroy(window); APP_LOG(APP_LOG_LEVEL_INFO, "main: exit"); }
void show_loading() { Layer *window_layer = window_get_root_layer(window[current_level]); if (refresh_layer == NULL) { refresh_layer = bitmap_layer_create(layer_get_bounds(window_layer)); refresh_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_REFRESH); bitmap_layer_set_alignment(refresh_layer, GAlignCenter); bitmap_layer_set_background_color(refresh_layer, GColorClear); bitmap_layer_set_bitmap(refresh_layer, refresh_bitmap); } layer_set_hidden(bitmap_layer_get_layer(refresh_layer), false); layer_add_child(window_layer, bitmap_layer_get_layer(refresh_layer)); }
void LoadBackgroundImage(Window *window, int id) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); if(!backgroundLoaded) { backgroundBitmap = gbitmap_create_with_resource(id); backgroundImage = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(backgroundImage, backgroundBitmap); bitmap_layer_set_alignment(backgroundImage, GAlignLeft); backgroundLoaded = true; } layer_add_child(window_layer, bitmap_layer_get_layer(backgroundImage)); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); text_layer = text_layer_create(GRect(0, bounds.size.h - 16, bounds.size.w, 16)); text_layer_set_text(text_layer, "Press select"); text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); text_layer_set_background_color(text_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(text_layer)); }
static void simple_image(void) { //window = window_create(); //window_stack_push(window, true /* Animated */); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); // This needs to be deinited on app exit which is when the event loop ends image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BUTT); // The bitmap layer holds the image for display image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); }
/*************************************************************** * LOAD and UNLOAD ***************************************************************/ static void power_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); //init layers Layer *simple_bg_layer = layer_create(bounds); layer_set_update_proc(simple_bg_layer, power_bg_update_proc); layer_add_child(window_layer, simple_bg_layer); //background clock BitmapLayer *background = bitmap_layer_create(bounds); radioImage = gbitmap_create_with_resource(RESOURCE_ID_POWER); bitmap_layer_set_bitmap(background, radioImage); bitmap_layer_set_alignment(background, GAlignBottom); bitmap_layer_set_compositing_mode(background, GCompOpAssign); layer_add_child(window_layer, bitmap_layer_get_layer(background)); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); window_set_background_color(window, GColorBlack); temp1_layer = text_layer_create(GRect(7, 2, bounds.size.w-14, 44)); text_layer_set_text_color(temp1_layer, GColorWhite); text_layer_set_background_color(temp1_layer, GColorClear); text_layer_set_font(temp1_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_text_alignment(temp1_layer, GTextAlignmentRight); layer_add_child(window_layer, text_layer_get_layer(temp1_layer)); temp2_layer = text_layer_create(GRect(7, 46, bounds.size.w-14, 48)); text_layer_set_text_color(temp2_layer, GColorWhite); text_layer_set_background_color(temp2_layer, GColorClear); text_layer_set_font(temp2_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_text_alignment(temp2_layer, GTextAlignmentRight); layer_add_child(window_layer, text_layer_get_layer(temp2_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); text_time_layer = text_layer_create(GRect(7, 96, bounds.size.w-14, bounds.size.h-96)); 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_BITHAM_42_BOLD)); text_layer_set_text_alignment(text_time_layer, GTextAlignmentRight); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); // add setpoint icons upper_setpoint_image = gbitmap_create_with_resource(RESOURCE_ID_SETPOINT_UPPER); lower_setpoint_image = gbitmap_create_with_resource(RESOURCE_ID_SETPOINT_LOWER); for (int i=0; i<4; i++) { setpoint_image_layers[i] = bitmap_layer_create(GRect(8, 12 + (i*18) + ((i&2)*4), 16, 16)); bitmap_layer_set_alignment(setpoint_image_layers[i], GAlignCenter); bitmap_layer_set_bitmap(setpoint_image_layers[i], (i & 1 ? lower_setpoint_image : upper_setpoint_image)); layer_set_hidden(bitmap_layer_get_layer(setpoint_image_layers[i]), true); layer_add_child(window_layer, bitmap_layer_get_layer(setpoint_image_layers[i])); } }
static void main_window_load(Window *window){ Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); GRect weather_bounds = GRect(0,PBL_IF_ROUND_ELSE(115,105), bounds.size.w, 50); s_status_bar = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(18,5), bounds.size.w, 50)); s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(43,35), bounds.size.w, 50)); //Load custom minimal font s_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_REGULAR_DOS_48)); s_font_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_REGULAR_DOS_12)); s_weather_bitmap = gbitmap_create_with_resource(getImageId(temperature)); s_weather_icon = bitmap_layer_create(weather_bounds); window_set_background_color(s_main_window, GColorVividCerulean); //Set time text layer attributes 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_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); //Set status bar layer attributes text_layer_set_background_color(s_status_bar, GColorClear); text_layer_set_text_color(s_status_bar, GColorWhite); //text_layer_set_text(s_status_bar, "Battery status"); text_layer_set_font(s_status_bar, s_font_small); text_layer_set_text_alignment(s_status_bar, GTextAlignmentCenter); bitmap_layer_set_alignment(s_weather_icon, GAlignCenter); bitmap_layer_set_background_color(s_weather_icon, GColorClear); bitmap_layer_set_compositing_mode(s_weather_icon, GCompOpSet); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); layer_add_child(window_layer, text_layer_get_layer(s_status_bar)); bitmap_layer_set_bitmap(s_weather_icon, s_weather_bitmap); layer_add_child(window_layer, bitmap_layer_get_layer(s_weather_icon)); battery_handler(battery_state_service_peek()); }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); //Bitmap Layyer + GBitmap s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ROBOSTANGS_LOGO); s_background_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); bitmap_layer_set_alignment(s_background_layer, GAlignTop); layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); //Time layer s_time_layer = text_layer_create(GRect(0, 125, bounds.size.w, 50)); s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BANK_GOTHIC_30)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, PBL_IF_BW_ELSE(GColorWhite, GColorChromeYellow)); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); }
void init_cards(Window *main_window, GBitmap *main_image_front, BitmapLayer *main_image_layer_front, CardBack_t main_card_back) { reset_card_used(); current_card = rand() % NUMBER_OF_CARDS; current_side = FRONT; window = main_window; image_front = main_image_front; image_layer_front = main_image_layer_front; card_back = main_card_back; init_card_text(); GRect bounds = layer_get_bounds(window_get_root_layer(window)); image_layer_front = bitmap_layer_create(bounds); bitmap_layer_set_alignment(image_layer_front, GAlignCenter); layer_add_child(window_get_root_layer(window), (Layer*)image_layer_front); load_card(); }
static void webcam_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); webcam_status_text_layer = text_layer_create(GRect(0, bounds.size.h - 16, bounds.size.w, 16)); text_layer_set_text(webcam_status_text_layer, "Please wait..."); text_layer_set_font(webcam_status_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(webcam_status_text_layer, GTextAlignmentCenter); text_layer_set_background_color(webcam_status_text_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(webcam_status_text_layer)); DictionaryIterator *iter; app_message_outbox_begin(&iter); dict_write_int(iter, KEY_WEBCAM, &webcam_current_id, sizeof(int), true); dict_write_end(iter); app_message_outbox_send(); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Moon phases"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&SOMETHINGSIGNIFICANT); bmp_init_container(RESOURCE_ID_THE_MOON, &the_moon); layer_set_frame(&the_moon.layer.layer, GRect(0, 0, WIDTH, HEIGHT - TEXTH)); bitmap_layer_set_alignment(&the_moon.layer, GAlignCenter); layer_add_child(&window.layer, &the_moon.layer.layer); layer_init(&moon_layer, window.layer.frame); layer_set_frame(&moon_layer, GRect(0, 0, WIDTH, HEIGHT - TEXTH)); moon_layer.update_proc = moon_LayerUpdateProc; // MAGIC! layer_add_child(&window.layer, &moon_layer); text_layer_init(&phase_text, window.layer.frame); text_layer_set_text_color(&phase_text, GColorBlack); text_layer_set_background_color(&phase_text, GColorWhite); text_layer_set_text_alignment(&phase_text, GTextAlignmentCenter); layer_set_frame(&phase_text.layer, GRect(0, HEIGHT - TEXTH, WIDTH, TEXTH)); layer_add_child(&window.layer, &phase_text.layer); text_layer_init(&fudge_text, window.layer.frame); text_layer_set_text_color(&fudge_text, GColorBlack); text_layer_set_background_color(&fudge_text, GColorClear); text_layer_set_text_alignment(&fudge_text, GTextAlignmentRight); layer_set_frame(&fudge_text.layer, GRect(0, HEIGHT - TEXTH, WIDTH, TEXTH)); layer_add_child(&window.layer, &fudge_text.layer); window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider); update_phase(); }
void LoadMainBmpImage(Window *window, int id) { int resourceId = id; Layer *window_layer = window_get_root_layer(window); #if DISABLE_MENU_BMPS return; #endif if(!window) { DEBUG_LOG("Skipping image load due to window not yet available."); return; } if(mainImageLoaded) { if(mainImageResourceLoaded == resourceId) { DEBUG_LOG("Resource %d already loaded.", resourceId); layer_add_child(window_layer, bitmap_layer_get_layer(mainImage)); return; // already loaded the correct one. } DEBUG_LOG("Unloading resourceId %d.", mainImageResourceLoaded); UnloadMainBmpImage(); } DEBUG_LOG("Loading resourceId %d.", resourceId); mainImageBitmap = gbitmap_create_with_resource(resourceId); mainImage = bitmap_layer_create(mainFrame); bitmap_layer_set_bitmap(mainImage, mainImageBitmap); bitmap_layer_set_alignment(mainImage, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(mainImage)); mainImageLoaded = true; mainImageResourceLoaded = resourceId; }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); // Create time TextLayer s_time_layer = text_layer_create(GRect(0, 133, 144, 50)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); text_layer_set_text(s_time_layer, "00/00 00:00"); // Improve the layout to be more like a watchface text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); // This needs to be deinited on app exit which is when the event loop ends image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_3QR_ORG_A); // The bitmap layer holds the image for display image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignTop); // Add it as a child layer to the Window's root layer layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); // Make sure the time is displayed from the start update_time(); }
static void window_appear(Window* window) { Layer* window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); scroll_layer = scroll_layer_create(bounds); scroll_layer_set_click_config_onto_window(scroll_layer, window); #ifdef PBL_ROUND scroll_layer_set_paging(scroll_layer, true); #endif urlab_logo = gbitmap_create_with_resource(RESOURCE_ID_URLAB_LOGO); GRect image_bound = gbitmap_get_bounds(urlab_logo); image_layer = bitmap_layer_create(GRect(0, 0, bounds.size.w, image_bound.size.h)); bitmap_layer_set_bitmap(image_layer, urlab_logo); bitmap_layer_set_alignment(image_layer, GAlignCenter); scroll_layer_add_child(scroll_layer, bitmap_layer_get_layer(image_layer)); text_layer = text_layer_create(GRect(0, image_bound.size.h, bounds.size.w , bounds.size.h / 2)); text_layer_set_text (text_layer, about_text); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); #ifdef PBL_ROUND uint8_t inset = 4; text_layer_enable_screen_text_flow_and_paging(text_layer, inset); #endif layer_add_child(window_layer, text_layer_get_layer(text_layer)); scroll_layer_add_child(scroll_layer, text_layer_get_layer(text_layer)); layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer)); scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, image_bound.size.h + bounds.size.h / 2)); }
// initialize app state based on i_current_stroke. static void init_stroke_layers() { StrokeData *stroke_data = &s_stroke_datas[i_current_stroke]; text_layer_destroy(intro_up_help); text_layer_destroy(intro_select_help); text_layer_destroy(intro_down_help); stroke_image_layer = bitmap_layer_create(GRect(0, 10, 120, 50)); stroke_name_layer = text_layer_create(GRect(0, 65, 120, 30)); stroke_count_layer = text_layer_create(GRect(0, 105, 120, 30)); bitmap_layer_set_bitmap(stroke_image_layer, stroke_data->bitmap); bitmap_layer_set_alignment(stroke_image_layer, GAlignCenter); text_layer_set_text_alignment(stroke_name_layer, GTextAlignmentCenter); text_layer_set_font(stroke_name_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(stroke_count_layer, GTextAlignmentCenter); text_layer_set_font(stroke_count_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK)); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(stroke_image_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(stroke_name_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(stroke_count_layer)); }
/* Create the QTPlus Window and initialize the layres */ void qtp_init() { qtp_window = window_create(); /* Time Layer */ #ifdef QTP_K_SHOW_TIME GRect time_frame = GRect( QTP_PADDING_X, QTP_PADDING_Y, QTP_SCREEN_WIDTH - QTP_PADDING_X, QTP_TIME_HEIGHT ); qtp_time_layer = text_layer_create(time_frame); qtp_update_time(false); text_layer_set_text_alignment(qtp_time_layer, GTextAlignmentCenter); text_layer_set_font(qtp_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); layer_add_child(window_get_root_layer(qtp_window), text_layer_get_layer(qtp_time_layer)); #endif /* Setup weather if it is enabled */ #ifdef QTP_K_SHOW_WEATHER /* Weather description layer */ GRect desc_frame = GRect( QTP_PADDING_X + QTP_WEATHER_SIZE + 5, qtp_weather_y() + QTP_WEATHER_SIZE, QTP_SCREEN_WIDTH - QTP_PADDING_X, QTP_WEATHER_SIZE); qtp_weather_desc_layer = text_layer_create(desc_frame); text_layer_set_font(qtp_weather_desc_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(qtp_weather_desc_layer, GTextAlignmentLeft); const Tuple *desc_tuple = app_sync_get(&qtp_sync, QTP_WEATHER_DESC_KEY); if (desc_tuple != NULL) { text_layer_set_text(qtp_weather_desc_layer, desc_tuple->value->cstring); } layer_add_child(window_get_root_layer(qtp_window), text_layer_get_layer(qtp_weather_desc_layer)); /* Temperature description layer */ GRect temp_frame = GRect( QTP_PADDING_X + QTP_WEATHER_SIZE + 5, qtp_weather_y(), QTP_SCREEN_WIDTH, QTP_WEATHER_SIZE); qtp_temp_layer = text_layer_create(temp_frame); text_layer_set_text_alignment(qtp_temp_layer, GTextAlignmentLeft); const Tuple *temp_tuple; #ifdef QTP_K_DEGREES_F temp_tuple = app_sync_get(&qtp_sync, QTP_WEATHER_TEMP_F_KEY); #else temp_tuple = app_sync_get(&qtp_sync, QTP_WEATHER_TEMP_C_KEY); #endif /* QTP_K_DEGREES_F */ if (temp_tuple != NULL) { text_layer_set_text(qtp_temp_layer, temp_tuple->value->cstring); } text_layer_set_font(qtp_temp_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); layer_add_child(window_get_root_layer(qtp_window), text_layer_get_layer(qtp_temp_layer)); /* Weather icon layer */ GRect weather_icon_frame = GRect( QTP_PADDING_X, qtp_weather_y(), QTP_WEATHER_SIZE, QTP_WEATHER_SIZE ); qtp_weather_icon_layer = bitmap_layer_create(weather_icon_frame); bitmap_layer_set_alignment(qtp_weather_icon_layer, GAlignCenter); const Tuple *icon_tuple = app_sync_get(&qtp_sync, QTP_WEATHER_ICON_KEY); qtp_update_weather_icon(icon_tuple->value->uint8, false, false); layer_add_child(window_get_root_layer(qtp_window), bitmap_layer_get_layer(qtp_weather_icon_layer)); #endif /* QTP_K_SHOW_WEATHER */ /* Battery Logo layer */ GRect battery_logo_frame = GRect( QTP_PADDING_X, qtp_battery_y(), QTP_BAT_ICON_SIZE, QTP_BAT_ICON_SIZE ); qtp_battery_image_layer = bitmap_layer_create(battery_logo_frame); bitmap_layer_set_bitmap(qtp_battery_image_layer, qtp_battery_image); bitmap_layer_set_alignment(qtp_battery_image_layer, GAlignCenter); layer_add_child(window_get_root_layer(qtp_window), bitmap_layer_get_layer(qtp_battery_image_layer)); /* Battery Status text layer */ GRect battery_frame = GRect( 40, qtp_battery_y(), QTP_SCREEN_WIDTH - QTP_BAT_ICON_SIZE, QTP_BAT_ICON_SIZE ); qtp_battery_text_layer = text_layer_create(battery_frame); text_layer_set_font(qtp_battery_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); qtp_update_battery_status(false); layer_add_child(window_get_root_layer(qtp_window), text_layer_get_layer(qtp_battery_text_layer)); /* Bluetooth Logo layer */ GRect bluetooth_logo_frame = GRect(QTP_PADDING_X, qtp_bluetooth_y(), QTP_BT_ICON_SIZE, QTP_BT_ICON_SIZE); qtp_bluetooth_image_layer = bitmap_layer_create(bluetooth_logo_frame); bitmap_layer_set_bitmap(qtp_bluetooth_image_layer, qtp_bluetooth_image); bitmap_layer_set_alignment(qtp_bluetooth_image_layer, GAlignCenter); layer_add_child(window_get_root_layer(qtp_window), bitmap_layer_get_layer(qtp_bluetooth_image_layer)); /* Bluetooth Status text layer */ GRect bluetooth_frame = GRect(40,qtp_bluetooth_y(), QTP_SCREEN_WIDTH - QTP_BT_ICON_SIZE, QTP_BT_ICON_SIZE); qtp_bluetooth_text_layer = text_layer_create(bluetooth_frame); text_layer_set_font(qtp_bluetooth_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); qtp_update_bluetooth_status(false); layer_add_child(window_get_root_layer(qtp_window), text_layer_get_layer(qtp_bluetooth_text_layer)); /* Invert the screen */ #ifdef QTP_K_INVERT GRect inverter_frame = GRect(0,0, QTP_SCREEN_WIDTH, QTP_SCREEN_HEIGHT); qtp_inverter_layer = inverter_layer_create(inverter_frame); layer_add_child(window_get_root_layer(qtp_window), inverter_layer_get_layer(qtp_inverter_layer)); #endif /* Register for back button */ //window_set_click_config_provider(qtp_window, (ClickConfigProvider)qtp_click_config_provider); }
static void main_window_load(Window *window) { GRect bounds = layer_get_bounds(window_get_root_layer(window)); action_bar = action_bar_layer_create(); action_bar_layer_set_click_config_provider(action_bar, click_config_provider); #ifdef PBL_COLOR action_bar_layer_set_icon_animated(action_bar,BUTTON_ID_UP,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_CROSS_INV),true); action_bar_layer_set_icon_animated(action_bar,BUTTON_ID_DOWN,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_ZZ_INV),true); #else action_bar_layer_set_icon(action_bar,BUTTON_ID_UP,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_CROSS)); action_bar_layer_set_icon(action_bar,BUTTON_ID_DOWN,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_ZZ)); #endif action_bar_layer_add_to_window(action_bar,window); // Create output TextLayer s_output_layer = text_layer_create(GRect(0, bounds.size.h/2-21-(clock_is_24h_style()?0:21), bounds.size.w-ACTION_BAR_WIDTH, bounds.size.h)); text_layer_set_text_alignment(s_output_layer, GTextAlignmentCenter); text_layer_set_font(s_output_layer,fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); //snprintf(output_text, sizeof(output_text), "00:00"); text_layer_set_text(s_output_layer, output_text); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_output_layer)); //snprintf(output_text, sizeof(output_text), "00:00"); if(alarm_has_description(s_alarm)) { // Create Description s_description_layer = text_layer_create(GRect(0, 6, bounds.size.w-ACTION_BAR_WIDTH, 36)); text_layer_set_text_alignment(s_description_layer, GTextAlignmentCenter); text_layer_set_font(s_description_layer,fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text(s_description_layer, s_alarm->description); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_description_layer)); } else { // Create Bitmap s_bitmap_layer = bitmap_layer_create(GRect(0,10,bounds.size.w-ACTION_BAR_WIDTH, bounds.size.h)); s_logo = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_LOGO); bitmap_layer_set_bitmap(s_bitmap_layer,s_logo); bitmap_layer_set_alignment(s_bitmap_layer,GAlignTop); layer_add_child(window_get_root_layer(window),bitmap_layer_get_layer(s_bitmap_layer)); } #ifdef PBL_SDK_2 s_inverter_layer = inverter_layer_create(GRect(0,0,bounds.size.w,bounds.size.h)); layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(s_inverter_layer)); #endif s_vibration_pattern = load_persistent_storage_int(VIBRATION_PATTERN_KEY,0); s_vibration_duration = load_persistent_storage_int(VIBRATION_DURATION_KEY, 2); s_auto_snooze = load_persistent_storage_bool(AUTO_SNOOZE_KEY, true); do_vibrate(); // switch off vibration after x minutes switch (s_vibration_duration) { case 0: s_vibration_duration = 30; break; case 1: s_vibration_duration = 60; break; case 2: s_vibration_duration = 120; break; case 3: s_vibration_duration = 300; break; default: break; } cancel_vibe_timer = app_timer_register(1000*s_vibration_duration,cancel_vibe_timer_callback,NULL); // test snoozing with the accelerometer /*if(s_flip_to_snooze) { accel_tap_service_subscribe(&accel_tap_handler); }*/ }
void handle_init(void) { my_window = window_create(); text = text_layer_create(GRect(84, 52, 53, 18)); text_layer_set_text_alignment(text, GTextAlignmentCenter); //Setting the GBitmaps to their resources def = gbitmap_create_with_resource(RESOURCE_ID_def); staged = gbitmap_create_with_resource(RESOURCE_ID_staged); bulb1 = gbitmap_create_with_resource(RESOURCE_ID_bulb); bulb2 = gbitmap_create_with_resource(RESOURCE_ID_bulb); bulb3 = gbitmap_create_with_resource(RESOURCE_ID_bulb); green = gbitmap_create_with_resource(RESOURCE_ID_bulb); //Setting the bitmap layers to the variables def_layer = bitmap_layer_create(GRect(0, 0, 144, 154)); staged_layer = bitmap_layer_create(GRect(0, 0, 144, 154)); bulb1_layer = bitmap_layer_create(GRect(-25, -21, 144, 154)); bulb2_layer = bitmap_layer_create(GRect(-25, 5, 144, 154)); bulb3_layer = bitmap_layer_create(GRect(-25, 31, 144, 154)); green_layer = bitmap_layer_create(GRect(-25, 56, 144, 154)); //Linking the GBitmaps(the pictures) to their physical layers bitmap_layer_set_bitmap(def_layer, def); bitmap_layer_set_bitmap(staged_layer, staged); bitmap_layer_set_bitmap(bulb1_layer, bulb1); bitmap_layer_set_bitmap(bulb2_layer, bulb2); bitmap_layer_set_bitmap(bulb3_layer, bulb3); bitmap_layer_set_bitmap(green_layer, green); //Setting the allignment of the bitmap layers bitmap_layer_set_alignment(def_layer, GAlignBottom); bitmap_layer_set_alignment(staged_layer, GAlignBottom); bitmap_layer_set_alignment(bulb1_layer, GAlignCenter); bitmap_layer_set_alignment(bulb2_layer, GAlignCenter); bitmap_layer_set_alignment(bulb3_layer, GAlignCenter); bitmap_layer_set_alignment(green_layer, GAlignCenter); //Pasting the def bitmap and the text layer onto the window layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(def_layer)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(text)); //Puts all the bulbs on the screen, and then hides them layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(staged_layer)); layer_set_hidden(bitmap_layer_get_layer(staged_layer), true); layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(bulb1_layer)); layer_set_hidden(bitmap_layer_get_layer(bulb1_layer), true); layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(bulb2_layer)); layer_set_hidden(bitmap_layer_get_layer(bulb2_layer), true); layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(bulb3_layer)); layer_set_hidden(bitmap_layer_get_layer(bulb3_layer), true); layer_add_child(window_get_root_layer(my_window), bitmap_layer_get_layer(green_layer)); layer_set_hidden(bitmap_layer_get_layer(green_layer), true); //Checks if the ROLLOUT_KEY value exists; if it does, then the rollout is set to whatever the value is; if it doesn't, then the rollout is set to the ROLLOUT_KEY_DEFAULT value rollout = persist_exists(ROLLOUT_KEY) ? persist_read_int(ROLLOUT_KEY) : ROLLOUT_KEY_DEFAULT; window_set_click_config_provider(my_window, click_config); //Pushes the window to the screen window_stack_push(my_window, true); }
void init() { big_bold_font = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK); med_bold_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); small_bold_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); conditions[WEATHER_UNKNOWN] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_UNKNOWN); conditions[WEATHER_CLEAR_DAY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLEAR_DAY); conditions[WEATHER_CLEAR_NIGHT] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLEAR_NIGHT); conditions[WEATHER_RAIN] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_RAIN); conditions[WEATHER_SNOW] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_SNOW); // conditions[WEATHER_SLEET] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_SLEET); conditions[WEATHER_WIND] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_WIND); conditions[WEATHER_FOG] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_FOG); conditions[WEATHER_CLOUDY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLOUDY); conditions[WEATHER_PARTLY_CLOUDY_DAY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_PARTLY_CLOUDY_DAY); conditions[WEATHER_PARTLY_CLOUDY_NIGHT] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_PARTLY_CLOUDY_NIGHT); // Set up main window mainwindow = window_create(); window_set_background_color(mainwindow, GColorBlack); window_set_fullscreen(mainwindow, true); for ( int i = 0; i < MAX_WATCH_FACES; i++) { // This layer displays the time. 12-hour, 24-hour or how the watch is configured watchfaces[i].main_time_layer = text_layer_create(GRect(0, i*56, 144, 32)); text_layer_set_text(watchfaces[i].main_time_layer, watchfaces[i].time_text); text_layer_set_text_color(watchfaces[i].main_time_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].main_time_layer, GColorClear); text_layer_set_font(watchfaces[i].main_time_layer, big_bold_font); text_layer_set_text_alignment(watchfaces[i].main_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(mainwindow), (Layer *)watchfaces[i].main_time_layer); // This layer displays the selected time zone city, including GMT offset watchfaces[i].main_city_layer = text_layer_create(GRect(0, (i*56)+32, 144, 24)); text_layer_set_text_color(watchfaces[i].main_city_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].main_city_layer, GColorClear); text_layer_set_font(watchfaces[i].main_city_layer, small_bold_font); text_layer_set_text_alignment(watchfaces[i].main_city_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(mainwindow), (Layer *)watchfaces[i].main_city_layer); watchfaces[i].window = window_create(); window_set_background_color(watchfaces[i].window, GColorBlack); window_set_fullscreen(watchfaces[i].window, true); window_set_click_config_provider(watchfaces[i].window, (ClickConfigProvider) watchface_click_config_provider); // This layer displays the time. 12-hour, 24-hour or how the watch is configured watchfaces[i].text_time_layer = text_layer_create(GRect(0, 6, 144, 44)); text_layer_set_text(watchfaces[i].text_time_layer, watchfaces[i].time_text); text_layer_set_text_color(watchfaces[i].text_time_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].text_time_layer, GColorClear); text_layer_set_font(watchfaces[i].text_time_layer, big_bold_font); text_layer_set_text_alignment(watchfaces[i].text_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_time_layer); // This layer displays the date watchfaces[i].text_date_layer = text_layer_create(GRect(0, 44, 144, 28)); text_layer_set_text(watchfaces[i].text_date_layer, watchfaces[i].date_text); text_layer_set_text_color(watchfaces[i].text_date_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].text_date_layer, GColorClear); text_layer_set_font(watchfaces[i].text_date_layer, med_bold_font); text_layer_set_text_alignment(watchfaces[i].text_date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_date_layer); // This layer displays the selected time zone city, including GMT offset watchfaces[i].text_city_layer = text_layer_create(GRect(0, 72, 146, 22)); text_layer_set_text_color(watchfaces[i].text_city_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].text_city_layer, GColorClear); text_layer_set_font(watchfaces[i].text_city_layer, small_bold_font); text_layer_set_text_alignment(watchfaces[i].text_city_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_city_layer); for ( int j = 0; j < MAX_WEATHER_DAYS; j++ ) { // This layer displays a weather image, if available. watchfaces[i].bitmap_weather_layer[j] = bitmap_layer_create(GRect(9+(j*(36+9)), 94, 36, 36)); bitmap_layer_set_background_color(watchfaces[i].bitmap_weather_layer[j], GColorClear); bitmap_layer_set_alignment(watchfaces[i].bitmap_weather_layer[j], GAlignCenter); bitmap_layer_set_compositing_mode(watchfaces[i].bitmap_weather_layer[j], GCompOpAssignInverted); bitmap_layer_set_bitmap(watchfaces[i].bitmap_weather_layer[j], conditions[WEATHER_UNKNOWN]); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].bitmap_weather_layer[j]); // This layer displays the time zone temperature, high and low, below the weather icon watchfaces[i].text_temp_layer[j] = text_layer_create(GRect(9+(j*(36+9)), 130, 36, 38)); text_layer_set_text(watchfaces[i].text_temp_layer[j], watchfaces[i].temps[j]); text_layer_set_text_color(watchfaces[i].text_temp_layer[j], GColorWhite); text_layer_set_background_color(watchfaces[i].text_temp_layer[j], GColorClear); text_layer_set_font(watchfaces[i].text_temp_layer[j], small_bold_font); text_layer_set_text_alignment(watchfaces[i].text_temp_layer[j], GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_temp_layer[j]); } } Tuplet initial_values[] = { TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) -28800), TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY, (uint8_t) BACKGROUND_SUNS), TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY, (uint8_t) DISPLAY_WATCH_CONFIG_TIME), TupletCString(LOCAL_WATCH_OFFSET+PBCOMM_CITY_KEY, "Watch Time"), TupletBytes( LOCAL_WATCH_OFFSET+PBCOMM_WEATHER_KEY, weather, WEATHER_KEY_LEN), TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) 0), TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY, (uint8_t) BACKGROUND_SUNS), TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY, (uint8_t) DISPLAY_24_HOUR_TIME), TupletCString(TZ1_WATCH_OFFSET+PBCOMM_CITY_KEY, "London, England"), TupletBytes( TZ1_WATCH_OFFSET+PBCOMM_WEATHER_KEY, weather, WEATHER_KEY_LEN), TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) 32400), TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY, (uint8_t) BACKGROUND_SUNS), TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY, (uint8_t) DISPLAY_24_HOUR_TIME), TupletCString(TZ2_WATCH_OFFSET+PBCOMM_CITY_KEY, "Tokyo, Japan"), TupletBytes( TZ2_WATCH_OFFSET+PBCOMM_WEATHER_KEY, weather, WEATHER_KEY_LEN) }; // Initialize watchfaces[].time_format as it may be used before sync_tuple_changed_callback // is executed to set up the proper value. for (int i = 0; i < MAX_WATCH_FACES; i++) { strncpy (watchfaces[i].time_format, time_12h_format, sizeof(time_12h_format)); } // Initialize status window, but don't populate unless it's requested via tap statuswindow = window_create(); window_set_background_color(statuswindow, GColorBlack); window_set_window_handlers(statuswindow, (WindowHandlers) { .load = statuswindow_load, .unload = statuswindow_unload });