void chrono_start_stop_handler(ClickRecognizerRef recognizer, Window *window) { PblTm time; int seconds; get_time(&time); seconds = get_time_seconds(&time); // The start/stop button was pressed. if (chrono_running) { // If the chronograph is currently running, this means to stop (or // pause). chrono_hold_seconds = seconds - chrono_start_seconds; chrono_running = false; chrono_lap_paused = false; vibes_enqueue_custom_pattern(tap); update_hands(&time); // We change the click config provider according to the chrono run // state. When the chrono is stopped, we listen for a different // set of buttons than when it is started. window_set_click_config_provider(window, (ClickConfigProvider)stopped_click_config_provider); } else { // If the chronograph is not currently running, this means to // start, from the currently showing Chronograph time. chrono_start_seconds = seconds - chrono_hold_seconds; chrono_running = true; vibes_enqueue_custom_pattern(tap); update_hands(&time); window_set_click_config_provider(window, (ClickConfigProvider)started_click_config_provider); } }
void chrono_set_click_config(struct Window *window) { if (chrono_data.running) { window_set_click_config_provider(window, &started_click_config_provider); } else { window_set_click_config_provider(window, &stopped_click_config_provider); } }
void chrono_digital_window_appear_handler(struct Window *window) { app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "chrono digital appears"); chrono_digital_window_showing = true; // We never have the lap timer paused while the digital window is visible. chrono_data.lap_paused = false; if (chrono_data.running) { window_set_click_config_provider(chrono_digital_window, &started_click_config_provider); } else { window_set_click_config_provider(chrono_digital_window, &stopped_click_config_provider); } reset_chrono_digital_timer(); }
static void single_code_window_load(Window *window) { window_set_click_config_provider(single_code_main_window, (ClickConfigProvider) window_config_provider); Layer *window_layer = window_get_root_layer(single_code_main_window); display_bounds = layer_get_frame(window_layer); Layer *countdown_layer = layer_create(display_bounds); layer_add_child(window_layer, countdown_layer); //add_countdown_layer(s_layer); start_managing_countdown_layer(countdown_layer); text_label_rect = single_text_label_rect; GRect text_label_start = text_label_rect; text_label_start.origin.x = display_bounds.size.w; text_label_layer = text_layer_create(text_label_start); text_layer_set_background_color(text_label_layer, GColorClear); text_layer_set_text_alignment(text_label_layer, single_text_label_alignment); text_layer_set_overflow_mode(text_label_layer, GTextOverflowModeWordWrap); text_layer_set_text(text_label_layer, label_text); layer_add_child(window_layer, text_layer_get_layer(text_label_layer)); text_pin_rect = single_text_pin_rect; GRect text_pin_start = text_pin_rect; text_pin_start.origin.x = display_bounds.size.w; text_pin_layer = text_layer_create(text_pin_start); text_layer_set_background_color(text_pin_layer, GColorClear); text_layer_set_text_alignment(text_pin_layer, GTextAlignmentCenter); text_layer_set_text(text_pin_layer, pin_text); layer_add_child(window_layer, text_layer_get_layer(text_pin_layer)); apply_display_colors(); set_fonts(); loading_complete = true; }
//Loads main_window static void main_window_load(Window *window) { // Here we load the bitmap assets s_menu_icons[0] = gbitmap_create_with_resource(RESOURCE_ID_VERYGOOD); s_menu_icons[1] = gbitmap_create_with_resource(RESOURCE_ID_GOOD); s_menu_icons[2] = gbitmap_create_with_resource(RESOURCE_ID_MED); s_menu_icons[3] = gbitmap_create_with_resource(RESOURCE_ID_BAD); s_menu_icons[4] = gbitmap_create_with_resource(RESOURCE_ID_VERYBAD); s_menu_icons[5] = gbitmap_create_with_resource(RESOURCE_ID_EXAMPLE1); // Now we prepare to initialize the menu layer Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); //if user presses BACK, the app exits window_set_click_config_provider(window, back_click_config_provider); // Create the menu layer s_menu_layer = menu_layer_create(bounds); menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks){ .get_num_rows = menu_get_num_rows_callback, .get_header_height = PBL_IF_RECT_ELSE(menu_get_header_height_callback, NULL), .draw_header = PBL_IF_RECT_ELSE(menu_draw_header_callback, NULL), .draw_row = menu_draw_row_callback, .select_click = menu_select_callback, .get_cell_height = PBL_IF_ROUND_ELSE(get_cell_height_callback, NULL), });
static void onWindowLoad(Window *window) { // 配置按键 window_set_click_config_provider(window, clickConfigProvider); // 窗口信息 Layer *layer = window_get_root_layer(window); bounds = layer_get_bounds(layer); // bitmap图层 GRect fromRect = GRect(0, 0, bounds.size.w, bounds.size.h); GRect toRect = GRect(0, bounds.size.h, bounds.size.w, bounds.size.h); bitmapLayer = bitmap_layer_create(fromRect); // bitmap对象 bitmap = gbitmap_create_with_resource(RESOURCE_ID_MY_LOGO); bitmap_layer_set_compositing_mode(bitmapLayer, GCompOpSet); bitmap_layer_set_bitmap(bitmapLayer, bitmap); // logo动画 PropertyAnimation *propAnim = property_animation_create_layer_frame((Layer *)bitmapLayer, &fromRect, &toRect); Animation *anim = property_animation_get_animation(propAnim); const int delay_ms = 1000; const int duration_ms = 3000; animation_set_curve(anim, AnimationCurveEaseOut); animation_set_delay(anim, delay_ms); animation_set_duration(anim, duration_ms); animation_schedule(anim); // 添加图层 layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(bitmapLayer)); }
void x01_gui_window_push(ClickConfigProvider click_config_provider) { s_window = window_create(); setup_window(); window_set_click_config_provider(s_window, click_config_provider); window_set_window_handlers(s_window, (WindowHandlers) { .unload = handle_window_unload });
void timer_window_load(Window *me) { static char headerText[16]; snprintf(headerText, sizeof(headerText), "Timer %d", curTimer+1); updateTimerValueText(); text_layer_init(&timerSelectHeader, timerUpdateWindow.layer.frame); text_layer_set_text_color(&timerSelectHeader, GColorBlack); text_layer_set_background_color(&timerSelectHeader, GColorClear); layer_set_frame(&timerSelectHeader.layer, GRect(8, 8, 144-8, 168-68)); text_layer_set_font(&timerSelectHeader, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK)); text_layer_set_text(&timerSelectHeader, headerText); layer_add_child(&timerUpdateWindow.layer, &timerSelectHeader.layer); text_layer_init(&timerSelectValue, timerUpdateWindow.layer.frame); text_layer_set_text_color(&timerSelectValue, GColorBlack); text_layer_set_background_color(&timerSelectValue, GColorClear); layer_set_frame(&timerSelectValue.layer, GRect(40, 50, 144-8, 168-68)); text_layer_set_font(&timerSelectValue, fonts_get_system_font(FONT_KEY_GOTHAM_42_LIGHT)); text_layer_set_text(&timerSelectValue, timerValueText); layer_add_child(&timerUpdateWindow.layer, &timerSelectValue.layer); text_layer_init(&timerSelectFooter, timerUpdateWindow.layer.frame); text_layer_set_text_color(&timerSelectFooter, GColorBlack); text_layer_set_background_color(&timerSelectFooter, GColorClear); layer_set_frame(&timerSelectFooter.layer, GRect(8, 110, 144-8, 168-68)); text_layer_set_font(&timerSelectFooter, fonts_get_system_font(FONT_KEY_GOTHAM_30_BLACK)); text_layer_set_text(&timerSelectFooter, "minutes"); layer_add_child(&timerUpdateWindow.layer, &timerSelectFooter.layer); window_set_click_config_provider(&timerUpdateWindow, (ClickConfigProvider) timer_click_config_provider); }
static void init_text_layers(void) { // text_layer = text_layer_create(GRect(x, y, width, height)); // Time Text Layer and Label base_layer = layer_create (GRect(0, 0, 144, 168)); text_layer = text_layer_create(GRect(0, 67, 144, 34)); text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); text_layer_set_background_color(text_layer, GColorClear); text_layer_set_text_color(text_layer, GColorWhite); // Add Layers to Root Window layer_add_child(base_layer, text_layer_get_layer(text_layer)); layer_add_child(window_get_root_layer(window), base_layer); // Set Initial Text Layer Text text_layer_set_text(text_layer, "hello"); // Set Window Click Config Provider window_set_click_config_provider(window, (ClickConfigProvider) config_provider); }
static void init() { s_main_window = window_create(); window_set_click_config_provider(s_main_window, config_provider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload, });
static void init(void) { window = window_create(); window_set_click_config_provider(window, click_config_provider); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); icon_layer = bitmap_layer_create(GRect(12, -5, 120, 120)); layer_add_child(window_layer, bitmap_layer_get_layer(icon_layer)); temperature_layer = text_layer_create(GRect(0, 100, 144, 68)); text_layer_set_text_color(temperature_layer, GColorWhite); text_layer_set_background_color(temperature_layer, GColorClear); text_layer_set_font(temperature_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT)); text_layer_set_text_alignment(temperature_layer, GTextAlignmentCenter); text_layer_set_text(temperature_layer, temperature); Tuplet initial_values[] = { TupletInteger(WEATHER_ICON_KEY, (uint8_t) 0), TupletCString(WEATHER_TEMPERATURE_KEY, "70\u00B0F"), TupletCString(WEATHER_REALFEEL_KEY, "70\u00B0F"), }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL); window_set_click_config_provider(window, (ClickConfigProvider) config_provider); layer_add_child(window_layer, text_layer_get_layer(temperature_layer)); }
//Initialise Windows static void prv_init(void) { s_window = window_create(); window_set_click_config_provider(s_window, prv_click_config_provider); window_set_window_handlers(s_window, (WindowHandlers) { .load = prv_window_load, .unload = prv_window_unload, });
void handle_init(AppContextRef ctx) { (void)ctx; app_ctx = ctx; window_init(&window, "Vibe"); window_stack_push(&window, true /* Animated */); power = 3; on = false; resource_init_current_app(&APP_RESOURCES); layer_init(&controls_layer, GRect(124, 3, 20, 146)); controls_layer.update_proc = &controls_update_callback; layer_add_child(&window.layer, &controls_layer); layer_init(&bars_layer, GRect(22, 22, 85, 115)); bars_layer.update_proc = &bars_update_callback; layer_add_child(&window.layer, &bars_layer); bmp_init_container(RESOURCE_ID_IMAGE_CONTROLS, &controls); bmp_init_container(RESOURCE_ID_IMAGE_BAR_ON, &bar_on); bmp_init_container(RESOURCE_ID_IMAGE_BAR_OFF, &bar_off); window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider); }
static void init(void) { // Initialize Pebble Autoconfig to register App Message handlers and restores settings autoconfig_init(); // Here the restored or defaulted settings are available logSettings("restored"); // Register our custom receive handler which in turn will call Pebble Autoconfigs receive handler app_message_register_inbox_received(in_received_handler); window = window_create(); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); for (int i = 0; i < SETTING_COUNT; ++i) { layer[i] = text_layer_create(GRect(10, 10 + i*35, bounds.size.w - 10, 28)); layer_add_child(window_layer, text_layer_get_layer(layer[i])); } updateDisplay(); // Attach our desired button functionality window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider); window_stack_push(window, true); }
static void init() { srand(time(NULL)); lightup(); // Create maze mazeWidth = 18; mazeHeight = 19; corridorSize = 8; maze = genmaze(mazeWidth, mazeHeight); // Init Accelerometer accel_data_service_subscribe(10, NULL); accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ); // Init Player Position playerX = 0; playerY = 0; // Create main Window s_main_window = window_create(); window_set_click_config_provider(s_main_window,clickprovider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = main_window_load, .unload = main_window_unload });
void handle_init(void) { my_window = window_create(); // text_layer = text_layer_create(GRect(0, 0, 144, 20)); // Create time TextLayer s_time_layer = text_layer_create(GRect(0, 55, 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"); // Improve the layout to be more like a watchface text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); 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(my_window), text_layer_get_layer(s_time_layer)); tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); update_time(); window_set_click_config_provider(my_window, config_provider); app_message_register_inbox_received(in_received_handler); app_message_register_inbox_dropped(in_dropped_handler); app_message_register_outbox_sent(out_sent_handler); app_message_register_outbox_failed(out_failed_handler); const uint32_t inbound_size = 64; const uint32_t outbound_size = 64; app_message_open(inbound_size, outbound_size); window_stack_push(my_window, true); }
void handle_init(void) { //This is just some "Hello, World" stuff: static char* hello_text; //hello_text = "Hello, 22"; int percentage = battery_state_service_peek().charge_percent; snprintf (hello_text, 10, "Hello. %d", percentage); my_window = window_create(); Layer *window_layer = window_get_root_layer(my_window); GRect window_frame = layer_get_bounds(window_layer); text_layer = text_layer_create(GRect(0, 0, 144, 20)); text_layer_set_text(text_layer, hello_text); layer_add_child(window_layer, text_layer_get_layer(text_layer)); //This is the layer with the bluetooth connection status: int status_x = window_frame.size.w - 12; int status_y = 0; //status_layer = create_status_layer(window_frame); status_layer = create_status_layer(status_x, status_y, PHONE_STATUS_BLACK); layer_add_child(window_layer, bitmap_layer_get_layer(status_layer)); //This is the layer with the battery status: GRect battery_bar_rect = GRect(0,0,10,100); int battery_bar_shape = BATTERY_BAR_VERTICAL; battery_layer = create_battery_layer(battery_bar_rect, battery_bar_shape); layer_add_child(window_layer, inverter_layer_get_layer(battery_layer)); //This is some testing on how to move and resize things: window_set_click_config_provider(my_window, my_click_handler); //Finally, display the window: window_stack_push(my_window, true); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); window_set_click_config_provider(window, main_click_config_provider); s_center = grect_center_point(&bounds); s_main_layer = layer_create(bounds); layer_add_child(window_layer, s_main_layer); // left time label s_left_time_label = text_layer_create(GRect(46, 102, 110, 40)); text_layer_set_background_color(s_left_time_label, GColorClear); if(persist_read_int(MODE_REST)) { text_layer_set_text_color(s_left_time_label, REST_COLOR); } else { text_layer_set_text_color(s_left_time_label, CONCENTRATION_COLOR); } text_layer_set_font(s_left_time_label, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS)); layer_add_child(window_layer, text_layer_get_layer(s_left_time_label)); layer_set_update_proc(s_main_layer, update_main_proc); // fire timer app_timer_register(0, count_timer_handler, NULL); }
void help_window_push() { if(!help_window) { help_window = window_create(); window_set_click_config_provider(help_window, help_click_config_provider); window_set_window_handlers(help_window, (WindowHandlers) { .load = help_window_load, .unload = help_window_unload });
void main_window_push() { if(!s_window) { s_window = window_create(); window_set_click_config_provider(s_window, click_config_provider); window_set_window_handlers(s_window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
static void init() { app_message_open(512, 512); s_main_window = window_create(); window_set_click_config_provider(s_main_window, click_config_provider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
/* * Stuff we only allow after we've gone through the normal pre-amble */ EXTFN void post_init_hook(void *data) { wakeup_init(); ui.animation_count = 6; // Make it 6 so we consider is_animation_complete() will return true layer_mark_dirty(ui.icon_bar); // Set click provider window_set_click_config_provider(ui.primary_window, (ClickConfigProvider) click_config_provider); }
void win_vibrate_init(void) { window = window_create(); window_set_background_color(window, GColorBlack); window_set_click_config_provider(window, (ClickConfigProvider)click_config_provider); window_set_window_handlers(window, (WindowHandlers) { .appear = window_appear, .disappear = window_disappear });
void InitializeBattleExitConfirmationWindow(void) { InitializeConfirmationWindow(&battleExitWindow, &exitText, &yesText, &noText); battleExitWindow.window_handlers.unload = BattleExitConfirmationDeinit; window_set_click_config_provider(&battleExitWindow, (ClickConfigProvider) BattleExitWindowClickConfigProvider); BattleInit(); ShowMainBattleMenu(); }
static void init() { app_message_open(512, 512); app_message_register_inbox_received(inbox_received_callback); s_main_window = window_create(); window_set_click_config_provider(s_main_window, click_config_provider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
//loading static void load(Window* window) { previous_question = -1; Layer *window_layer = window_get_root_layer(ui.window); GRect window_bounds = layer_get_bounds(window_layer); #ifdef PBL_COLOR layer_set_update_proc(window_layer, bg_update_proc); #endif // init text layers for(int i=0; i < 3; i++) { GRect answerBounds = GRect(144 - 34, 84 - 58 + i * 49, 30, 18); ui.romajiAnswer[i] = text_layer_create(answerBounds); text_layer_set_text_alignment(ui.romajiAnswer[i], GTextAlignmentRight); text_layer_set_font(ui.romajiAnswer[i], fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_text(ui.romajiAnswer[i], ""); #ifdef PBL_COLOR text_layer_set_background_color(ui.romajiAnswer[i], GColorClear); text_layer_set_text_color(ui.romajiAnswer[i], SEC_FG_COLOR); #endif } for(int i=0; i < 3; i++) ui.bitmaps[i] = NULL; GRect statsBounds = GRect(0, 0, 144, 18); ui.stats = text_layer_create(statsBounds); text_layer_set_text_alignment(ui.stats, GTextAlignmentCenter); text_layer_set_font(ui.stats, fonts_get_system_font(FONT_KEY_GOTHIC_18)); #ifdef PBL_COLOR text_layer_set_background_color(ui.stats, GColorClear); text_layer_set_text_color(ui.stats, SEC_FG_COLOR); #endif total_question_num = 0; correct_anserted_questions = 0; update_stats_disp(); // init icons GRect icon_rect = GRect(0, 0, window_bounds.size.w, window_bounds.size.h); grect_align(&icon_rect, &window_bounds, GAlignCenter, false); ui.glyph_layer = layer_create(icon_rect); layer_set_update_proc(ui.glyph_layer, glyph_layer_update_proc); layer_set_clips(ui.glyph_layer, true); // init layers layer_add_child(window_layer, ui.glyph_layer); layer_add_child(window_layer, text_layer_get_layer(ui.stats)); for(int i=0; i<3; i++) layer_add_child(window_layer, text_layer_get_layer(ui.romajiAnswer[i])); window_set_click_config_provider(ui.window, (ClickConfigProvider) config_provider); load_new_question(); }
void game_init(void) { game_window = window_create(); window_set_click_config_provider(game_window, click_config_provider); window_set_window_handlers(game_window, (WindowHandlers) { .load = window_load, .unload = window_unload, .appear = window_appear, .disappear = window_disappear });
static void init(void) { app_message_init(); data_image = malloc(sizeof(uint8_t) * (5 * 4) * 168 + 12); window = window_create(); window_set_click_config_provider(window, click_config_provider); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload, });
void init(void) { window = window_create(); window_set_click_config_provider(window, click_config_provider); window_set_background_color(window, GColorWhite); window_set_fullscreen(window, true); window_set_window_handlers(window, (WindowHandlers) { .load = window_load, .unload = window_unload });