void menu_cell_draw_other(GContext* ctx, const Layer *cell_layer, const char *title, GBitmap ** icon) { GRect bounds = layer_get_frame(cell_layer); #ifndef PBL_SDK_3 graphics_context_set_text_color(ctx, GColorBlack); #endif graphics_draw_text(ctx, title, FONT_GOTHIC_24_BOLD, GRect(MENU_ICON_SPACE, -4, bounds.size.w-MENU_ICON_SPACE, 4+18), GTextOverflowModeFill, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft), NULL); #ifdef PBL_ROUND uint8_t text_width=graphics_text_layout_get_content_size(title, FONT_GOTHIC_24_BOLD, GRect(MENU_ICON_SPACE, -4, bounds.size.w-MENU_ICON_SPACE, 4+18), GTextOverflowModeFill, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft)).w; if (icon) graphics_draw_bitmap_in_rect(ctx, icon[PBL_IF_SDK_3_ELSE(menu_cell_layer_is_highlighted(cell_layer), 0)], GRect((bounds.size.w-text_width)/2-16-6,(bounds.size.h-16)/2, 16, 16)); #else if (icon) graphics_draw_bitmap_in_rect(ctx, icon[PBL_IF_SDK_3_ELSE(menu_cell_layer_is_highlighted(cell_layer), 0)], GRect(6,(bounds.size.h-16)/2, 16, 16)); #endif }
static void draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *context) { static char title[16]; int i = (int)cell_index->row; if (i == SETTINGS_CHECKBOX_NUM_ROWS) { menu_cell_basic_draw(ctx, cell_layer, SETTINGS_CHECKBOX_SUBMIT_HINT, NULL, NULL); } else { snprintf(title, sizeof(title), "%s", MenuItem[i]); menu_cell_basic_draw(ctx, cell_layer, title, NULL, NULL); // Selected? GBitmap *ptr = s_tick_black_bitmap; if(menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, GColorWhite); ptr = s_tick_white_bitmap; } GRect bounds = layer_get_bounds(cell_layer); GRect bitmap_bounds = gbitmap_get_bounds(ptr); // Draw checkbox GRect r = GRect( bounds.size.w - (2 * SETTINGS_CHECKBOX_BOX_SIZE), (bounds.size.h / 2) - (SETTINGS_CHECKBOX_BOX_SIZE / 2), SETTINGS_CHECKBOX_BOX_SIZE, SETTINGS_CHECKBOX_BOX_SIZE); graphics_draw_rect(ctx, r); if(MenuSelection[cell_index->row]) { graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_draw_bitmap_in_rect(ctx, ptr, GRect(r.origin.x, r.origin.y - 3, bitmap_bounds.size.w, bitmap_bounds.size.h)); } } }
static void draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *context) { if(cell_index->row == CHECKBOX_WINDOW_NUM_ROWS) { // Submit item menu_cell_basic_draw(ctx, cell_layer, "Submit", NULL, NULL); } else { // Choice item static char s_buff[16]; snprintf(s_buff, sizeof(s_buff), "Choice %d", (int)cell_index->row); menu_cell_basic_draw(ctx, cell_layer, s_buff, NULL, NULL); // Selected? GBitmap *ptr = tick_black_bitmap; if(menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, GColorWhite); ptr = tick_white_bitmap; } GRect bounds = layer_get_bounds(cell_layer); GRect bitmap_bounds = gbitmap_get_bounds(ptr); // Draw checkbox GRect r = GRect( bounds.size.w - (2 * CHECKBOX_WINDOW_BOX_SIZE), (bounds.size.h / 2) - (CHECKBOX_WINDOW_BOX_SIZE / 2), CHECKBOX_WINDOW_BOX_SIZE, CHECKBOX_WINDOW_BOX_SIZE); graphics_draw_rect(ctx, r); if(s_selections[cell_index->row]) { graphics_context_set_compositing_mode(ctx, GCompOpSet); graphics_draw_bitmap_in_rect(ctx, ptr, GRect(r.origin.x, r.origin.y - 3, bitmap_bounds.size.w, bitmap_bounds.size.h)); } } }
void menu_cell_draw_job(GContext* ctx, const Layer *cell_layer, const uint8_t index) { GRect bounds = layer_get_frame(cell_layer); // http://newscentral.exsees.com/item/ac0cacd0083161de2ffe8161eb40fa51-15e3726b28defcbc9eb59ade232b5de3 #ifdef PBL_SDK_3 graphics_context_set_compositing_mode(ctx, GCompOpSet); // transparency #else graphics_context_set_text_color(ctx, GColorBlack); #endif #ifdef PBL_ROUND uint8_t name_width=graphics_text_layout_get_content_size(jobs[index].Name, FONT_GOTHIC_24_BOLD, GRect(4+ROUND_MARGIN, -4, bounds.size.w-8-16-2*ROUND_MARGIN, 4+18), GTextOverflowModeFill, GTextAlignmentLeft).w; uint8_t num_width =graphics_text_layout_get_content_size(jobs_get_job_count_as_text(index), FONT_GOTHIC_18, GRect(4+ROUND_MARGIN, 2, bounds.size.w-8-2*ROUND_MARGIN, 14), GTextOverflowModeFill, GTextAlignmentRight).w; uint8_t total_width=name_width+num_width+12; graphics_draw_text(ctx, jobs[index].Name, FONT_GOTHIC_24_BOLD, GRect((bounds.size.w-total_width)/2, -4, name_width, 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL); graphics_draw_text(ctx, jobs_get_job_count_as_text(index), FONT_GOTHIC_18, GRect((bounds.size.w-total_width)/2, 0, total_width, 14), GTextOverflowModeFill, GTextAlignmentRight, NULL); #else graphics_draw_text(ctx, jobs[index].Name, FONT_GOTHIC_24_BOLD, GRect(4+ROUND_MARGIN, -4, bounds.size.w-8-16-2*ROUND_MARGIN, 4+18), GTextOverflowModeFill, GTextAlignmentLeft, NULL); graphics_draw_text(ctx, jobs_get_job_count_as_text(index), FONT_GOTHIC_18, GRect(4+ROUND_MARGIN, 0, bounds.size.w-8-2*ROUND_MARGIN, 14), GTextOverflowModeFill, GTextAlignmentRight, NULL); #endif char* stickers=jobs[index].Stickers; // always returns a zero padded string if (*stickers) { while (*(stickers+EMOJI_CHILD_COLS)) stickers+=EMOJI_CHILD_COLS; #ifdef PBL_ROUND uint8_t n=0; while (stickers[n]) n++; #endif uint8_t cell = (bounds.size.w-2*ROUND_MARGIN) / EMOJI_CHILD_COLS; uint8_t marg = (cell - EMOJI_WIDTH)/2+1+PBL_IF_ROUND_ELSE(ROUND_MARGIN+(EMOJI_CHILD_COLS-n)*cell/2, 0); uint8_t i=0; while (*stickers) { uint8_t emoji=*stickers-1; graphics_draw_bitmap_in_rect(ctx, EMOJI_INDEX(emoji, PBL_IF_SDK_3_APLITE_ELSE(menu_cell_layer_is_highlighted(cell_layer), 0)), GRect(marg+cell*(i++),23, EMOJI_WIDTH, EMOJI_HEIGHT)); stickers++; } } else { graphics_draw_text(ctx, "PRESS to add sticker", FONT_GOTHIC_14, GRect(4, 20, bounds.size.w-8, 16), GTextOverflowModeFill, GTextAlignmentCenter, NULL); if (!job_menu_visible()) graphics_draw_text(ctx, "HOLD to edit", FONT_GOTHIC_14, GRect(4, 36, bounds.size.w-8, 16), GTextOverflowModeFill, GTextAlignmentCenter, NULL); } }
static void menuDrawRow(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context) { if (cell_index->row >= activeListCount) return; GRect cell_bounds = layer_get_bounds(cell_layer); if (isRound) { // Add some padding so text is not clipped cell_bounds.origin.x += 6; cell_bounds.size.w -= 12; } if (activeList[cell_index->row].status == STATUS_BOUGHT) { graphics_context_set_stroke_width(ctx, 3); if (menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, GColorWhite); } else { graphics_context_set_stroke_color(ctx, GColorBlack); } GPoint pt; pt.x = cell_bounds.origin.x + 2; pt.y = cell_bounds.size.h / 2 - 8; gpath_move_to(checkboxPath, pt); gpath_draw_outline_open(ctx, checkboxPath); cell_bounds.origin.x += 20; cell_bounds.size.w -= 20; } graphics_draw_text(ctx, activeList[cell_index->row].name, font, cell_bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); }
static void multi_code_menu_draw_row_callback(GContext *ctx, Layer *cell_layer, MenuIndex *cell_index, void *context) { GRect bounds = layer_get_bounds(cell_layer); graphics_context_set_fill_color(ctx, bg_color); graphics_context_set_text_color(ctx, fg_color); #ifdef PBL_COLOR if (menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_fill_color(ctx, fg_color); graphics_context_set_text_color(ctx, bg_color); graphics_fill_rect(ctx, bounds, 0, 0); } #endif if (watch_otp_count >= 1) { graphics_draw_text(ctx, generateCode(otp_keys[cell_index->row], timezone_offset), font_pin.font, GRect(0, pin_origin_y, bounds.size.w, 30), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL); graphics_draw_text(ctx, otp_labels[cell_index->row], fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(0, 30, bounds.size.w, 25), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL); } else { graphics_draw_text(ctx, "123456", font_pin.font, GRect(0, pin_origin_y, bounds.size.w, 30), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL); graphics_draw_text(ctx, "EMPTY", fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect(0, 30, bounds.size.w, 25), GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, NULL); } }
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) { GRect bounds = layer_get_bounds(cell_layer); GPoint p = GPoint(bounds.size.w - 15, (bounds.size.h / 2)); switch (cell_index->row) { case 0: menu_cell_basic_draw(ctx, cell_layer, "2k steps/day", NULL, NULL); break; case 1: menu_cell_basic_draw(ctx, cell_layer, "4k steps/day", NULL, NULL); break; case 2: menu_cell_basic_draw(ctx, cell_layer, "6k steps/day", NULL, NULL); break; case 3: menu_cell_basic_draw(ctx, cell_layer, "8k steps/day", NULL, NULL); break; case 4: menu_cell_basic_draw(ctx, cell_layer, "10k steps/day", NULL, NULL); break; case 5: menu_cell_basic_draw(ctx, cell_layer, "15k steps/day", NULL, NULL); break; case 6: menu_cell_basic_draw(ctx, cell_layer, "20k steps/day", NULL, NULL); break; } graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_fill_color(ctx, GColorFolly); if (menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, GColorWhite); } graphics_draw_circle(ctx, p, 7); if (cell_index->row == getStepGoal()) { graphics_fill_circle(ctx, p, 5); } }
static void draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *context) { if(cell_index->row == num_rows) { // This is the submit item menu_cell_basic_draw(ctx, cell_layer, "Submit", NULL, NULL); } else { // This is a choice item static char *s_buff; #ifdef CHESS if (cell_index->row == CHESS_EASY) { s_buff = "Easy"; } else if (cell_index->row == CHESS_HARD) { s_buff = "Hard"; } #endif menu_cell_basic_draw(ctx, cell_layer, s_buff, NULL, NULL); // get bounds and set point GRect bounds = layer_get_bounds(cell_layer); GPoint p = GPoint(bounds.size.w - (3 * RADIO_BUTTON_WINDOW_RADIO_RADIUS), (bounds.size.h / 2)); // Selected? if(menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, GColorWhite); graphics_context_set_fill_color(ctx, GColorWhite); } else { graphics_context_set_fill_color(ctx, GColorBlack); } // Draw radio filled/empty graphics_draw_circle(ctx, p, RADIO_BUTTON_WINDOW_RADIO_RADIUS); if(cell_index->row == s_current_selection) { // This is the selection graphics_fill_circle(ctx, p, RADIO_BUTTON_WINDOW_RADIO_RADIUS - 3); } } }
static void draw_row_callback(GContext *ctx, Layer *cell_layer, MenuIndex *idx, void *context) { GRect bounds = layer_get_bounds(cell_layer); #if defined(PBL_ROUND) // get info of pixel row in the middle of menu row GBitmap *fb = graphics_capture_frame_buffer(ctx); GPoint sc_coord = layer_convert_point_to_screen(cell_layer, GPoint(0, bounds.size.h/2)); GBitmapDataRowInfo info = gbitmap_get_data_row_info(fb, sc_coord.y); graphics_release_frame_buffer(ctx, fb); // adapt bounds for round displays bounds.origin.x = info.min_x + PADDING; bounds.size.w = info.max_x - info.min_x - PADDING; #endif GRect frame = GRect( bounds.origin.x + ICON_SIZE + 3*PADDING, 0, bounds.size.w - 2*ICON_SIZE - PADDING, bounds.size.h/2 ); // draw direction // expand frame width if countdown on the right is small if(deps_items[idx->row].countdown > 0 && deps_items[idx->row].countdown < 10) { frame.size.w += 10; } graphics_draw_text(ctx, deps_items[idx->row].direction, fonts_get_system_font(FONT_KEY_GOTHIC_14), frame, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); // draw time of scheduled departure plus delay frame.origin.y += 12; graphics_draw_text(ctx, deps_items[idx->row].time, fonts_get_system_font(FONT_KEY_GOTHIC_18), frame, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); // draw time until real time departure frame.origin.x = bounds.origin.x + bounds.size.w - ICON_SIZE - PADDING; frame.origin.y = 0; frame.size.w = ICON_SIZE; frame.size.h = ICON_SIZE; if(deps_items[idx->row].countdown == 0) { // draw icon if departure is imminent char* icon_number; if (strcmp(deps_items[idx->row].icon, "bus") == 0) { icon_number = "1"; } else if (strcmp(deps_items[idx->row].icon, "tram") == 0) { icon_number = "2"; } else if (strcmp(deps_items[idx->row].icon, "train") == 0) { icon_number = "3"; } else if (strcmp(deps_items[idx->row].icon, "boat") == 0) { icon_number = "4"; } else if (strcmp(deps_items[idx->row].icon, "funicular") == 0) { icon_number = "5"; } else if (strcmp(deps_items[idx->row].icon, "cable_car") == 0) { icon_number = "6"; } else { icon_number = ""; } frame.origin.x = bounds.origin.x + bounds.size.w - ICON_SIZE; frame.origin.y = 0; frame.size.w = ICON_SIZE+2; frame.size.h = ICON_SIZE; graphics_draw_text(ctx, icon_number, s_icons, frame, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL); } else { static char s_buff[16]; if(deps_items[idx->row].countdown > 60) { strncpy(s_buff, ">1h", 16); } else if(deps_items[idx->row].countdown > 0) { snprintf(s_buff, sizeof(s_buff), "%d'", deps_items[idx->row].countdown); } graphics_draw_text(ctx, s_buff, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), frame, GTextOverflowModeFill, GTextAlignmentRight, NULL); } // draw line icon with colors frame.origin.x = bounds.origin.x + PADDING; frame.origin.y = (bounds.size.h / 2) - (ICON_SIZE / 2); frame.size.w = ICON_SIZE; frame.size.h = ICON_SIZE; GColor color_bg; // correct some coloring switch(deps_items[idx->row].color_bg) { case 9090335 : color_bg = GColorSpringBud; break; case 12703135 : color_bg = GColorInchworm; break; default : color_bg = GColorFromHEX(deps_items[idx->row].color_bg); } GColor color_fg = GColorFromHEX(deps_items[idx->row].color_fg); graphics_context_set_fill_color(ctx, COLOR_FALLBACK(color_bg, GColorClear)); graphics_fill_rect(ctx, frame, 3, GCornersAll); if(!gcolor_equal(color_bg, GColorWhite) || menu_cell_layer_is_highlighted(cell_layer)) { graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorWhite, GColorClear)); } graphics_draw_round_rect(ctx, frame, 3); graphics_context_set_text_color(ctx, COLOR_FALLBACK(color_fg, GColorBlack)); char * name = deps_items[idx->row].name; GFont font; if(strlen(name) == 1) { frame.origin.x += 1; frame.origin.y += 3; /*font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);*/ font = s_helvetic_bold; } else if(strlen(name) == 2) { // correct position if 2nd digit is "1" if (strstr(name+1, "1") != NULL) { frame.origin.x += 2; } frame.origin.y += 3; /*font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);*/ font = s_helvetic_bold; /*if(strlen(name) == 1) { frame.origin.x += 1; }*/ } else if(strlen(name) == 3){ frame.origin.y += 3; font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); } else { frame.origin.y += 6; font = fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD); } graphics_draw_text(ctx, name, font, frame, GTextOverflowModeFill, GTextAlignmentCenter, NULL); }