void update_battery_level_display() { if (!battery_level_layer) return; GRect bounds = layer_get_frame(battery_level_layer); int third = (bounds.size.h - 4) / 3; //height of screen //int y = third * 33 / 100; //DEBUG int y = third * m_sBattState.charge_percent / 100; to_rect[5] = layer_get_frame(battery_level_layer); to_rect[4] = layer_get_frame(battery_level_layer); if (m_sBattState.is_charging) { to_rect[5].origin.y = -(2 + 3*third); //from to_rect[4].origin.y = -(2 + 3*third) + y; //Note: charge_percent seems incorrect when charging! (e.g. shows 10% instead of 60% actual capacity). } else { to_rect[5].origin.y = -2; //from to_rect[4].origin.y = -2 - y; } if (animations[4]) { property_animation_destroy(animations[4]); animations[4] = NULL; } animations[4] = property_animation_create_layer_frame(battery_level_layer, &to_rect[5], &to_rect[4]); animation_set_duration((Animation*) animations[4], 1500); animation_schedule((Animation*) animations[4]); }
static void menu_draw_header_callback(GContext* ctx, const Layer *cell_layer, uint16_t section_index, void *data) { // Draw title text in the section header graphics_context_set_fill_color(ctx, GColorWhite); graphics_fill_rect(ctx, layer_get_frame(cell_layer), 1, GCornersAll); graphics_context_set_text_color(ctx, GColorBlack); graphics_draw_text(ctx, "OTAKU", fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), layer_get_frame(cell_layer), GTextOverflowModeFill, GTextAlignmentCenter, NULL); }
void show_expanded() { destroy_animations(); Layer* current_card = (current%2 == 0)?card_layer_A:card_layer_B; int card_height = layer_get_frame(current_card).size.h; GRect card_from = layer_get_frame(current_card); GRect card_to = GRect(0,EXPAND_SIZE-card_from.size.h,144,card_from.size.h); GRect expanded_from = GRect(0,168, 144, 168-EXPAND_SIZE); GRect expanded_to = GRect(0, EXPAND_SIZE, 144, 168-EXPAND_SIZE); //animate card card_animation_old = property_animation_create_layer_frame(current_card, &card_from, &card_to); animation_set_curve((Animation*) card_animation_old, AnimationCurveEaseOut); animation_set_duration((Animation*) card_animation_old, 300); animation_schedule((Animation*) card_animation_old); //animate expanded layer expanded_animation = property_animation_create_layer_frame(expanded_layer, &expanded_from, &expanded_to); animation_set_curve((Animation*) expanded_animation, AnimationCurveEaseOut); animation_set_duration((Animation*) expanded_animation, 300); animation_schedule((Animation*) expanded_animation); expanded_visible = 1; }
static void hands_update_proc(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); GPoint center = grect_center_point(&bounds); const int16_t hourHandLength = bounds.size.w / 2 +20; const int16_t minuteHandLength = hourHandLength - 30; GPoint minuteHand; center.y +=20; time_t now = time(NULL); struct tm *t = localtime(&now); for (int i=0;i<12;i++) { int16_t minute_angle = TRIG_MAX_ANGLE * (((59-t->tm_min)+i*5)%60) / 60; minuteHand.y = (int16_t)(-cos_lookup(minute_angle) * (int32_t)minuteHandLength / TRIG_MAX_RATIO) + center.y; minuteHand.x = (int16_t)(sin_lookup(minute_angle) * (int32_t)minuteHandLength / TRIG_MAX_RATIO) + center.x; GRect frame = layer_get_frame(text_layer_get_layer(num_layer[i])); frame.origin.x = minuteHand.x-frame.size.w/2; frame.origin.y = minuteHand.y-frame.size.h/2; layer_set_frame(text_layer_get_layer(num_layer[i]),frame); layer_set_hidden(text_layer_get_layer(num_layer[i]),false); int16_t hour_angle = (TRIG_MAX_ANGLE * (((24-t->tm_hour+i) % 12) * 6) + ((TRIG_MAX_ANGLE * (60-t->tm_min)) / 10)) / (12 * 6); minuteHand.y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)hourHandLength / TRIG_MAX_RATIO) + center.y; minuteHand.x = (int16_t)(sin_lookup(hour_angle) * (int32_t)hourHandLength / TRIG_MAX_RATIO) + center.x; frame = layer_get_frame(text_layer_get_layer(hour_layer[i])); frame.origin.x = minuteHand.x-frame.size.w/2; frame.origin.y = minuteHand.y-frame.size.h/2; layer_set_frame(text_layer_get_layer(hour_layer[i]),frame); layer_set_hidden(text_layer_get_layer(hour_layer[i]),false); } // draw minute line if(getDrawline()) { if(getInvert()) graphics_context_set_stroke_color(ctx,GColorWhite); else graphics_context_set_stroke_color(ctx,GColorBlack); graphics_draw_line(ctx,GPoint(144/2,0),GPoint(144/2,167)); } // draw background transbitmap_draw_in_rect(background_bitmap, ctx, bounds); // draw date if(draw_date) { graphics_context_set_fill_color(ctx,GColorBlack); graphics_fill_circle(ctx,GPoint(120,120),16); layer_set_hidden(text_layer_get_layer(date_layer),false); } else layer_set_hidden(text_layer_get_layer(date_layer),true); }
void layer_center_in_parent(Layer *layer) { if (!layer || !layer->parent) return; GRect frame = layer_get_frame(layer); GRect parent_frame = layer_get_frame(layer->parent); layer_set_frame(layer, grect_center_rect(&frame, &parent_frame)); }
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 moveTextLayers(int workingTextLayerY, int timeTextLayerY) { GRect frame; frame = layer_get_frame(text_layer_get_layer(app.workingTextLayer)); frame.origin.y = workingTextLayerY; layer_set_frame(text_layer_get_layer(app.workingTextLayer), frame); frame = layer_get_frame(text_layer_get_layer(app.timeTextLayer)); frame.origin.y = timeTextLayerY; layer_set_frame(text_layer_get_layer(app.timeTextLayer), frame); }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); APP_LOG(APP_LOG_LEVEL_DEBUG, "window height = %d", layer_get_frame(window_layer).size.h); s_action_bar = action_bar_layer_create(); action_bar_layer_add_to_window(s_action_bar, window); action_bar_layer_set_click_config_provider(s_action_bar, click_config_provider); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_plus); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_minus); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_done); int width = layer_get_frame(window_layer).size.w - ACTION_BAR_WIDTH - 3; // Header Text Layer s_header_layer = text_layer_create(GRect(4, 0, width, 60)); text_layer_set_font(s_header_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_background_color(s_header_layer, GColorClear); text_layer_set_text(s_header_layer, "Mood Tracker"); layer_add_child(window_layer, text_layer_get_layer(s_header_layer)); // Body Text Layer s_body_layer = text_layer_create(GRect(4, 44, width, 60)); text_layer_set_font(s_body_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_background_color(s_body_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(s_body_layer)); // Label Text Layer s_label_layer = text_layer_create(GRect(4, 44 + 28, width, 60)); text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18)); text_layer_set_background_color(s_label_layer, GColorClear); text_layer_set_text(s_label_layer, "of mood today"); layer_add_child(window_layer, text_layer_get_layer(s_label_layer)); #ifdef PBL_COLOR // Set the Window background color to a color that is similar to hospital // walls window_set_background_color(window, GColorCadetBlue); // Set the actionbar background color to a color that is similar to medical // staff uniforms action_bar_layer_set_background_color(s_action_bar, GColorCobaltBlue); text_layer_set_text_color(s_header_layer, GColorBlack); text_layer_set_text_color(s_body_layer, GColorBlack); text_layer_set_text_color(s_label_layer, GColorBlack); #endif update_text(); }
static void gui_layer_bg_update(Layer *layer, GContext *ctx) { graphics_context_set_fill_color(ctx, c_bg); graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone); int width = layer_get_frame(layer).size.w; int height = layer_get_frame(layer).size.h; graphics_context_set_stroke_color(ctx, PBL_IF_COLOR_ELSE(GColorLightGray, GColorBlack)); graphics_context_set_stroke_width(ctx, 1); graphics_draw_line(ctx, GPoint(PADDING_X, height/2-10), GPoint(width-PADDING_X, height/2-10)); graphics_draw_line(ctx, GPoint(PADDING_X, height/2+10), GPoint(width-PADDING_X, height/2+10)); }
//Individual drug window handlers. static void ind_drug_window_load(Window *window) { //Initialize the TextLayer that will contain the drug information. GRect bounds = layer_get_frame(window_get_root_layer(window)); s_ind_drug_info_text_layer = text_layer_create(GRect(0,0,bounds.size.w,2000)); text_layer_set_font(s_ind_drug_info_text_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text(s_ind_drug_info_text_layer,s_drug_information); //Create the scroll layer. s_ind_drug_info_scroll_layer = scroll_layer_create(layer_get_frame(window_get_root_layer(window))); //Sets the up and down button actions to scrolling actions. scroll_layer_set_click_config_onto_window(s_ind_drug_info_scroll_layer,window); //Sets the select button to activate code mode. scroll_layer_set_callbacks(s_ind_drug_info_scroll_layer,(ScrollLayerCallbacks) {.click_config_provider=ind_drug_window_click_config_provider});
static void update_date_format() { GRect rect = layer_get_frame(text_layer_get_layer(date_text)); rect.origin.x = dateFormats[dateStyle].dx; layer_set_frame(text_layer_get_layer(date_text), rect); rect = layer_get_frame(text_layer_get_layer(month_text)); rect.origin.x = dateFormats[dateStyle].mx; layer_set_frame(text_layer_get_layer(month_text), rect); rect = layer_get_frame(text_layer_get_layer(year_text)); rect.origin.x = dateFormats[dateStyle].yx; layer_set_frame(text_layer_get_layer(year_text), rect); }
static void handle_second_tick(struct tm* tick_time, TimeUnits units_changed) { static int day_m = 40; static int hour_m = 33; static int min_m = 77; static bool clock24 = false; if (clock24 != clock_is_24h_style()) { clock24 = clock_is_24h_style(); for (int slot_number = 4; slot_number < TOTAL_IMAGE_SLOTS; slot_number++) { GRect bounds = layer_get_frame(bitmap_layer_get_layer(digit_slot[slot_number])); if (clock24) { bounds.origin.y = 19; } else { bounds.origin.y = 35; } layer_set_frame(bitmap_layer_get_layer(digit_slot[slot_number]), bounds); } GRect bounds = layer_get_frame(text_layer_get_layer(date_layer)); if (clock24) { bounds.origin.y = 52; } else { bounds.origin.y = 62; } layer_set_frame(text_layer_get_layer(date_layer), bounds); layer_set_hidden((Layer *)ampm_layer, clock24); } if (day_m != tick_time->tm_mday) { day_m = tick_time->tm_mday; update_date(tick_time); text_layer_set_text(date_layer, date_text); } if (hour_m != tick_time->tm_hour) { hour_m = tick_time->tm_hour; display_value(get_display_hour(tick_time->tm_hour), 0, true); if (!clock_is_24h_style()) { if (hour_m >=12) { text_layer_set_text(ampm_layer, "PM"); } else { text_layer_set_text(ampm_layer, "AM"); } } } if (min_m != tick_time->tm_min) { min_m = tick_time->tm_min; display_value(tick_time->tm_min, 1, true); } display_value(tick_time->tm_sec, 2, true); }
// ------------------------------------------------------------------------ // // Main Functions // ------------------------------------------------------------------------ // static void main_window_load(Window *window) { Layer *root_layer = window_get_root_layer(window); window_set_background_color(main_window, GColorBlack); window_set_click_config_provider(main_window, click_config_provider); dither_layer = layer_create(layer_get_frame(root_layer)); // fullscreen // dither_layer = layer_create(GRect((layer_get_bounds(root_layer).size.w - 100) / 2,20,100,100)); // Non-fullscreen // dither_layer = layer_create(GRect( 100,20,100,100)); // testing out-of-bounds layer_add_child(root_layer, dither_layer); layer_set_update_proc(dither_layer, dither_layer_update); text_layer = layer_create(layer_get_frame(root_layer)); layer_add_child(root_layer, text_layer); layer_set_update_proc(text_layer, text_layer_update); }
// main window loading (initialisation) static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect frame = layer_get_frame(window_layer); // Create GFonts s_time_font_dte = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_AERO_28)); // Initial time (00:00) load_time_images(); // Create and add the time TextLayer DTE s_time_layer_dte = text_layer_create(GRect(x0, y0 + 96, 144, 32)); text_layer_set_background_color(s_time_layer_dte, GColorBlack); text_layer_set_text_color(s_time_layer_dte, GColorWhite); text_layer_set_text(s_time_layer_dte, "Ddd 00 Mmm"); text_layer_set_font(s_time_layer_dte, s_time_font_dte); text_layer_set_text_alignment(s_time_layer_dte, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer_dte)); // Create and add a line Canvas Layer s_canvas_layer = layer_create(frame); layer_set_update_proc(s_canvas_layer, layer_update_callback); layer_add_child(window_layer, s_canvas_layer); // Create and add a Bitmap Layer for BT Signal warning s_warning_img_layer = bitmap_layer_create(GRect(x0, y0 + 132, 144, 32)); s_warning_bitmap = gbitmap_create_with_resource(RESOURCE_ID_WARN28); bitmap_layer_set_bitmap(s_warning_img_layer, s_warning_bitmap); layer_add_child(window_layer, bitmap_layer_get_layer(s_warning_img_layer)); }
void menu_cell_basic_draw_multiline_with_extra_title(GContext* ctx, const Layer *cell_layer, char *title, char *right_title, char *subtitle, GBitmap *icon) { GRect bounds = layer_get_frame(cell_layer); graphics_context_set_text_color (ctx, GColorBlack); // Line 1 if (icon != NULL) { graphics_draw_bitmap_in_rect(ctx, icon, GRect(2, 2, 20, 20)); } graphics_draw_text(ctx, title, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), GRect(26, -5, bounds.size.w - 5, 26), GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); graphics_draw_text(ctx, right_title, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(bounds.size.w/2, 16, bounds.size.w/2 - 5, 26), GTextOverflowModeWordWrap, GTextAlignmentRight, NULL); // Line 2 graphics_draw_text(ctx, subtitle, fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(5, 21, bounds.size.w-10, 40), GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL); }
void blocks_update_callback(Layer *layer, GContext *ctx) { (void)layer; (void)ctx; GRect block_rect[2]; GRect layer_bounds = layer_get_bounds(layer); GRect layer_frame = layer_get_frame(layer); block_rect[0] = GRect(layer_bounds.origin.x, layer_bounds.origin.y + BLOCK_LAYER_EXTRA, BLOCK_SIZE, layer_frame.size.h - BLOCK_LAYER_EXTRA); block_rect[1] = GRect(layer_bounds.origin.x + BLOCK_SIZE + BLOCK_SPACING, layer_bounds.origin.y + BLOCK_LAYER_EXTRA, BLOCK_SIZE, layer_frame.size.h - BLOCK_LAYER_EXTRA); for (uint8_t i = 0; i < 2; ++i) { GRect *rect = block_rect + i; draw_block(ctx, *rect, 4); } }
void handle_init() { window = window_create(); Layer *window_layer = window_get_root_layer(window); GRect windowFrame = layer_get_frame(window_layer); int16_t aThird = windowFrame.size.h / 3; GRect textFrame; textFrame.origin.x = 0; textFrame.origin.y = 0; textFrame.size.w = windowFrame.size.w; textFrame.size.h = aThird; textFrame.origin.y = aThird; statusTextLayer = text_layer_create( textFrame ); text_layer_set_text(statusTextLayer, STATUS_READY); text_layer_set_text_alignment(statusTextLayer, GTextAlignmentLeft); text_layer_set_font(statusTextLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); layer_add_child( window_layer, text_layer_get_layer( statusTextLayer ) ); init_app_message(); WindowHandlers handlers = { .load = window_load, .unload = window_unload }; window_set_window_handlers(window, handlers); window_stack_push(window, true /* Animated */); }
static void main_window_load(Window *window) { // Here we load the bitmap assets /* s_menu_icons[0] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MENU_ICON_BIG_WATCH); s_menu_icons[1] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MENU_ICON_SECTOR_WATCH); s_menu_icons[2] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MENU_ICON_BINARY_WATCH); */ // And also load the background //s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND_BRAINS); //init list of books: int i; for (i=0; i<NUM_FIRST_MENU_ITEMS; i++){ snprintf(book_list[i].name, sizeof(book_list[i].name), "Book %d", i+1); } //if data was saved, read it: load_items(); // Now we prepare to initialize the menu layer Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); // Create the menu layer s_menu_layer = menu_layer_create(bounds); menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks){ .get_num_sections = menu_get_num_sections_callback, .get_num_rows = menu_get_num_rows_callback, .get_header_height = menu_get_header_height_callback, .draw_header = menu_draw_header_callback, .draw_row = menu_draw_row_callback, .select_click = menu_select_callback, });
static void init(void) { memset(&time_digits_layers, 0, sizeof(time_digits_layers)); memset(&time_digits_images, 0, sizeof(time_digits_images)); memset(&date_digits_layers, 0, sizeof(date_digits_layers)); memset(&date_digits_images, 0, sizeof(date_digits_images)); memset(&month_digits_layers, 0, sizeof(month_digits_layers)); memset(&month_digits_images, 0, sizeof(month_digits_images)); memset(&year_digits_layers, 0, sizeof(year_digits_layers)); memset(&year_digits_images, 0, sizeof(year_digits_images)); memset(&seconds_digits_layers, 0, sizeof(seconds_digits_layers)); memset(&seconds_digits_images, 0, sizeof(seconds_digits_images)); window = window_create(); if (window == NULL) { APP_LOG(APP_LOG_LEVEL_DEBUG, "OOM: couldn't allocate window"); return; } window_stack_push(window, true /* Animated */); Layer *window_layer = window_get_root_layer(window); background_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); background_layer = bitmap_layer_create(layer_get_frame(window_layer)); bitmap_layer_set_bitmap(background_layer, background_image); layer_add_child(window_layer, bitmap_layer_get_layer(background_layer)); if (!clock_is_24h_style()) { time_format_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_24_HOUR_MODE); GRect frame = (GRect) { .origin = { .x = 17, .y = 68 }, .size = time_format_image->bounds.size }; time_format_layer = bitmap_layer_create(frame); bitmap_layer_set_bitmap(time_format_layer, time_format_image); layer_add_child(window_layer, bitmap_layer_get_layer(time_format_layer)); }
void reposition_new() //reposition current before animation { GRect card_frame = layer_get_frame((current%2==0)?card_layer_A:card_layer_B); card_frame.origin.y = 168; layer_set_frame((current%2==0)?card_layer_A:card_layer_B, card_frame); layer_set_frame((current%2==0)?back_layer_A:back_layer_B, GRect(0,144,144,144)); }
static void draw_strikethrough_on_item(GContext* ctx, Layer* cell_layer, TodoListItem* item) { graphics_context_set_compositing_mode(ctx, GCompOpClear); graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_fill_color(ctx, GColorBlack); GRect cell_bounds = layer_get_frame(cell_layer); static const int menu_cell_margin = 5; GSize text_cell_size = cell_bounds.size; text_cell_size.w -= 2 * menu_cell_margin; GRect text_cell_rect; text_cell_rect.origin = GPointZero; text_cell_rect.size = text_cell_size; GSize max_used_size = graphics_text_layout_get_max_used_size(ctx, item->text, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), text_cell_rect, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); GRect strike_through; strike_through.origin = cell_bounds.origin; strike_through.origin.x += menu_cell_margin; strike_through.origin.y += cell_bounds.size.h / 2; strike_through.size = (GSize) { max_used_size.w, 2 }; // Stretch the strikethrough to be slightly wider than the text static const int pixel_nudge = 2; strike_through.origin.x -= pixel_nudge; strike_through.size.w += 2 * pixel_nudge; graphics_fill_rect(ctx, strike_through, 0, GCornerNone); }
void handle_init() { autoconfig_init(); window = window_create(); window_set_background_color(window, GColorWhite); window_stack_push(window, true); app_message_register_inbox_received(in_received_handler); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); for (int i = 0; i < TOTAL_IMAGE_SLOTS; i++) { bitmaps[i] = NULL; image_containers[i] = bitmap_layer_create(GRect( ((i % 4) * 36), ((i / 4) * 70)+15, 36,70)); layer_add_child(window_layer, bitmap_layer_get_layer(image_containers[i])); } inverter_layer = inverter_layer_create (bounds); layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted()); layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer)); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }
static void initialise_ui(void) { s_window = window_create(); window_set_background_color(s_window, BACKGROUND); Layer *window_layer = window_get_root_layer(s_window); GRect bounds = layer_get_frame(window_layer); s_textlayer_1 = text_layer_create(GRect(0, (bounds.size.h - MESSAGE_HEIGHT) / 2, bounds.size.w, MESSAGE_HEIGHT)); text_layer_set_background_color(s_textlayer_1, GColorClear); text_layer_set_text_color(s_textlayer_1, CHARTCOLOR); text_layer_set_text(s_textlayer_1, "It is time to measure yourself and record your weight!"); text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter); text_layer_set_font(s_textlayer_1, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); layer_add_child(window_layer, (Layer *)s_textlayer_1); s_textlayer_2 = text_layer_create(GRect(0, bounds.size.h - INSTRUCTION_HEIGHT, bounds.size.w, INSTRUCTION_HEIGHT)); text_layer_set_background_color(s_textlayer_2, GColorClear); text_layer_set_text_color(s_textlayer_2, FOREGROUND); text_layer_set_text(s_textlayer_2, "Push Back button for main window"); text_layer_set_text_alignment(s_textlayer_2, GTextAlignmentCenter); text_layer_set_font(s_textlayer_2, fonts_get_system_font(FONT_KEY_GOTHIC_14)); layer_add_child(window_layer, (Layer *)s_textlayer_2); #ifdef PBL_ROUND text_layer_enable_screen_text_flow_and_paging(s_textlayer_2, 4); text_layer_enable_screen_text_flow_and_paging(s_textlayer_1, 4); #endif }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); window_set_background_color(window, GColorBlack); s_ca_layer = layer_create(bounds); layer_set_update_proc(s_ca_layer, ca_update_callback); layer_add_child(window_layer, s_ca_layer); s_time_layer = text_layer_create(GRect(0, 144, 144, 24)); #ifdef PBL_COLOR GColor background_color = GColorDarkGray; GColor text_color = GColorWhite; #else GColor background_color = GColorWhite; GColor text_color = GColorBlack; #endif text_layer_set_background_color(s_time_layer, background_color); text_layer_set_text_color(s_time_layer, text_color); text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); update_time(); }
static void appWindow_load(Window *window) { int num_a_items = 0; first_menu_items[num_a_items++] = (SimpleMenuItem){ // You should give each menu item a title and callback .title = first_string, }; // The menu items appear in the order saved in the menu items array first_menu_items[num_a_items++] = (SimpleMenuItem){ .title = second_string, }; first_menu_items[num_a_items++] = (SimpleMenuItem){ .title = third_string, }; // Bind the menu items to the corresponding menu sections menu_sections[0] = (SimpleMenuSection){ .num_items = NUM_FIRST_MENU_ITEMS, .items = first_menu_items, }; Layer *appWindow_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(appWindow_layer); // Initialize the simple menu layer simple_menu_layer = simple_menu_layer_create(bounds, window, menu_sections, NUM_MENU_SECTIONS, NULL); // Add it to the window for display layer_add_child(appWindow_layer, simple_menu_layer_get_layer(simple_menu_layer)); }
/** * Handles the GUI Initialization */ void window_load (Window *window) { GRect bounds = layer_get_frame(ui.windowLayer); ui.boardLayer = layer_create(bounds); layer_set_update_proc(ui.boardLayer, boxDraw); layer_add_child(ui.windowLayer, ui.boardLayer); //GRect debugBounds = GRect(0, 0, bounds.size.w, 60); // ui.debugLayer = text_layer_create(debugBounds); ui.debugLayer = text_layer_create(bounds); text_layer_set_text_color(ui.debugLayer, GColorBlack); text_layer_set_background_color(ui.debugLayer, GColorClear); text_layer_set_text(ui.debugLayer, "Points: 0"); text_layer_set_font(ui.debugLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(ui.debugLayer, GTextAlignmentCenter); layer_add_child(ui.boardLayer, text_layer_get_layer(ui.debugLayer)); GRect messageBounds = GRect(0, 69, bounds.size.w, 30); ui.messageLayer = text_layer_create(messageBounds); text_layer_set_text_color(ui.messageLayer, GColorWhite); text_layer_set_background_color(ui.messageLayer, GColorBlack); text_layer_set_text(ui.messageLayer, ""); text_layer_set_font(ui.messageLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(ui.messageLayer, GTextAlignmentCenter); layer_add_child(ui.boardLayer, text_layer_get_layer(ui.messageLayer)); layer_set_hidden(text_layer_get_layer(ui.messageLayer), true); }
void reposition_old() //reposition previous before animation { GRect card_frame = layer_get_frame((current%2==1)?card_layer_A:card_layer_B); card_frame.origin.y = 168 - card_frame.size.h; layer_set_frame((current%2==1)?card_layer_A:card_layer_B, card_frame); layer_set_frame((current%2==1)?back_layer_A:back_layer_B, GRect(0,0,144,144)); }
void init(void) { window = window_create(); window_stack_push(window, true /* Animated */); // TODO(dmnd) try another colour window_set_background_color(window, GColorBlack); // TODO(dmnd) try to remember what this does... // init both frames to 2 draw_rect(0, 0, TILES_X, TILES_Y, 2); draw_rect(0, 0, TILES_X, TILES_Y, 2); // Init the layer for the display Layer *root_layer = window_get_root_layer(window); GRect frame = layer_get_frame(root_layer); display_layer = layer_create(frame); layer_set_update_proc(display_layer, &display_layer_update_cb); layer_add_child(root_layer, display_layer); unsigned char units; if (DEBUG) { units = SECOND_UNIT; } else { units = MINUTE_UNIT; } tick_timer_service_subscribe(units, &handle_minute_tick); }
static void card_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); bounds.origin.x = 5; bounds.origin.y = 0; bounds.size.w -= 5; bounds.size.h -= 110; s_free_layer = text_layer_create(bounds); text_layer_set_font(s_free_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); bounds.origin.y += bounds.size.h; bounds.size.h -= 14; s_total_layer = text_layer_create(bounds); text_layer_set_font(s_total_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); bounds.origin.y += bounds.size.h; bounds.size.h += 24; s_name_layer = text_layer_create(bounds); text_layer_set_font(s_name_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24)); text_layer_set_overflow_mode(s_name_layer, GTextOverflowModeWordWrap); layer_add_child(window_layer, text_layer_get_layer(s_free_layer)); layer_add_child(window_layer, text_layer_get_layer(s_total_layer)); layer_add_child(window_layer, text_layer_get_layer(s_name_layer)); card_shown = true; update(); }
void hide_watchface() { destroy_animations(); //watchface_visible = 0; resize_layers(); int card_height = layer_get_frame(card_layer_A).size.h; APP_LOG(APP_LOG_LEVEL_DEBUG, "%d", card_height); GRect card_from = GRect(0,168-MIN_CARD_HEIGHT,144,card_height);//SET THIS TO THE HEIGHT OF CARD TOP GRect card_to = GRect(0,168-card_height,144,card_height); GRect watchface_from = GRect(0,0,144,168); GRect watchface_to = GRect(0,-168,144,168); //animate card card_animation_new = property_animation_create_layer_frame(card_layer_A, &card_from, &card_to); animation_set_curve((Animation*) card_animation_new, AnimationCurveEaseOut); animation_set_duration((Animation*) card_animation_new, 300); animation_schedule((Animation*) card_animation_new); //animate watchface card_animation_old = property_animation_create_layer_frame(watchface_layer, &watchface_from, &watchface_to); animation_set_curve((Animation*) card_animation_old, AnimationCurveLinear); animation_set_duration((Animation*) card_animation_old, 300); animation_schedule((Animation*) card_animation_old); watchface_visible = 0; }