SimplySplash *simply_splash_create(Simply *simply) { SimplySplash *self = malloc(sizeof(*self)); *self = (SimplySplash) { .simply = simply }; self->window = window_create(); window_set_user_data(self->window, self); window_set_fullscreen(self->window, false); window_set_background_color(self->window, GColorWhite); window_set_window_handlers(self->window, (WindowHandlers) { .load = window_load, .disappear = window_disappear, });
static void init(void) { s_main_window = window_create(); window_set_background_color(s_main_window, COLOR_FALLBACK(GColorIndigo, GColorBlack)); #ifdef PBL_SDK_2 window_set_fullscreen(s_main_window, true); #endif window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload });
static void window_load(Window *window) { window_set_background_color(window, GColorBlack); //Power bitmap power_bitmap = gbitmap_create_with_resource(RESOURCE_ID_POWER); //Phase phase_layer = layer_create(GRECT_PHASE_SHOWING); layer_set_update_proc(phase_layer, (LayerUpdateProc)phase_update_proc); layer_add_child(window_get_root_layer(window), phase_layer); //Time display under background time_bg_layer = layer_create(GRECT_TIME_BG_HIDDEN); time_layer = cl_init_text_layer(GRECT_TIME_BG_HIDDEN, GColorBlack, GColorClear, false, 0, FONT_KEY_GOTHIC_24_BOLD, GTextAlignmentCenter); layer_set_update_proc(time_bg_layer, (LayerUpdateProc)bg_update_proc); layer_add_child(window_get_root_layer(window), time_bg_layer); layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer)); //Bluetooth bt_on_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BT_ON); bt_off_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BT_OFF); bt_layer = bitmap_layer_create(GRECT_BT_HIDDEN); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bt_layer)); //Battery battery_layer = layer_create(GRECT_BATTERY_HIDDEN); layer_set_update_proc(battery_layer, (LayerUpdateProc)battery_update_proc); layer_add_child(window_get_root_layer(window), battery_layer); //Background background_white_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND_WHITE); background_white_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_compositing_mode(background_white_layer, GCompOpOr); bitmap_layer_set_bitmap(background_white_layer, background_white_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(background_white_layer)); background_black_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND_BLACK); background_black_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_compositing_mode(background_black_layer, GCompOpAnd); bitmap_layer_set_bitmap(background_black_layer, background_black_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(background_black_layer)); //Date date_bg_layer = layer_create(GRECT_DATE_BG_HIDDEN); date_layer = cl_init_text_layer(GRECT_DATE_BG_HIDDEN, GColorBlack, GColorClear, false, 0, FONT_KEY_GOTHIC_24_BOLD, GTextAlignmentCenter); layer_set_update_proc(date_bg_layer, (LayerUpdateProc)bg_update_proc); layer_add_child(window_get_root_layer(window), date_bg_layer); layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer)); //Animate in cl_animate_layer(phase_layer, GRECT_PHASE_HIDDEN, GRECT_PHASE_SHOWING, 1000, 200); }
static void init() { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); // Avoids a blank screen on watch start. time_t now = time(NULL); struct tm *tick_time = localtime(&now); display_time(tick_time); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }
static void init() { // Create main Window element and assign to pointer s_main_window = window_create(); // set the window background window_set_background_color(s_main_window, GColorBlack); // Set handlers to manage the elements inside the Window window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload });
static void init(void) { Window* w; tick_timer_service_subscribe(SECOND_UNIT, handle_tick); //APP_LOG(APP_LOG_LEVEL_DEBUG, "Creating GPS window"); w = window_create(); window_set_background_color(w, GColorBlack); window_set_fullscreen(w, true); window_set_window_handlers(w, (WindowHandlers) { .load = gps_window_load, .unload = gps_window_unload });
static Window* init() { // Create main Window element and assign to pointer Window *w = window_create(); // Set Background color of window window_set_background_color(w, background_color); // Set handlers to manage the elements inside the Window window_set_window_handlers(w, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload });
static void do_init(void) { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); Layer *root_layer = window_get_root_layer(window); GRect frame = layer_get_frame(root_layer); /* Background */ Anonymous = gbitmap_create_with_resource(RESOURCE_ID_BG_ANONYMOUS); Anonymous_Layer = bitmap_layer_create(GRect(0, 0, WIDTH, HEIGHT)); bitmap_layer_set_background_color(Anonymous_Layer, GColorBlack); bitmap_layer_set_bitmap(Anonymous_Layer, Anonymous); layer_add_child(root_layer, bitmap_layer_get_layer(Anonymous_Layer)); /* Time block */ time_layer = text_layer_create(GRect(0, 52, frame.size.w, 34)); 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 )); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); /* Bluetooth block */ bt_connected = gbitmap_create_with_resource(RESOURCE_ID_BT_DISCONNECTED); bt_connected_layer = bitmap_layer_create(GRect(WIDTH - ICON_WIDTH, 1, ICON_WIDTH, ICON_HEIGHT)); bitmap_layer_set_background_color(bt_connected_layer, GColorBlack); layer_add_child(root_layer, bitmap_layer_get_layer(bt_connected_layer)); /* Battery block */ battery_layer = text_layer_create(GRect(2, -2, frame.size.w, 16 )); text_layer_set_text_color(battery_layer, GColorWhite); text_layer_set_background_color(battery_layer, GColorClear); text_layer_set_font(battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(battery_layer, GTextAlignmentLeft); text_layer_set_text(battery_layer, "100% charged"); /* Init blocks */ time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_second_tick(current_time, SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick); battery_state_service_subscribe(&handle_battery); bool connected = bluetooth_connection_service_peek(); handle_bluetooth(connected); bluetooth_connection_service_subscribe(&handle_bluetooth); layer_add_child(root_layer, text_layer_get_layer(time_layer)); layer_add_child(root_layer, text_layer_get_layer(battery_layer)); }
void app_message_received(DictionaryIterator *iter, void *context) { // Tuple *jeep_model_t = dict_find(iter, KEY_JEEP_MODEL); Tuple *display_type_t = dict_find(iter, MESSAGE_KEY_type); if(display_type_t) { // display_type = display_type_t->value->int32; switch(display_type_t->value->cstring[0]) { case 'b': display_type = 0; break; case 'd': display_type = 1; break; // case 'm': default: display_type = 2; break; } persist_write_int(MESSAGE_KEY_type, display_type); } Tuple *show_seconds_t = dict_find(iter, MESSAGE_KEY_seconds); if(show_seconds_t) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Seconds setting received as: %d", show_seconds_t->value->int32); show_seconds = show_seconds_t->value->int32 == 1; persist_write_bool(MESSAGE_KEY_seconds,show_seconds); } Tuple *jeep_color_t = dict_find(iter, MESSAGE_KEY_jeepColor); if(jeep_color_t) { int jeep_color_i = jeep_color_t->value->int32; persist_write_int(MESSAGE_KEY_jeepColor, jeep_color_i); jeep_color = GColorFromHEX(jeep_color_i); } Tuple *time_color_t = dict_find(iter, MESSAGE_KEY_timeColor); if(time_color_t) { int time_color_i = time_color_t->value->int32; persist_write_int(MESSAGE_KEY_timeColor, time_color_i); time_color = GColorFromHEX(time_color_i); } Tuple *background_color_t = dict_find(iter, MESSAGE_KEY_bgColor); if(background_color_t) { int background_color_i = background_color_t->value->int32; persist_write_int(MESSAGE_KEY_bgColor, background_color_i); background_color = GColorFromHEX(background_color_i); window_set_background_color(main_window,background_color); } watchface_load(main_window); }
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); }
static void initialise_ui(void) { s_window = window_create(); Layer *root_layer = window_get_root_layer(s_window); GRect bounds = layer_get_bounds(root_layer); window_set_background_color(s_window, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack)); IF_2(window_set_fullscreen(s_window, false)); #ifdef PBL_ROUND int dev_layer_left = (bounds.size.w - DEV_LAYER_WIDTH)/2; int dev_layer_top = (bounds.size.h - DEV_LAYER_HEIGHT)/2; #else int dev_layer_left = ((bounds.size.w - DEV_LAYER_WIDTH - ACTION_BAR_WIDTH)/2) + 4; int dev_layer_top = ((bounds.size.h - DEV_LAYER_HEIGHT - 14)/2) + IF_32(14, 0); #endif s_rect_above = GRect(dev_layer_left, -(DEV_LAYER_HEIGHT+2), DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT); s_rect_onscreen = GRect(dev_layer_left, dev_layer_top, DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT); s_rect_below = GRect(dev_layer_left, bounds.size.h+2, DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT); // s_devicecard_layer s_devicecard_layer = devicecard_layer_create(s_rect_onscreen); layer_add_child(root_layer, s_devicecard_layer->layer); // s_layer_spots s_layer_spots = layer_create(PBL_IF_RECT_ELSE(GRect((dev_layer_left/2)-SPOT_RADIUS, dev_layer_top, (SPOT_RADIUS*2)+1 , DEV_LAYER_HEIGHT), bounds)); layer_add_child(root_layer, (Layer *)s_layer_spots); #ifndef PBL_SDK_2 s_status_bar = status_bar_layer_create(); status_bar_layer_set_colors(s_status_bar, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack), GColorWhite); layer_add_child(root_layer, status_bar_layer_get_layer(s_status_bar)); #endif s_res_image_action_up = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_UP); s_res_image_action_set = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_SET); s_res_image_action_down = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_DOWN); // s_actionbar_main s_actionbar_main = action_bar_layer_create(); action_bar_layer_add_to_window(s_actionbar_main, s_window); action_bar_layer_set_background_color(s_actionbar_main, GColorWhite); action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_UP, s_res_image_action_up); action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_SELECT, s_res_image_action_set); action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_DOWN, s_res_image_action_down); #ifdef PBL_RECT layer_set_frame(action_bar_layer_get_layer(s_actionbar_main), GRect(bounds.size.w-20, 0, 20, bounds.size.h)); IF_3(layer_set_bounds(action_bar_layer_get_layer(s_actionbar_main), GRect(-5, 0, 30, bounds.size.h))); #endif layer_add_child(root_layer, (Layer *)s_actionbar_main); }
static void init(void) { // Create the main window s_main_window = window_create(); // set the background colour window_set_background_color(s_main_window, GColorBlack); // set the window load and unload handlers window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload, });
void error_window_init(void) { error_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ERROR); window = window_create(); window_set_background_color(window, GColorBlack); window_set_click_config_provider(window, window_click_config_provider); window_set_fullscreen(window, true); static const WindowHandlers window_handlers = { .load = window_load, }; window_set_window_handlers(window, window_handlers); }
static void initialise_ui(void) { s_window = window_create(); window_set_background_color(s_window, GColorBlack); window_set_fullscreen(s_window, true); // s_textlayer_1 s_textlayer_1 = text_layer_create(GRect(0, 70, 144, 20)); text_layer_set_background_color(s_textlayer_1, GColorClear); text_layer_set_text_color(s_textlayer_1, GColorWhite); text_layer_set_text(s_textlayer_1, "Loading..."); text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter); layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1); }
void init(void) { window = window_create(); window_set_background_color(window, GColorBlack); window_stack_push(window, true); // Register AppMessage handlers app_message_register_inbox_received(in_received_handler); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); text_layer = text_layer_create((GRect) { .origin = { 0, 50 }, .size = { bounds.size.w, 60 } });
void pge_begin(GColor window_color, PGELogicHandler *logic_handler, PGERenderHandler *render_handler, PGEClickHandler *click_handler) { s_logic_handler = logic_handler; s_render_handler = render_handler; s_game_window = window_create(); #ifdef PBL_SDK_2 window_set_fullscreen(s_game_window, true); #endif window_set_background_color(s_game_window, window_color); window_set_window_handlers(s_game_window, (WindowHandlers) { .load = game_window_load, .unload = game_window_unload });
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "VeryPlain"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); initLayerPathAndCenter(&hour_display_layer, &hour_hand_path, &HOUR_HAND_PATH_POINTS, &hour_display_layer_update_callback); initLayerPathAndCenter(&minute_display_layer, &minute_hand_path, &MINUTE_HAND_PATH_POINTS, &minute_display_layer_update_callback); //initLayerPathAndCenter(&second_display_layer, &second_hand_path, &SECOND_HAND_PATH_POINTS, &second_display_layer_update_callback); }
static void menu_statistics_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect window_bounds = layer_get_bounds(window_layer); window_set_background_color(s_statistics_window, GColorPurple); s_statistics_layer = text_layer_create(GRect(5, 0, window_bounds.size.w - 5, window_bounds.size.h)); text_layer_set_font(s_statistics_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_background_color(s_statistics_layer, GColorClear); text_layer_set_text(s_statistics_layer, "THIS IS THE STATS"); text_layer_set_text_alignment(s_statistics_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft)); layer_add_child(window_layer, text_layer_get_layer(s_statistics_layer)); }
// -------------------------------------------------------- // menu_timer_init() // // called by TempusFugit.c to initialize menu data // -------------------------------------------------------- void menu_timer_init() { // ------------------------------- // init window handlers // ------------------------------- window_init(&menu_timer_window, "Timer Menu"); window_set_background_color(&menu_timer_window, GColorWhite); window_set_window_handlers(&menu_timer_window, (WindowHandlers) { .appear = (WindowHandler)handle_appear, .disappear = (WindowHandler)handle_disappear, .load = handle_load, .unload = handle_unload, });
static void init_window(void) { // Init Main Window window = window_create(); window_set_background_color(window, GColorBlack); window_set_fullscreen(window, true); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .appear = window_appear, .unload = window_unload });
static void window_load(Window *window) { //Setup window window_set_background_color(window, GColorBlack); //Setup canvas canvas = layer_create(GRect(0, 0, 144, 168)); layer_set_update_proc(canvas, (LayerUpdateProc) render); layer_add_child(window_get_root_layer(window), canvas); //Start rendering start(); }
static void inbox_received_handler(DictionaryIterator *iter, void *context) { // High contrast selected? Tuple *high_contrast_t = dict_find(iter, KEY_HIGH_CONTRAST); if(high_contrast_t && high_contrast_t->value->int32 > 0) { // Change color scheme window_set_background_color(s_main_window, GColorBlack); text_layer_set_text_color(s_text_layer, GColorWhite); // Persist value persist_write_bool(KEY_HIGH_CONTRAST, true); } else { persist_write_bool(KEY_HIGH_CONTRAST, false); } // Color scheme? Tuple *color_red_t = dict_find(iter, KEY_COLOR_RED); Tuple *color_green_t = dict_find(iter, KEY_COLOR_GREEN); Tuple *color_blue_t = dict_find(iter, KEY_COLOR_BLUE); if(color_red_t && color_green_t && color_blue_t) { // Apply the color if available #ifdef PBL_SDK_2 window_set_background_color(s_main_window, GColorWhite); text_layer_set_text_color(s_text_layer, GColorBlack); #elif PBL_SDK_3 int red = color_red_t->value->int32; int green = color_green_t->value->int32; int blue = color_blue_t->value->int32; // Persist values persist_write_int(KEY_COLOR_RED, red); persist_write_int(KEY_COLOR_GREEN, green); persist_write_int(KEY_COLOR_BLUE, blue); GColor bg_color = GColorFromRGB(red, green, blue); window_set_background_color(s_main_window, bg_color); text_layer_set_text_color(s_text_layer, gcolor_is_dark(bg_color) ? GColorWhite : GColorBlack); #endif } }
void handle_init(void) { window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); Layer *window_layer = window_get_root_layer(window); // Set up AppMessage to receive timezone offset app_message_register_inbox_received(in_received_handler); app_message_open(64, 64); dolce_vita_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GEOSANS_LIGHT_26)); // Current Time text_time_layer = text_layer_create(GRect(0, 114, 144, 43)); 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_MEDIUM_NUMBERS)); text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); // Apple Logo logo_image = gbitmap_create_with_resource(RESOURCE_ID_WWDC14); logo_image_layer = bitmap_layer_create(GRect(0, 0, 144, 60)); bitmap_layer_set_bitmap(logo_image_layer, logo_image); layer_add_child(window_layer, bitmap_layer_get_layer(logo_image_layer)); // WWDC14 Text text_image = gbitmap_create_with_resource(RESOURCE_ID_WWDC14TEXT); text_image_layer = bitmap_layer_create(GRect(0, 60, 144, 30)); bitmap_layer_set_bitmap(text_image_layer, text_image); layer_add_child(window_layer, bitmap_layer_get_layer(text_image_layer)); // Countdown text_countdown_layer = text_layer_create(GRect(0, 88, 144, 33)); text_layer_set_text_color(text_countdown_layer, GColorWhite); text_layer_set_background_color(text_countdown_layer, GColorBlack); text_layer_set_font(text_countdown_layer, dolce_vita_font); text_layer_set_text_alignment(text_countdown_layer, GTextAlignmentCenter); text_layer_set_background_color(text_countdown_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(text_countdown_layer)); tim_cook_image = gbitmap_create_with_resource(RESOURCE_ID_TIMCOOK); tim_cook_image_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(tim_cook_image_layer, tim_cook_image); layer_add_child(window_layer, bitmap_layer_get_layer(tim_cook_image_layer)); layer_set_hidden(bitmap_layer_get_layer(tim_cook_image_layer), true); tick_timer_service_subscribe(SECOND_UNIT, handle_second_tick); accel_tap_service_subscribe(&acceleration_tap_handler); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); s_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CONFIRM); const GEdgeInsets icon_insets = {.top = 7, .right = 28, .bottom = 56, .left = 14}; s_icon_layer = bitmap_layer_create(grect_inset(bounds, icon_insets)); bitmap_layer_set_bitmap(s_icon_layer, s_icon_bitmap); bitmap_layer_set_compositing_mode(s_icon_layer, GCompOpSet); layer_add_child(window_layer, bitmap_layer_get_layer(s_icon_layer)); const GEdgeInsets label_insets = {.top = 112, .right = ACTION_BAR_WIDTH, .left = ACTION_BAR_WIDTH / 2}; s_label_layer = text_layer_create(grect_inset(bounds, label_insets)); text_layer_set_text(s_label_layer, DIALOG_CHOICE_WINDOW_MESSAGE); text_layer_set_background_color(s_label_layer, GColorClear); text_layer_set_text_alignment(s_label_layer, GTextAlignmentCenter); text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); layer_add_child(window_layer, text_layer_get_layer(s_label_layer)); s_tick_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TICK); s_cross_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CROSS); s_action_bar_layer = action_bar_layer_create(); action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_UP, s_tick_bitmap); action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_DOWN, s_cross_bitmap); action_bar_layer_add_to_window(s_action_bar_layer, window); } static void window_unload(Window *window) { text_layer_destroy(s_label_layer); action_bar_layer_destroy(s_action_bar_layer); bitmap_layer_destroy(s_icon_layer); gbitmap_destroy(s_icon_bitmap); gbitmap_destroy(s_tick_bitmap); gbitmap_destroy(s_cross_bitmap); window_destroy(window); s_main_window = NULL; } void dialog_choice_window_push() { if(!s_main_window) { s_main_window = window_create(); window_set_background_color(s_main_window, PBL_IF_COLOR_ELSE(GColorJaegerGreen, GColorWhite)); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); }
void init(void) { // Create Window s_main_window = window_create(); #ifdef PBL_COLOR window_set_background_color(s_main_window, GColorPictonBlue); #else window_set_background_color(s_main_window, GColorWhite); #endif // Create text layer #if defined(PBL_RECT) s_text_layer = text_layer_create(GRect(0, 63, 144, 35)); #elif defined(PBL_ROUND) s_text_layer = text_layer_create(GRect(0, 70, 180, 35)); #endif text_layer_set_background_color(s_text_layer, GColorClear); #ifdef PBL_COLOR text_layer_set_text_color(s_text_layer, GColorWhite); #else text_layer_set_text_color(s_text_layer, GColorBlack); #endif text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter); text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); text_layer_set_text(s_text_layer, "Connecting"); layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(s_text_layer)); // Show the Window on the watch, with animated=true window_stack_push(s_main_window, true); // Register callbacks app_message_register_inbox_received(inbox_received_callback); app_message_register_inbox_dropped(inbox_dropped_callback); app_message_register_outbox_failed(outbox_failed_callback); app_message_register_outbox_sent(outbox_sent_callback); // Open AppMessage app_message_open(200, 0); }
static void init() { // Load the custom font s_font36 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_XFILES_TYPE_46)); s_font18 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_XFILES_TYPE_18)); // Create main Window element and assign to pointer s_main_window = window_create(); window_set_background_color(s_main_window, GColorBlack); // Set handlers to manage the elements inside the Window window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload });
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); GFont font = fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD); Layer *root_layer = window_get_root_layer(s_data.window); GRect frame = layer_get_frame(root_layer); s_data.label = text_layer_create(GRect(0, 0, frame.size.w, frame.size.h)); text_layer_set_background_color(s_data.label, GColorBlack); text_layer_set_text_color(s_data.label, GColorWhite); text_layer_set_font(s_data.label, font); text_layer_set_text_alignment(s_data.label, GTextAlignmentLeft); layer_add_child(root_layer, text_layer_get_layer(s_data.label)); time_t now = time(NULL); struct tm *t = localtime(&now); update_time(t); tick_timer_service_subscribe(SECOND_UNIT, &handle_minute_tick); bluetoothstatus_layer = text_layer_create(GRect(0, 100, frame.size.w, frame.size.h)); text_layer_set_text_color(bluetoothstatus_layer, GColorWhite); text_layer_set_background_color(bluetoothstatus_layer, GColorBlack); text_layer_set_font(bluetoothstatus_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(bluetoothstatus_layer, GTextAlignmentCenter); layer_add_child(root_layer, text_layer_get_layer(bluetoothstatus_layer)); bluetooth_connection_service_subscribe(bluetooth_connection_callback); update_bluetooth(bluetooth_connection_service_peek()); batterystatus_layer = text_layer_create(GRect(0, 120, frame.size.w, frame.size.h)); text_layer_set_text_color(batterystatus_layer, GColorWhite); text_layer_set_background_color(batterystatus_layer, GColorBlack); text_layer_set_font(batterystatus_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(batterystatus_layer, GTextAlignmentCenter); layer_add_child(root_layer, text_layer_get_layer(batterystatus_layer)); BatteryChargeState pb_bat = battery_state_service_peek(); pebble_batteryPercent = pb_bat.charge_percent; battery_state_service_subscribe(pebble_battery_callback); update_pebble_battery(battery_state_service_peek()); icon_bt_on = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BT_ON_ICON ); }
// -------------------------------------------------------- // menu_program_init() // // called by TempusFugit.c to initialize menu data // -------------------------------------------------------- void menu_program_init() { // ------------------------------- // init window handlers // ------------------------------- window_init(&menu_program_window, "Tempus Fugit"); window_set_background_color(&menu_program_window, GColorWhite); window_set_window_handlers(&menu_program_window, (WindowHandlers) { .appear = (WindowHandler)menu_program_appear, .disappear = (WindowHandler)menu_program_disappear, .load = menu_program_load, .unload = menu_program_unload, });
void set_window_test_animation(void) { window_set_background_color(g_windows[WINDOW_ANIMATION], GColorBlack); // Create GBitmap, then set to created BitmapLayer /* s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_FOOD_0); 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(g_windows[WINDOW_ANIMATION]), bitmap_layer_get_layer(s_background_layer)); initAni(); Food *food = (Food*)malloc(sizeof(Food)); food_init(food,true); */ }
static void set_colors() { text_layer_set_text(s_cond_layer, s_cond); window_set_background_color(s_main_window, COLOR_FALLBACK(bg, bwbg)); set_all_text_layer(text); for(int i = 1; i <= ppl_total; i++){ if (strcmp(s_ppl[i], "0")==0){ text_layer_set_background_color(sa_name_layer[i], COLOR_FALLBACK(bg, GColorWhite)); text_layer_set_text_color(sa_name_layer[i], text); } else { text_layer_set_background_color(sa_name_layer[i], COLOR_FALLBACK(text, bwbg)); text_layer_set_text_color(sa_name_layer[i], bg); } } }