void handle_init(AppContextRef ctx) { resource_init_current_app(&HOUSECONTROL); window_init(&homeWindow, "Group Selection"); WindowHandlers handlers = { .appear = &handle_home_window_appear }; window_set_window_handlers(&homeWindow, handlers); window_stack_push(&homeWindow, true /* Animated */); window_init(&groupWindow, "Device Selection"); WindowHandlers handlers2 = { .appear = &handle_group_window_appear }; window_set_window_handlers(&groupWindow, handlers2); window_init(&deviceWindow, "Device"); WindowHandlers handlers3 = { .appear = &handle_device_window_appear }; window_set_window_handlers(&deviceWindow, handlers3); //HOME LAYER GRect bounds = homeWindow.layer.bounds; menu_layer_init(&homeLayer, bounds); menu_layer_set_callbacks(&homeLayer, NULL, (MenuLayerCallbacks){ .get_num_rows = menu_home_get_num_rows, .draw_row = menu_home_draw_row, .select_click = menu_home_select_click });
static SCREEN * newterm(char *type, FILE *outfile, FILE *infile) { int res; COLS = SCREEN_WIDTH; LINES = SCREEN_HEIGHT; screen.type = type; screen.out = outfile; screen.in = infile; window_init(&screen.std_win, 0, 0, LINES, COLS, NULL, &screen.std_buff[0][0]); memset(&screen.std_buff[0][0], ' ', sizeof screen.std_buff); window_init(&screen.cur_win, 0, 0, LINES, COLS, NULL, &screen.cur_buff[0][0]); memset(&screen.cur_buff[0][0], 0, sizeof screen.cur_buff); screen.curses_mode = true; if (-1 == tcgetattr(fileno(screen.in), &screen.last_mode)) { return NULL; } stdscr = &screen.std_win; curscr = &screen.cur_win; res = doupdate(); if (res != OK) { return NULL; } return &screen; }
si_t pop_window() { switch(save_or_rename_flag) { case 0: save_window = window_init("save_directory_window"); break; case 1: save_window = window_init("save_file_window"); break; case 2: save_window = window_init("rename_window"); break; default: break; } if(NULL == save_window) { //EGUI_PRINT_ERROR("failed to init save window"); application_exit(); return -1; } window_set_bounds(save_window,200, 200, 300, 60); window_set_color(save_window, NULL, &ground_purple); save_text_line = text_line_init(100, 0); if(NULL == save_text_line) { //EGUI_PRINT_ERROR("failed to init save_text_line on save window"); application_exit(); return -1; } text_line_set_bounds(save_text_line, 5, 5, 230, 50); text_line_set_placeholder(save_text_line, "input file name"); text_line_set_color(save_text_line, &heavy_blue, NULL, &heavy_blue ); save_button = button_init("OK"); if(NULL == save_button) { //EGUI_PRINT_ERROR("failed to init ok button on save window"); application_exit(); return -1; } button_set_bounds(save_button, 240, 10, 50, 40); button_set_color(save_button, &ground_purple, &heavy_blue ); button_set_font(save_button, FONT_MATRIX_12); save_button->callback = rename_window_ok_button_callback; object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_button)); object_attach_child(OBJECT_POINTER(save_window), OBJECT_POINTER(save_text_line)); application_add_window(Desktop_w, save_window); return 0; }
/* 测试 struct window */ int main() { si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; si_t app_type = APPLICATION_TYPE_NORMAL; struct window * w = NULL; /* 初始化用户应用程序 */ application_init(video_access_mode, app_type, "single_window"); w = window_init("single_window"); /* 申请失败 */ if(w == NULL) { application_exit(); return -1; } window_set_bounds(w, 300, 100, 450, 200); /* 添加顶层窗口 */ application_add_window(NULL, w); /* 设置主窗口 */ application_set_main_window(w); /* 运行 */ application_exec(); return 0; }
void displayHelp() { static Window window; static Layer chromeLayer; static TextLayer helpTextLayer; window_init(&window, "Help"); window_set_fullscreen(&window, true); window.layer.frame.origin.x = 5; window.layer.frame.origin.y = 5; // TODO: Should have get/set bounds functions public? window.layer.bounds.size.w -= 10; window.layer.bounds.size.h -= 10; window_set_background_color(&window, GColorClear); // TODO: Set proper/better frame/bounds values here? layer_init(&chromeLayer, window.layer.frame); chromeLayer.update_proc = &help_window_update_callback; layer_add_child(&window.layer, &chromeLayer); text_layer_init(&helpTextLayer, GRect(16, 16, 144-24-8 /* width */, 168-24-8 /* height */)); text_layer_set_text_color(&helpTextLayer, GColorWhite); text_layer_set_background_color(&helpTextLayer, GColorBlack); text_layer_set_font(&helpTextLayer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&helpTextLayer, ">Select (long press)<\nChange edit mode.\n\n>Up/Down<\nIncrease/decrease axis value\n\n(Press back to close)"); layer_add_child(&window.layer, &helpTextLayer.layer); window_stack_push(&window, false /* Not animated */); }
void handle_init(AppContextRef ctx) { window_init(&window, "Simplicity"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(8, 28, 144-8, 40)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TEST_21))); layer_add_child(&window.layer, &text_date_layer.layer); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(1, 62, 144-2, 168-62)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TEST_48))); layer_add_child(&window.layer, &text_time_layer.layer); layer_init(&line_layer, window.layer.frame); line_layer.update_proc = &line_layer_update_callback; layer_add_child(&window.layer, &line_layer); // TODO: Update display here to avoid blank display on launch? }
bool graphics_init(gfx_t* gfx) { memset(gfx, 0, sizeof *gfx); if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { return false; } if (!window_init(&gfx->window, "Spielbub", SCREEN_WIDTH, SCREEN_HEIGHT)) { return false; } gfx->background = create_surface(); gfx->sprites_bg = create_surface(); gfx->sprites_fg = create_surface(); if (!gfx->background || !gfx->sprites_bg || ! gfx->sprites_fg) { goto error; } gfx->layers[0] = gfx->background; gfx->layers[1] = gfx->sprites_bg; gfx->layers[2] = gfx->sprites_fg; gfx->state = OAM; window_clear(&gfx->window); window_draw(&gfx->window); return true; error: { graphics_destroy(gfx); return false; } }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Orbit"); window_stack_push(&window, false /* Not Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage); layer_add_child(&window.layer, &faceImage.layer.layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_PLANET_WHITE, RESOURCE_ID_IMAGE_MINUTE_PLANET_BLACK, &minuteImage); layer_add_child(&window.layer, &minuteImage.layer.layer); rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_PLANET_WHITE, RESOURCE_ID_IMAGE_HOUR_PLANET_BLACK, &hourImage); layer_add_child(&window.layer, &hourImage.layer.layer); text_layer_init(&minuteText, GRect(0,0,0,0)); text_layer_set_text_color(&minuteText, GColorWhite); text_layer_set_background_color(&minuteText, GColorClear); text_layer_set_text_alignment(&minuteText, GTextAlignmentCenter); text_layer_set_font(&minuteText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_14))); layer_add_child(&window.layer, &minuteText.layer); text_layer_init(&hourText, GRect(0,0,0,0)); text_layer_set_text_color(&hourText, GColorWhite); text_layer_set_background_color(&hourText, GColorClear); text_layer_set_text_alignment(&hourText, GTextAlignmentCenter); text_layer_set_font(&hourText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_22))); layer_add_child(&window.layer, &hourText.layer); update_rings(); }
void window_handle(WnckWindow *window, gboolean want_tiled) { if (!WNCK_IS_WINDOW (window)) { fprintf(stderr, "[bonnye] Trying to rehandle something that is not a window\n"); return; } int spaceid = workspace_get_from_window(window); gboolean is_tiled = workspace_has_tiled_window(spaceid, window); if (want_tiled) { if (is_tiled) { fprintf(stderr, "[bonnye] Trying to tile a tiled window. Doing nothing\n"); return; } workspace_add_window(spaceid, window); window_init(spaceid, window); } else { if (!is_tiled) { fprintf(stderr, "[bonnye] Trying to untile an untiled window. Doing nothing\n"); return; } workspace_remove_window(spaceid, window); window_clear(window); } tile(spaceid); }
void handle_init(AppContextRef ctx) { (void) ctx; window_init(&window, "Totoro"); window_stack_push(&window, true); resource_init_current_app(&APP_RESOURCES); // Set up a layer for the static watch face background bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); layer_add_child(&window.layer, &background_image_container.layer.layer); // Date // Initialises the date and sets the text, font and background colour text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorBlack); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(69, 150, 80, 15)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHIC_REGULAR_12))); layer_add_child(&window.layer, &text_date_layer.layer); // Time // Initialises the time and sets the text, font and background colour text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorBlack); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(0, 0, 144, 44)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GOTHIC_REGULAR_36))); text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter); layer_add_child(&window.layer, &text_time_layer.layer); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Window Name"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); Minutes_Open = 0; //Texts //Year text_layer_init(&year_layer, GRect(8, 7, 144-16, 7+12)); text_layer_set_text_color(&year_layer, GColorWhite); text_layer_set_background_color(&year_layer, GColorClear); text_layer_set_font(&year_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&year_layer, "Year"); layer_add_child(&window.layer, &year_layer.layer); //Month text_layer_init(&month_layer, GRect(8, 38, 144-16, 38+12)); text_layer_set_text_color(&month_layer, GColorWhite); text_layer_set_background_color(&month_layer, GColorClear); text_layer_set_font(&month_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&month_layer, "Month"); layer_add_child(&window.layer, &month_layer.layer); //Week text_layer_init(&week_layer, GRect(8, 69, 144-16, 69+12)); text_layer_set_text_color(&week_layer, GColorWhite); text_layer_set_background_color(&week_layer, GColorClear); text_layer_set_font(&week_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&week_layer, "Week"); layer_add_child(&window.layer, &week_layer.layer); //Day text_layer_init(&day_layer, GRect(8, 100, 144-16, 100+12)); text_layer_set_text_color(&day_layer, GColorWhite); text_layer_set_background_color(&day_layer, GColorClear); text_layer_set_font(&day_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(&day_layer, "Day"); layer_add_child(&window.layer, &day_layer.layer); //Clock text text_layer_init(&text_time_layer, GRect(0, 127, 144, 127+26)); 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_GOTHIC_28_BOLD)); text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter); text_layer_set_text(&text_time_layer, "00:00"); layer_add_child(&window.layer, &text_time_layer.layer); layer_init(&bars_layer, window.layer.frame); bars_layer.update_proc = &bars_update_callback; layer_add_child(&window.layer, &bars_layer); layer_init(&main_layer, window.layer.frame); main_layer.update_proc = &progress_update_callback; layer_add_child(&window.layer, &main_layer); }
void end_round() { round_started = false; club_menu_index = 0; text_layer_set_text(&club, club_menu[club_menu_index]); window_init(&finalscore, "Final Score"); window_stack_push(&finalscore, true /* Animated */); text_layer_init(&finalscore_score, GRect(0, 0, 144, 168-16)); text_layer_set_background_color(&finalscore_score, GColorWhite); text_layer_set_text_color(&finalscore_score, GColorBlack); text_layer_set_font(&finalscore_score,fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD)); mini_snprintf(s_final_score, 25, "Final Score %d", totalshots); text_layer_set_text(&finalscore_score, s_final_score); text_layer_set_text_alignment(&finalscore_score, GTextAlignmentCenter); layer_add_child(&finalscore.layer, &finalscore_score.layer); text_layer_init(&finalscore_putts, GRect(0, 126, 144, 168-16-126)); text_layer_set_background_color(&finalscore_putts, GColorWhite); text_layer_set_text_color(&finalscore_putts, GColorBlack); text_layer_set_font(&finalscore_putts,fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); mini_snprintf(s_final_putts, 25, "Total Putts: %d", totalputts); text_layer_set_text(&finalscore_putts, s_final_putts); text_layer_set_text_alignment(&finalscore_putts, GTextAlignmentCenter); layer_add_child(&finalscore.layer, &finalscore_putts.layer); vibes_double_pulse(); // Need to destroy list_of_shots array. }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&s_window, "barwatch"); window_stack_push(&s_window, true /* Animated */); layer_init(&bar_layer, GRect(0,0, s_window.layer.frame.size.w, s_window.layer.frame.size.h)); bar_layer.update_proc = draw_bar_layer; layer_add_child(&s_window.layer, &bar_layer); /* Initialize inverter layer * add one to x and y and subtract bar height by 2 so that the * inverter layer fits inside the rectangle and doesn't invert the rectangle */ inverter_layer_init(&days_in_year_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 0), 0, BAR_HEIGHT - 2)); inverter_layer_init(&days_in_month_inverter_layer,GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 0), 0, BAR_HEIGHT - 2)); inverter_layer_init(&days_in_week_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 1), 0, BAR_HEIGHT - 2)); inverter_layer_init(&hours_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 1), 0, BAR_HEIGHT - 2)); inverter_layer_init(&minutes_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 2), 0, BAR_HEIGHT - 2)); inverter_layer_init(&seconds_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 2), 0, BAR_HEIGHT - 2)); layer_add_child(&s_window.layer, &days_in_year_inverter_layer.layer); layer_add_child(&s_window.layer, &days_in_month_inverter_layer.layer); layer_add_child(&s_window.layer, &days_in_week_inverter_layer.layer); layer_add_child(&s_window.layer, &hours_inverter_layer.layer); layer_add_child(&s_window.layer, &minutes_inverter_layer.layer); layer_add_child(&s_window.layer, &seconds_inverter_layer.layer); draw_once = true; }
void handle_init(AppContextRef ctx) { Layer *rootLayer; int i; window_init(&window, "Squared"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); rootLayer = window_get_root_layer(&window); for (i=0; i<NUMSLOTS; i++) { initSlot(i, rootLayer); } animImpl.setup = NULL; animImpl.update = animateDigits; animImpl.teardown = NULL; animation_init(&anim); animation_set_delay(&anim, 0); animation_set_duration(&anim, DIGIT_CHANGE_ANIM_DURATION); animation_set_implementation(&anim, &animImpl); app_timer_send_event(ctx, STARTDELAY /* milliseconds */, 0); }
// Handle the start-up of the app void handle_init_app(AppContextRef app_ctx) { // Create our app's base window window_init(&window, "Tic Tock Toe watch"); window_stack_push(&window, true); window_set_background_color(&window, COLOR_BACKGROUND); // Init the layer that shows the board layer_init(&boardLayer, window.layer.frame); // Associate with layer object and set dimensions boardLayer.update_proc = &boardLayer_update_callback; // Set the drawing callback function for the layer. layer_add_child(&window.layer, &boardLayer); // Add the child to the app's base window // Init the layer that shows the player marks // TODO: Wrap this boilerplate in a function? layer_init(&playersLayer, window.layer.frame); playersLayer.update_proc = &playersLayer_update_callback; layer_add_child(&window.layer, &playersLayer); // Init the text layer used to show the time // TODO: Determine best practice for text. e.g. TextLayer with standard update proc vs Layer with custom update proc // TODO: Wrap this boilerplate in a function? text_layer_init(&timeLayer, GRect(0, 168-42, 144 /* width */, 42 /* height */)); text_layer_set_text_alignment(&timeLayer, GTextAlignmentCenter); text_layer_set_text_color(&timeLayer, COLOR_FOREGROUND); text_layer_set_background_color(&timeLayer, GColorClear); text_layer_set_font(&timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); update_time_display(); layer_add_child(&window.layer, &timeLayer.layer); }
bool sdl_osd_interface::video_init() { int index; // extract data from the options extract_video_config(); // set up monitors first sdl_monitor_info::init(); // we need the beam width in a float, contrary to what the core does. video_config.beamwidth = options().beam_width_min(); // initialize the window system so we can make windows if (!window_init()) return false; // create the windows for (index = 0; index < video_config.numscreens; index++) { osd_window_config conf; memset(&conf, 0, sizeof(conf)); get_resolution(options().resolution(), options().resolution(index), &conf, TRUE); // create window ... sdl_window_info *win = global_alloc(sdl_window_info(machine(), index, sdl_monitor_info::pick_monitor(options(), index), &conf)); if (win->window_init()) return false; } return true; }
void init_handler(AppContextRef ctx) { window_init(&window, "pbl-index"); window_set_background_color(&window, GColorBlack); window_stack_push(&window, true); for (int i=0; i<NUM_LINES; i++) { text_layer_init(&textLayer[0][i], GRect(5, 7+i*30, 144-5-COLUMN2_WIDTH, 30)); text_layer_init(&textLayer[1][i], GRect(144-COLUMN2_WIDTH, 7+i*30, COLUMN2_WIDTH, 30)); text_layer_set_font(&textLayer[0][i], fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_font(&textLayer[1][i], fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_background_color(&textLayer[0][i], GColorBlack); text_layer_set_background_color(&textLayer[1][i], GColorBlack); text_layer_set_text_color(&textLayer[0][i], GColorWhite); text_layer_set_text_color(&textLayer[1][i], GColorWhite); text_layer_set_text_alignment(&textLayer[1][i], GTextAlignmentRight); } text_layer_set_text(&textLayer[0][0], "pbl-index"); text_layer_set_text(&textLayer[0][1], "by epatel"); text_layer_set_text(&textLayer[0][3], "loading..."); for (int i=0; i<NUM_LINES; i++) { layer_add_child(&window.layer, &textLayer[0][i].layer); layer_add_child(&window.layer, &textLayer[1][i].layer); } http_set_app_id(PBLINDEX_NAMES_COOKIE); http_register_callbacks((HTTPCallbacks){ .failure = failed, .success = success, .reconnect = reconnect, }, NULL);
void handle_init_app(AppContextRef app_ctx) { window_init(&window, "Less Simple"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); text_layer_init(&date_layer, GRect(PADDING*1.5, PADDING + DATE_TOP_PADDING, SCREEN_WIDTH-PADDING, LINE_HEIGHT)); text_layer_set_text_color(&date_layer, GColorWhite); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); layer_add_child(&window.layer, &date_layer.layer); text_layer_init(&time_layer, GRect(0, PADDING + LINE_HEIGHT*1, SCREEN_WIDTH, LINE_HEIGHT)); text_layer_set_text_color(&time_layer, GColorWhite); text_layer_set_text_alignment(&time_layer, GTextAlignmentCenter); text_layer_set_background_color(&time_layer, GColorClear); text_layer_set_font(&time_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_MEDIUM_NUMBERS)); layer_add_child(&window.layer, &time_layer.layer); text_layer_init(&second_layer, GRect(0, LINE_HEIGHT*2, SCREEN_WIDTH, LINE_HEIGHT)); text_layer_set_text_color(&second_layer, GColorWhite); text_layer_set_text_alignment(&second_layer, GTextAlignmentCenter); text_layer_set_background_color(&second_layer, GColorClear); text_layer_set_font(&second_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_LIGHT)); layer_add_child(&window.layer, &second_layer.layer); // Ensures time is displayed immediately (will break if NULL tick event accessed). // (This is why it's a good idea to have a separate routine to do the update itself.) handle_second_tick(app_ctx, NULL); layer_init(&lineLayer, window.layer.frame); lineLayer.update_proc = &line_layer_update_callback; layer_add_child(&window.layer, &lineLayer); }
// Handle the start-up of the app void handle_init(AppContextRef app_ctx) { // Create our app's base window window_init(&window, "Silly Walk"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); // Set up a layer for the static watch face background bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); layer_add_child(&window.layer, &background_image_container.layer.layer); // Set up a layer for the hour hand rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_HAND_WHITE, RESOURCE_ID_IMAGE_HOUR_HAND_BLACK, &hour_hand_image_container); rotbmp_pair_layer_set_src_ic(&hour_hand_image_container.layer, GPoint(33, 40)); layer_add_child(&window.layer, &hour_hand_image_container.layer.layer); // Set up a layer for the minute hand rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND_WHITE, RESOURCE_ID_IMAGE_MINUTE_HAND_BLACK, &minute_hand_image_container); rotbmp_pair_layer_set_src_ic(&minute_hand_image_container.layer, GPoint(16, 60)); layer_add_child(&window.layer, &minute_hand_image_container.layer.layer); PblTm t; get_time(&t); update_watch(&t); }
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); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Modern Watch"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); #if DISPLAY_DATE_ANALOG bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_DATEBOX, &background_image_container); #elif INVERTED bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_INVERTED, &background_image_container); #else bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); #endif layer_add_child(&window.layer, &background_image_container.layer.layer); #if DISPLAY_DATE_ANALOG date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_MEDIUM_12)); text_layer_init(&date_layer, GRect(116, 77, 20, 20)); #else date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITALDREAM_NARROW_12)); text_layer_init(&date_layer, GRect(27, 110, 90, 30)); #endif #if DISPLAY_DATE_ANALOG text_layer_set_text_color(&date_layer, GColorBlack); #elif INVERTED text_layer_set_text_color(&date_layer, GColorBlack); #else text_layer_set_text_color(&date_layer, GColorWhite); #endif text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter); text_layer_set_background_color(&date_layer, GColorClear); text_layer_set_font(&date_layer, date_font); layer_add_child(&window.layer, &date_layer.layer); draw_date(); layer_init(&hour_display_layer, window.layer.frame); hour_display_layer.update_proc = &hour_display_layer_update_callback; layer_add_child(&window.layer, &hour_display_layer); gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS); gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame)); layer_init(&minute_display_layer, window.layer.frame); minute_display_layer.update_proc = &minute_display_layer_update_callback; layer_add_child(&window.layer, &minute_display_layer); gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS); gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame)); layer_init(¢er_display_layer, window.layer.frame); center_display_layer.update_proc = ¢er_display_layer_update_callback; layer_add_child(&window.layer, ¢er_display_layer); #if DISPLAY_SECONDS layer_init(&second_display_layer, window.layer.frame); second_display_layer.update_proc = &second_display_layer_update_callback; layer_add_child(&window.layer, &second_display_layer); #endif }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Hebrew Text"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); // If you neglect to call this, all `resource_get_handle()` requests // will return NULL. resource_init_current_app(&RESOURCES); font42 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SIMPLE_42)); font36 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SIMPLE_36)); font28 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SIMPLE_28)); text_layer_init(&timeLayer, GRect(0, 0, window.layer.frame.size.w, window.layer.frame.size.h)); text_layer_set_text_color(&timeLayer, GColorWhite); text_layer_set_text_alignment(&timeLayer, GTextAlignmentRight); text_layer_set_background_color(&timeLayer, GColorClear); handle_minute_tick(ctx, NULL); layer_add_child(&window.layer, &timeLayer.layer); }
static void handle_init(AppContextRef ctx) { (void) ctx; window_init(&s_data.window, "Clock_Window"); const bool animated = true; window_stack_push(&s_data.window, animated); window_set_background_color(&s_data.window, GColorBlack); resource_init_current_app(&APP_RESOURCES); //GFont gotham = fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD); GFont fontPlain = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SANSATION_LIGHT_42)); GFont fontBold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_SANSATION_BOLD_42)); text_layer_init(&s_data.label, GRect(0, 0, s_data.window.layer.frame.size.w, 100)); text_layer_init(&s_data.label2, GRect(0, 37, s_data.window.layer.frame.size.w, s_data.window.layer.frame.size.h - 37)); text_layer_set_background_color(&s_data.label, GColorClear); text_layer_set_background_color(&s_data.label2, GColorClear); text_layer_set_text_color(&s_data.label, GColorWhite); text_layer_set_text_color(&s_data.label2, GColorWhite); text_layer_set_font(&s_data.label, fontBold); text_layer_set_font(&s_data.label2, fontPlain); layer_add_child(&s_data.window.layer, &s_data.label.layer); layer_add_child(&s_data.window.layer, &s_data.label2.layer); PblTm t; get_time(&t); update_time(&t); }
void handle_init(AppContextRef ctx) { window_init(&window, "Simplicity"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); layer_init(&time_layer, GRect(0, 12, 144, 168-68)); layer_add_child(&window.layer, &time_layer); text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(8, 0, 144-8, 168-68)); text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&time_layer, &text_date_layer.layer); text_layer_init(&text_time_layer, window.layer.frame); text_layer_set_text_color(&text_time_layer, GColorWhite); text_layer_set_background_color(&text_time_layer, GColorClear); layer_set_frame(&text_time_layer.layer, GRect(7, 24, 144-7, 168-92)); text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49))); layer_add_child(&time_layer, &text_time_layer.layer); layer_init(&line_layer, window.layer.frame); line_layer.update_proc = &line_layer_update_callback; layer_add_child(&time_layer, &line_layer); layer_init(&car_layer, GRect(0, 90, 144, 168-90)); layer_add_child(&window.layer, &car_layer); text_layer_init(&text_rated_layer, window.layer.frame); text_layer_set_text_color(&text_rated_layer, GColorWhite); text_layer_set_background_color(&text_rated_layer, GColorClear); layer_set_frame(&text_rated_layer.layer, GRect(8, 0, 144-8, 168-68)); text_layer_set_font(&text_rated_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&car_layer, &text_rated_layer.layer); text_layer_init(&text_state_layer, window.layer.frame); text_layer_set_text_color(&text_state_layer, GColorWhite); text_layer_set_background_color(&text_state_layer, GColorClear); layer_set_frame(&text_state_layer.layer, GRect(8, 20, 144-8, 168-68)); text_layer_set_font(&text_state_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21))); layer_add_child(&car_layer, &text_state_layer.layer); layer_init(&battery_layer, GRect(72, 10, 144-70, 10)); battery_layer.update_proc = &battery_layer_update_callback; layer_add_child(&car_layer, &battery_layer); Tuplet initial_values[] = { TupletInteger(TESLA_RATED_REMAIN_KEY, (uint16_t) 148), TupletCString(TESLA_STATE_STRING_KEY, "Charging"), TupletInteger(TESLA_BATTERY_PERCENT_KEY, (uint8_t) 72), }; app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL); }
// // sets up the display // void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Simplicity"); window_stack_push(&window, true /* Animated */); window_set_background_color(&window, GColorBlack); resource_init_current_app(&APP_RESOURCES); // // Load the bitmaps // bmp_init_container( RESOURCE_ID_IMAGE_PIC1, &_pic1 ); bmp_init_container( RESOURCE_ID_IMAGE_PIC2, &_pic2 ); bmp_init_container( RESOURCE_ID_IMAGE_PIC3, &_pic3 ); // // create the bitmap layer at the back // bitmap_layer_init( &_currentPicture, GRect(0,0, 144, 168) ); layer_add_child( &window.layer, &_currentPicture.layer ); // // load the font we are using // GFont font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21)); // // create the text layers // setupTextLayer( &_currentDate, &window, 2, 168-21, 144-4, 21, font ); setupTextLayer( &_currentTime, &window, 2, 168-42, 144-4, 21, font ); }
void handle_init(AppContextRef ctx) { memset(&background_image, 0, sizeof(background_image)); memset(&day_name_image, 0, sizeof(day_name_image)); memset(&date_digits_images, 0, sizeof(date_digits_images)); memset(&time_digits_images, 0, sizeof(time_digits_images)); memset(&digits, 0, sizeof(digits)); memset(&display_layer, 0, sizeof(display_layer)); window_init(&window, "LCAR"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image); layer_init(&display_layer, GRect(43, 110, 82, 35)); display_layer.update_proc = &display_layer_update_callback; layer_add_child(&window.layer, &background_image.layer.layer); layer_add_child(&window.layer, &background_image.layer.layer); layer_add_child(&window.layer,&display_layer); // Avoids a blank screen on watch start. PblTm tick_time; get_time(&tick_time); update_display(&tick_time); }
static void handle_init( AppContextRef ctx ) { (void) ctx; window_init(&window, "Main"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); // resource_init_current_app(&RESOURCES); resource_init_current_app(&APP_RESOURCES); int y = 15; int h = 30; font_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_22)); font_thin = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_28)); font_thick = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_BLACK_30)); // Stack top to bottom. Note that the hour can take up // two rows at midnight. text_layer(&m_small_word, GRect(4, y + 3*h+2, 144, h+8), font_small); text_layer(&m_word, GRect(4, y + 3*h, 144, h+8), font_thin); text_layer(&hour_word, GRect(4, y + 2*h-2, 144, 2*h+8), font_thick); text_layer(&rel_small_word, GRect(4, y + 1*h+2, 144, h+8), font_small); text_layer(&rel_word, GRect(4, y + 1*h, 144, h+8), font_thin); text_layer(&min_word, GRect(4, y + 0*h, 144, h+8), font_thin); }
static bool dock_init(WDock *dock, WWindow *parent, const WFitParams *fp) { WFitParams fp2=*fp; dock->pos=dock_param_pos.dflt; dock->grow=dock_param_grow.dflt; dock->is_auto=dock_param_is_auto.dflt; dock->brush=NULL; dock->dockapps=NULL; dock->min_w=1; dock->min_h=1; dock->max_w=1; dock->max_h=1; dock->arrange_called=FALSE; dock->save=TRUE; if(!window_init((WWindow*)dock, parent, &fp2, "WDock")) return FALSE; region_add_bindmap((WRegion*)dock, dock_bindmap); window_select_input(&(dock->win), IONCORE_EVENTMASK_CWINMGR); dock_brush_get(dock); LINK_ITEM(docks, dock, dock_next, dock_prev); return TRUE; }
void handle_init(AppContextRef app_ctx) { app = app_ctx; window_init(&window, "C25K for Pebble"); window_stack_push(&window, true ); main_menu_init(&window); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Bar Graph"); window_stack_push(&window, true /* Animated */); resource_init_current_app(&APP_RESOURCES); bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage); layer_add_child(&window.layer, &faceImage.layer.layer); layer_init(&hourLayer, window.layer.frame); hourLayer.update_proc = &update_hour; layer_add_child(&window.layer, &hourLayer); layer_init(&minLayer, window.layer.frame); minLayer.update_proc = &update_minute; layer_add_child(&window.layer, &minLayer); text_layer_init(&dateText, GRect(0,138,144,30)); text_layer_set_text_color(&dateText, GColorWhite); text_layer_set_background_color(&dateText, GColorClear); text_layer_set_text_alignment(&dateText, GTextAlignmentCenter); text_layer_set_font(&dateText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_22))); layer_add_child(&window.layer, &dateText.layer); update_date(); }