static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); // Background image s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND); s_background_layer = bitmap_layer_create(layer_get_bounds(window_layer)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); // Month and day s_date_layer = text_layer_create(GRect(0, 96, 144, 168-95)); #ifdef PBL_COLOR text_layer_set_text_color(s_date_layer, GColorDarkCandyAppleRed); #else text_layer_set_text_color(s_date_layer, GColorBlack); #endif text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_date_layer)); // The time s_time_layer = text_layer_create(GRect(0, 66, 144, 168-66)); #ifdef PBL_COLOR text_layer_set_text_color(s_time_layer, GColorDarkCandyAppleRed); #else text_layer_set_text_color(s_time_layer, GColorBlack); #endif text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); }
static void main_window_load(Window *window) { //Create GBitmap, then set to created BitmapLayer s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PIRATES); 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 time TextLayer s_time_layer = text_layer_create(GRect(5, 50, 139, 58)); 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"); //Create GFont s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_LEFTY_48)); //Apply to TextLayer text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); // 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)); // Make sure the time is displayed from the start update_time(); }
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); }
static void init(void) { memset(&time_digits_layers, 0, sizeof(time_digits_layers)); memset(&time_digits_images, 0, sizeof(time_digits_images)); const int inbound_size = 64; const int outbound_size = 64; app_message_open(inbound_size, outbound_size); window = window_create(); if (window == NULL) { return; } window_set_background_color(window, GColorBlack); canvas = layer_create(GRect(0, 0, 144, 168)); layer_set_update_proc(canvas, (LayerUpdateProc) render); layer_add_child(window_get_root_layer(window), canvas); window_stack_push(window, true); Layer *window_layer = window_get_root_layer(window); load_settings(); // Open AppMessage connection app_message_register_inbox_received(inbox_received_handler); app_message_open(128, 128); //owm_weather_init(5ba77aab84470992ddc7e49e4985aeab); //events_app_message_open(); //owm_weather_fetch(); handle_weather(); handle_battery(battery_state_service_peek()); battery_state_service_subscribe(handle_battery); // Create time and date layers GRect dummy_frame = { {0, 0}, {0, 0} }; for (int i = 0; i < TOTAL_TIME_DIGITS; i++) { time_digits_layers[i] = bitmap_layer_create(dummy_frame); layer_add_child(window_layer, bitmap_layer_get_layer(time_digits_layers[i])); } mFont = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_20)); mDayText = malloc(mDayTextSize); mWeatherText = malloc(mWeatherTextSize); mBatteryText = malloc(mBatteryTextSize); // Avoids a blank screen on watch start. time_t now = time(NULL); struct tm *tick_time = localtime(&now); handle_tick(tick_time, DAY_UNIT + HOUR_UNIT + MINUTE_UNIT); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); }
void set_bluetooth_layer() { bluetooth_layer = bitmap_layer_create(GRect (62, 5, 20, 10)); //(x,y,w,h) (x,y,144*168) off_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH_OFF); bitmap_layer_set_bitmap(bluetooth_layer, on_image); //layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bluetooth_layer)); }
void background_load( const Window *window_ptr, const GPoint point ) { hachune[ 0 ] = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_HACHUNE01 ); hachune[ 1 ] = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_HACHUNE02 ); Background_layer = bitmap_layer_create( GRect( point.x, point.y, 144 - point.x, 169 - point.y ) ); // max 144 * 169 layer_add_child( window_get_root_layer( window_ptr ), bitmap_layer_get_layer( Background_layer ) ); }
void setup_explosion() { explosion = bitmap_layer_create(LASTFRAME); bitmap_layer_set_bitmap(explosion, explosion_image); bitmap_layer_set_compositing_mode(explosion, GCompOpAnd); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(explosion)); layer_set_hidden(bitmap_layer_get_layer(explosion), true); }
void splash_window_load(Window *window) { splash_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SPLASH); splash_bitmap_layer = bitmap_layer_create(GRect(5, 5, 130, 130)); bitmap_layer_set_bitmap(splash_bitmap_layer, splash_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(splash_bitmap_layer)); app_timer_register(SPLASH_SEC * 1000,(AppTimerCallback) after_splash_window, NULL); }
void setup_bolt() { bolt = bitmap_layer_create(FRAME01); bitmap_layer_set_bitmap(bolt, bolt_image); bitmap_layer_set_compositing_mode(bolt, GCompOpAnd); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bolt)); layer_set_hidden(bitmap_layer_get_layer(bolt), true); }
static void window_load(Window *window) { Layer *root_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(root_layer); s_bitmap_layer = bitmap_layer_create(bounds); bitmap_layer_set_compositing_mode(s_bitmap_layer, GCompOpSet); layer_add_child(root_layer, bitmap_layer_get_layer(s_bitmap_layer)); }
void menu_load(Window *menu) { int num_menu_items = 0; main_menu_items[num_menu_items++] = (SimpleMenuItem) { .title = "Ask", .callback = search_select_callback, }; main_menu_items[num_menu_items++] = (SimpleMenuItem) { .title = "Answers", //.callback = //callback to what you want this item to do when clicked }; main_menu_items[num_menu_items++] = (SimpleMenuItem) { .title = "Questions", //.callback = //callback to what you want this item to do when clicked }; main_menu_items[num_menu_items++] = (SimpleMenuItem) { .title = "Help", .callback = help_select_callback, }; main_menu_sections[0] = (SimpleMenuSection) { .num_items = MENU_NUM_ITEMS, .items = main_menu_items }; GRect bounds = layer_get_bounds(window_get_root_layer(menu)); main_menu_layer = simple_menu_layer_create(bounds, menu, main_menu_sections, MENU_NUM_SECTIONS, NULL); layer_add_child(window_get_root_layer(menu), simple_menu_layer_get_layer(main_menu_layer)); } void menu_unload(Window *menu) { text_layer_destroy(menu_text); text_layer_destroy(select_text); } void title_load(Window *title) { title_bitmap = gbitmap_create_with_resource(RESOURCE_ID_REDDIT_TITLE_IMAGE); title_layer = bitmap_layer_create(GRect(0, 0, 144, 180)); bitmap_layer_set_bitmap(title_layer, title_bitmap); layer_add_child(window_get_root_layer(title), bitmap_layer_get_layer(title_layer)); } void title_unload(Window *title) { bitmap_layer_destroy(title_layer); } void title_click_handler(ClickRecognizerRef recognizer, void *context) { window_stack_push(menu, true); }
static void initialize_ui() { s_window = window_create(); window_set_fullscreen(s_window, false); window_set_background_color(s_window, GColorBlack); Layer *window_layer = window_get_root_layer(s_window); GRect bounds = layer_get_frame(window_layer); s_icon_vol_up = gbitmap_create_with_resource(RESOURCE_ID_ICON_VOL_UP); s_icon_pause = gbitmap_create_with_resource(RESOURCE_ID_ICON_PAUSE); s_icon_play = gbitmap_create_with_resource(RESOURCE_ID_ICON_PLAY); s_icon_vol_dn = gbitmap_create_with_resource(RESOURCE_ID_ICON_VOL_DN); s_icon_speaker = gbitmap_create_with_resource(RESOURCE_ID_ICON_SPEAKER); s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18); // s_lyr_backround s_lyr_background = layer_create(bounds); layer_set_update_proc(s_lyr_background, lyr_background_update_proc); layer_add_child(window_layer, (Layer *) s_lyr_background); // s_player_bar s_action_bar = action_bar_layer_create(); action_bar_layer_add_to_window(s_action_bar, s_window); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_vol_up); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_vol_dn); action_bar_layer_set_click_config_provider(s_action_bar, click_provider); layer_add_child(window_layer, (Layer *) s_action_bar); // s_txt_title s_txt_title = text_layer_create(GRect(4, 0, 116, 76)); text_layer_set_background_color(s_txt_title, GColorClear); text_layer_set_text_color(s_txt_title, GColorWhite); text_layer_set_text_alignment(s_txt_title, GTextAlignmentCenter); text_layer_set_font(s_txt_title, s_res_gothic_24_bold); text_layer_set_text(s_txt_title, "Loading..."); layer_add_child(window_layer, (Layer *) s_txt_title); // s_txt_artist s_txt_artist = text_layer_create(GRect(4, 78, 116, 56)); text_layer_set_background_color(s_txt_artist, GColorClear); text_layer_set_text_color(s_txt_artist, GColorWhite); text_layer_set_text_alignment(s_txt_artist, GTextAlignmentCenter); text_layer_set_font(s_txt_artist, s_res_gothic_18); layer_add_child(window_layer, (Layer *) s_txt_artist); // s_bmap_speaker s_bmp_speaker = bitmap_layer_create(GRect(2, 134, 8, 12)); bitmap_layer_set_bitmap(s_bmp_speaker, s_icon_speaker); layer_add_child(window_layer, (Layer *) s_bmp_speaker); // s_lyr_volume s_lyr_volume = layer_create_with_data(GRect(16, 136, 100, 8), sizeof(uint32_t)); layer_set_update_proc(s_lyr_volume, lyr_volume_update_proc); uint32_t *len = (uint32_t *) layer_get_data(s_lyr_volume); *len = 0; layer_add_child(window_layer, (Layer *) s_lyr_volume); app_message_register_inbox_received(inbox_received_callback); app_message_register_inbox_dropped(inbox_dropped_callback); outbox_send("GET_STATUS"); }
// Init function to handle the creation of layers, // event subscribing, etc void handle_init(void) { // window init window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorWhite); // display layer Layer *window_layer = window_get_root_layer(window); // background leafs = gbitmap_create_with_resource(RESOURCE_ID_BKNG); leafs_layer = bitmap_layer_create(GRect(0, 0, WATCH_WIDTH, WATCH_HEIGHT)); bitmap_layer_set_bitmap(leafs_layer, leafs); layer_add_child(window_layer, bitmap_layer_get_layer(leafs_layer)); GFont prox_reg = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PROXIMA_REGULAR_16)); GFont prox_bold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PROXIMA_BOLD_30)); // time init text_time_layer = text_layer_create(GRect(55, 100,(WATCH_WIDTH - 55), 50)); text_layer_set_font(text_time_layer, prox_bold); text_layer_set_background_color(text_time_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(text_time_layer)); // date init text_date_layer = text_layer_create(GRect(55, 130, (WATCH_WIDTH - 55), 20)); text_layer_set_font(text_date_layer, prox_reg); text_layer_set_background_color(text_date_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(text_date_layer)); // score init text_score_layer = text_layer_create(GRect(55, 15, (WATCH_WIDTH - 55), 20)); text_layer_set_font(text_score_layer, prox_reg); text_layer_set_text_color(text_score_layer, GColorWhite); text_layer_set_background_color(text_score_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(text_score_layer)); //update_display(tick_time); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); // AppSync stuff const int inbound_size = 64; const int outbound_size = 64; app_message_open(inbound_size, outbound_size); Tuplet initial_values[] = { TupletCString(0, "0-0") }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL); send_cmd(); // setting up timer to send cmds for updates timer = app_timer_register(10000, timer_callback, NULL); }
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)); }
static void initialise_ui(void) { s_window = window_create(); window_set_background_color(s_window, GColorBlack); #ifndef PBL_SDK_3 window_set_fullscreen(s_window, 0); #endif s_res_background = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND); s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14); // s_background s_background = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(s_background, s_res_background); layer_add_child(window_get_root_layer(s_window), (Layer *)s_background); // s_temp s_temp = text_layer_create(GRect(0, 86, 144, 28)); text_layer_set_background_color(s_temp, GColorClear); text_layer_set_text(s_temp, "..."); text_layer_set_text_alignment(s_temp, GTextAlignmentCenter); text_layer_set_font(s_temp, s_res_gothic_28_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)s_temp); // s_label_cpu s_label_cpu = text_layer_create(GRect(9, 152, 33, 16)); text_layer_set_background_color(s_label_cpu, GColorClear); text_layer_set_text(s_label_cpu, "CPU"); text_layer_set_text_alignment(s_label_cpu, GTextAlignmentCenter); text_layer_set_font(s_label_cpu, s_res_gothic_14); layer_add_child(window_get_root_layer(s_window), (Layer *)s_label_cpu); // s_label_ram s_label_ram = text_layer_create(GRect(102, 152, 33, 16)); text_layer_set_background_color(s_label_ram, GColorClear); text_layer_set_text(s_label_ram, "RAM"); text_layer_set_text_alignment(s_label_ram, GTextAlignmentCenter); text_layer_set_font(s_label_ram, s_res_gothic_14); layer_add_child(window_get_root_layer(s_window), (Layer *)s_label_ram); // s_label_core s_label_core = text_layer_create(GRect(0, 114, 144, 14)); text_layer_set_background_color(s_label_core, GColorClear); text_layer_set_text(s_label_core, "CORE"); text_layer_set_text_alignment(s_label_core, GTextAlignmentCenter); layer_add_child(window_get_root_layer(s_window), (Layer *)s_label_core); // s_label_temp s_label_temp = text_layer_create(GRect(0, 125, 144, 14)); text_layer_set_background_color(s_label_temp, GColorClear); text_layer_set_text(s_label_temp, "TEMP"); text_layer_set_text_alignment(s_label_temp, GTextAlignmentCenter); layer_add_child(window_get_root_layer(s_window), (Layer *)s_label_temp); // s_ticks s_ticks = layer_create(GRect(0, 0, 144, 144)); layer_add_child(window_get_root_layer(s_window), (Layer *)s_ticks); }
void thread_window_load(Window *window) { struct ThreadData *thread = GetSelectedThread(); thread_scroll_layer = scroll_layer_create(window_frame); scroll_layer_set_shadow_hidden(thread_scroll_layer, true); scroll_layer_set_click_config_onto_window(thread_scroll_layer, window); scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 0)); scroll_layer_set_content_offset(thread_scroll_layer, GPoint(0, 0), false); ScrollLayerCallbacks scrollOverride = { .click_config_provider = &thread_click_config, .content_offset_changed_handler = &thread_offset_changed_handler }; scroll_layer_set_callbacks(thread_scroll_layer, scrollOverride); thread_title_layer = layer_create(GRect(0, 0, window_frame.size.w, 22)); layer_set_update_proc(thread_title_layer, thread_title_layer_update_proc); scroll_layer_add_child(thread_scroll_layer, thread_title_layer); layer_add_child(window_get_root_layer(window), scroll_layer_get_layer(thread_scroll_layer)); thread_view_comments_layer = text_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT)); text_layer_set_text(thread_view_comments_layer, "View Comments"); text_layer_set_font(thread_view_comments_layer, GetBiggerFont()); text_layer_set_text_alignment(thread_view_comments_layer, GTextAlignmentCenter); scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_view_comments_layer)); thread_inverter_hidden = true; thread_inverter_layer = inverter_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT)); layer_set_hidden(inverter_layer_get_layer(thread_inverter_layer), true); scroll_layer_add_child(thread_scroll_layer, inverter_layer_get_layer(thread_inverter_layer)); if(thread->type == 1) { // we are an image thread_body_layer = NULL; thread_bitmap_layer = bitmap_layer_create(GRect(0, 22, window_frame.size.w, window_frame.size.h)); scroll_layer_add_child(thread_scroll_layer, bitmap_layer_get_layer(thread_bitmap_layer)); scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 22 + window_frame.size.h + 10)); thread_update_comments_position(); } else { //current_thread.image = NULL; thread_bitmap_layer = NULL; thread_body_layer = text_layer_create(GRect(0, 22, window_frame.size.w, 10000)); text_layer_set_font(thread_body_layer, GetFont()); scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_body_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"); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_LARGE_ICON); icon_bitmap_layer = bitmap_layer_create(layer_get_frame(window_layer)); bitmap_layer_set_bitmap(icon_bitmap_layer, icon_bitmap); layer_add_child(window_layer, bitmap_layer_get_layer(icon_bitmap_layer)); }
void window_load(Window *window) { // Load Fonts font_hour = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LATO_BLACK_24)); font_minute = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LATO_REGULAR_18)); font_date = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_LATO_REGULAR_12)); // Create Background Layer layer_background = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_background_color(layer_background, GColorBlack); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(layer_background)); // Create Hours Text Layer layer_hour = text_layer_create(GRect(4,42,136,32)); text_layer_set_background_color(layer_hour, GColorClear); text_layer_set_text_color(layer_hour, GColorWhite); text_layer_set_text(layer_hour, "mille"); text_layer_set_font(layer_hour, font_hour); text_layer_set_text_alignment(layer_hour, GTextAlignmentRight); layer_add_child(window_get_root_layer(window), text_layer_get_layer(layer_hour)); // Create Minutes Text Layer layer_minute = text_layer_create(GRect(4,68,136,64)); text_layer_set_background_color(layer_minute, GColorClear); text_layer_set_text_color(layer_minute, GColorWhite); text_layer_set_text(layer_minute, "heures moins mille"); text_layer_set_font(layer_minute, font_minute); text_layer_set_text_alignment(layer_minute, GTextAlignmentRight); layer_add_child(window_get_root_layer(window), text_layer_get_layer(layer_minute)); // Create Dates Text Layer layer_date = text_layer_create(GRect(4,150,136,32)); text_layer_set_background_color(layer_date, GColorClear); text_layer_set_text_color(layer_date, GColorWhite); text_layer_set_text(layer_date, "mille movembre"); text_layer_set_font(layer_date, font_date); text_layer_set_text_alignment(layer_date, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), text_layer_get_layer(layer_date)); // Create Battery Layer bitmap_battery = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_00); layer_battery = bitmap_layer_create(GRect(59, 4, 26, 10)); bitmap_layer_set_bitmap(layer_battery, bitmap_battery); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(layer_battery)); }
void window_load(Window *window) { ResHandle font_handle = resource_get_handle(RESOURCE_ID_SEAHAWKS_FONT_46); seahawks_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SEAHAWKS_LOGO); feather_bitmap = gbitmap_create_with_resource(RESOURCE_ID_FEATHER); seahawks_layer = bitmap_layer_create(GRect(0,30,144,60)); bitmap_layer_set_bitmap(seahawks_layer, seahawks_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(seahawks_layer)); //feather feather_layer_bottom = bitmap_layer_create(GRect(0,144,144,24)); bitmap_layer_set_bitmap(feather_layer_bottom, feather_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(feather_layer_bottom)); feather_layer_top = bitmap_layer_create(GRect(0,0,144,24)); bitmap_layer_set_bitmap(feather_layer_top, feather_bitmap); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(feather_layer_top)); text_layer = text_layer_create(GRect(15,85,120,168)); text_layer_set_background_color(text_layer, GColorClear); text_layer_set_text_color(text_layer, GColorBlack); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); text_layer_set_font(text_layer, fonts_load_custom_font(font_handle)); layer_add_child(window_get_root_layer(window), (Layer*) text_layer); inv_layer = inverter_layer_create(GRect(0, 0, 144, 168)); layer_add_child(window_get_root_layer(window), (Layer*) inv_layer); struct tm *t; time_t temp; temp = time(NULL); t= localtime(&temp); tick_handler(t, MINUTE_UNIT); //add window elements }
void main_window_load(){ Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); layer_set_update_proc(window_layer, update_proc); B0 = gbitmap_create_with_resource(RESOURCE_ID_RES_0); B1 = gbitmap_create_with_resource(RESOURCE_ID_RES_1); B2 = gbitmap_create_with_resource(RESOURCE_ID_RES_2); B3 = gbitmap_create_with_resource(RESOURCE_ID_RES_3); B4 = gbitmap_create_with_resource(RESOURCE_ID_RES_4); B5 = gbitmap_create_with_resource(RESOURCE_ID_RES_5); B6 = gbitmap_create_with_resource(RESOURCE_ID_RES_6); B7 = gbitmap_create_with_resource(RESOURCE_ID_RES_7); B8 = gbitmap_create_with_resource(RESOURCE_ID_RES_8); B9 = gbitmap_create_with_resource(RESOURCE_ID_RES_9); #ifdef PBL_ROUND bool round = true; #else bool round = false; #endif if(!(center || round)){ hour1 = bitmap_layer_create(GRect(PADING_X, PADING_Y, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(hour1, B0); layer_add_child(window_layer, bitmap_layer_get_layer(hour1)); hour2 = bitmap_layer_create(GRect(PADING_X*2 + IMAGE_W, PADING_Y, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(hour2, B1); layer_add_child(window_layer, bitmap_layer_get_layer(hour2)); min1 = bitmap_layer_create(GRect(PADING_X, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(min1, B2); layer_add_child(window_layer, bitmap_layer_get_layer(min1)); min2 = bitmap_layer_create(GRect(PADING_X*2 + IMAGE_W, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(min2, B3); layer_add_child(window_layer, bitmap_layer_get_layer(min2)); }else{ hour1 = bitmap_layer_create(GRect(PADING_CENTER_X, PADING_Y, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(hour1, B0); layer_add_child(window_layer, bitmap_layer_get_layer(hour1)); hour2 = bitmap_layer_create(GRect(bounds.size.w - PADING_CENTER_X - IMAGE_W, PADING_Y, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(hour2, B1); layer_add_child(window_layer, bitmap_layer_get_layer(hour2)); min1 = bitmap_layer_create(GRect(PADING_CENTER_X, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(min1, B2); layer_add_child(window_layer, bitmap_layer_get_layer(min1)); min2 = bitmap_layer_create(GRect(bounds.size.w - PADING_CENTER_X - IMAGE_W, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H)); bitmap_layer_set_bitmap(min2, B3); layer_add_child(window_layer, bitmap_layer_get_layer(min2)); } set_time(); }
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)); // Stroke Text s_time_layer1 = text_layer_create(GRect(-2, 63, 144, 50)); text_layer_set_background_color(s_time_layer1, GColorClear); text_layer_set_text_color(s_time_layer1, GColorBlack); text_layer_set_text(s_time_layer1, "00:00"); s_time_layer2 = text_layer_create(GRect(-2, 67, 144, 50)); text_layer_set_background_color(s_time_layer2, GColorClear); text_layer_set_text_color(s_time_layer2, GColorBlack); text_layer_set_text(s_time_layer2, "00:00"); s_time_layer3 = text_layer_create(GRect(2, 63, 144, 50)); text_layer_set_background_color(s_time_layer3, GColorClear); text_layer_set_text_color(s_time_layer3, GColorBlack); text_layer_set_text(s_time_layer3, "00:00"); s_time_layer4 = text_layer_create(GRect(2, 67, 144, 50)); text_layer_set_background_color(s_time_layer4, GColorClear); text_layer_set_text_color(s_time_layer4, GColorBlack); text_layer_set_text(s_time_layer4, "00:00"); // Create time TextLayer s_time_layer = text_layer_create(GRect(0, 65, 144, 50)); 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"); //Create GFont s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_BELWE_BOLD_42)); //Apply to TextLayer text_layer_set_text_alignment(s_time_layer1, GTextAlignmentCenter); text_layer_set_font(s_time_layer2, s_time_font); text_layer_set_text_alignment(s_time_layer2, GTextAlignmentCenter); text_layer_set_font(s_time_layer3, s_time_font); text_layer_set_text_alignment(s_time_layer3, GTextAlignmentCenter); text_layer_set_font(s_time_layer4, s_time_font); text_layer_set_text_alignment(s_time_layer4, GTextAlignmentCenter); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); text_layer_set_font(s_time_layer1, s_time_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_layer1)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer2)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer3)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer4)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); // Make sure the time is displayed from the start update_time(); }
void LoadBackground(Window *ParentWindow) { Layer *AnimLayer = GetAnimLayer(); // Create GBitmap, then set to created BitmapLayer BackgroundBitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_STATSBACKGROUND); BackgroundLayer = bitmap_layer_create(GRect(0, 50, 144, 100)); bitmap_layer_set_bitmap(BackgroundLayer, BackgroundBitmap); layer_add_child(/*window_get_root_layer(ParentWindow)*/AnimLayer, bitmap_layer_get_layer(BackgroundLayer)); }
static void draw_title(Layer *layer, GContext *ctx) { GRect title_bounds = layer_get_bounds(layer); logo = gbitmap_create_with_resource(RESOURCE_ID_LOGO); logo_layer = bitmap_layer_create(title_bounds); bitmap_layer_set_bitmap(logo_layer, logo); layer_add_child(layer, bitmap_layer_get_layer(logo_layer)); }
/* * Create a bitmap layer with bitmap in one go */ EXTFN void macro_bitmap_layer_create(BitmapLayerComp *comp, GRect frame, Layer *parent, uint32_t resource_id, bool visible) { comp->layer = bitmap_layer_create(frame); #ifdef PBL_COLOR bitmap_layer_set_compositing_mode(comp->layer, GCompOpSet); #endif layer_add_child(parent, bitmap_layer_get_layer_jf(comp->layer)); comp->bitmap = gbitmap_create_with_resource(resource_id); bitmap_layer_set_bitmap(comp->layer, comp->bitmap); layer_set_hidden(bitmap_layer_get_layer_jf(comp->layer), !visible); }
static void bluetooth_disconnected_splash_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); // Load bluetooth disconnected image s_bluetoothdisconnected_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); s_bluetoothdisconnected_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTHDISCONNECTED); bitmap_layer_set_bitmap(s_bluetoothdisconnected_layer, s_bluetoothdisconnected_bitmap); layer_add_child(window_layer, bitmap_layer_get_layer(s_bluetoothdisconnected_layer)); }
static void main_window_load(Window *window) { // Create GBitmap, then set to created BitmapLayer s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_DBZ); s_background_layer = bitmap_layer_create(GRect(-28, 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 time TextLayer s_time_layer = text_layer_create(GRect(67, 35, 76, 40)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); // Improve the layout to be more like a watchface // Create GFont s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHEWY_28)); #ifdef PBL_COLOR text_layer_set_text_color(s_time_layer, GColorRed); #endif text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); // Add it to the child layer to the Window's root layer layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer)); // Create date TextLayer s_date_layer = text_layer_create(GRect(67, 70, 75, 25)); text_layer_set_background_color(s_date_layer, GColorClear); text_layer_set_text_color(s_date_layer, GColorBlack); s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHEWY_16)); #ifdef PBL_COLOR text_layer_set_text_color(s_date_layer, GColorDarkCandyAppleRed); #endif text_layer_set_font(s_date_layer, s_date_font); text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter); // Add it to the child layer to the Window's root layer layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_date_layer)); // Create weather TextLayer s_weather_layer = text_layer_create(GRect(67, 93, 75, 25)); text_layer_set_background_color(s_weather_layer, GColorClear); text_layer_set_text_color(s_weather_layer, GColorBlack); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); text_layer_set_text(s_weather_layer, "Loading..."); // Create second custom font, apply it and add to the Window s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHEWY_14)); #ifdef PBL_COLOR text_layer_set_text_color(s_weather_layer, GColorDarkCandyAppleRed); #endif 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)); }
static void initialise_ui(void) { s_window = window_create(); s_res_image_smpte_face = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SMPTE_FACE); s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD); s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14); s_res_image_bluetooth_connected = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH_CONNECTED); // s_bitmaplayer_background s_bitmaplayer_background = bitmap_layer_create(GRect(0, 0, 144, 168)); bitmap_layer_set_bitmap(s_bitmaplayer_background, s_res_image_smpte_face); layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_background); // s_textlayer_time s_textlayer_time = text_layer_create(GRect(2, 49, 137, 36)); text_layer_set_background_color(s_textlayer_time, GColorBlack); text_layer_set_text_color(s_textlayer_time, GColorWhite); text_layer_set_text(s_textlayer_time, "TCR: 00:00:00"); text_layer_set_text_alignment(s_textlayer_time, GTextAlignmentCenter); text_layer_set_font(s_textlayer_time, s_res_gothic_28_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_time); // s_textlayer_UB s_textlayer_UB = text_layer_create(GRect(3, 146, 75, 18)); text_layer_set_background_color(s_textlayer_UB, GColorBlack); text_layer_set_text_color(s_textlayer_UB, GColorWhite); text_layer_set_text(s_textlayer_UB, "UB:00-00-00"); text_layer_set_text_alignment(s_textlayer_UB, GTextAlignmentCenter); layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_UB); // s_textlayer_1 s_textlayer_1 = text_layer_create(GRect(2, 85, 39, 18)); text_layer_set_background_color(s_textlayer_1, GColorBlack); text_layer_set_text_color(s_textlayer_1, GColorWhite); text_layer_set_text(s_textlayer_1, "LOCK"); text_layer_set_font(s_textlayer_1, s_res_gothic_14); layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1); // s_bitmaplayer_bluetooth_connected s_bitmaplayer_bluetooth_connected = bitmap_layer_create(GRect(29, 89, 8, 14)); bitmap_layer_set_bitmap(s_bitmaplayer_bluetooth_connected, s_res_image_bluetooth_connected); layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_bluetooth_connected); }
void window_load(Window *window) { // Here goes the clock clock_layer = text_layer_create(GRect(3, 0, 80, 20)); text_layer_set_background_color(clock_layer, GColorClear); text_layer_set_text_color(clock_layer, GColorBlack); text_layer_set_text(clock_layer, "Time"); // Ship name name_layer = text_layer_create(GRect(52, 0, 105, 20)); text_layer_set_background_color(name_layer, GColorClear); text_layer_set_text_color(name_layer, GColorBlack); text_layer_set_text(name_layer, "No Connection"); // Altitude display altitude_layer = text_layer_create(GRect(3, 20, 168, 144)); text_layer_set_background_color(altitude_layer, GColorClear); text_layer_set_text_color(altitude_layer, GColorBlack); text_layer_set_font(altitude_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text(altitude_layer, "Altitude: N/A"); // Apoapsis display apoapsis_layer = text_layer_create(GRect(3, 40, 168, 144)); text_layer_set_background_color(apoapsis_layer, GColorClear); text_layer_set_text_color(apoapsis_layer, GColorBlack); text_layer_set_font(apoapsis_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text(apoapsis_layer, "Apoapsis: N/A"); periapsis_layer = text_layer_create(GRect(3, 60, 168, 144)); text_layer_set_background_color(periapsis_layer, GColorClear); text_layer_set_text_color(periapsis_layer, GColorBlack); text_layer_set_font(periapsis_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text(periapsis_layer, "Periap: N/A"); // The top border lines topborder_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TOPBORDER); topborder_layer = bitmap_layer_create(GRect(0, 0, 144, 20)); bitmap_layer_set_bitmap(topborder_layer, topborder_bitmap); // Render everything nicely layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(topborder_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(clock_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(name_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(altitude_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(apoapsis_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(periapsis_layer)); // Clock that fires once per second struct tm *t; time_t temp; temp = time(NULL); t = localtime(&temp); tick_handler(t, SECOND_UNIT); }