static void gui_quickscreen_draw(const struct gui_quickscreen *qs, struct screen *display, struct viewport *parent, struct viewport vps[QUICKSCREEN_ITEM_COUNT], struct viewport *vp_icons) { int i; char buf[MAX_PATH]; unsigned const char *title, *value; void *setting; int temp; display->set_viewport(parent); display->clear_viewport(); for (i = 0; i < QUICKSCREEN_ITEM_COUNT; i++) { struct viewport *vp = &vps[i]; if (!qs->items[i]) continue; display->set_viewport(vp); display->scroll_stop(vp); title = P2STR(ID2P(qs->items[i]->lang_id)); setting = qs->items[i]->setting; temp = option_value_as_int(qs->items[i]); value = option_get_valuestring(qs->items[i], buf, MAX_PATH, temp); if (viewport_get_nb_lines(vp) < 2) { char text[MAX_PATH]; snprintf(text, MAX_PATH, "%s: %s", title, value); display->puts_scroll(0, 0, text); } else { display->puts_scroll(0, 0, title); display->puts_scroll(0, 1, value); } display->update_viewport(); } /* draw the icons */ display->set_viewport(vp_icons); display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], (vp_icons->width/2) - 4, 0, 7, 8); display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], vp_icons->width - 8, (vp_icons->height/2) - 4, 7, 8); display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 0, (vp_icons->height/2) - 4, 7, 8); display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], (vp_icons->width/2) - 4, vp_icons->height - 8, 7, 8); display->set_viewport(parent); display->update_viewport(); display->set_viewport(NULL); }
const char* skinlist_get_item_text(int offset, bool wrap, char* buf, size_t buf_size) { int item = offset_to_item(offset, wrap); if (item < 0 || !current_list) return NULL; const char* ret = current_list->callback_get_item_name( item, current_list->data, buf, buf_size); return P2STR((unsigned char*)ret); }
static int put_message(struct screen *display, const struct text_message * message, int start, int max_y) { int i; for(i=0; i<message->nb_lines && i+start<max_y; i++) { display->puts_scroll(0, i+start, P2STR((unsigned char *)message->message_lines[i])); } return i; }
void splash(int ticks, const char *str) { #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC long id; /* fmt may be a so called virtual pointer. See settings.h. */ if((id = P2ID((const unsigned char*)str)) >= 0) /* If fmt specifies a voicefont ID, and voice menus are enabled, then speak it. */ cond_talk_ids_fq(id); #endif splashf(ticks, "%s", P2STR((const unsigned char*)str)); }
/* Format a large-range value for output, using the appropriate unit so that * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" * units) if possible, and 3 significant digits are shown. If a buffer is * given, the result is snprintf()'d into that buffer, otherwise the result is * voiced.*/ char *output_dyn_value(char *buf, int buf_size, int value, const unsigned char * const *units, bool bin_scale) { int scale = bin_scale ? 1024 : 1000; int fraction = 0; int unit_no = 0; char tbuf[5]; while (value >= scale) { fraction = value % scale; value /= scale; unit_no++; } if (bin_scale) fraction = fraction * 1000 / 1024; if (value >= 100 || !unit_no) tbuf[0] = '\0'; else if (value >= 10) snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100); else snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10); if (buf) { if (strlen(tbuf)) snprintf(buf, buf_size, "%d%s%s%s", value, str(LANG_POINT), tbuf, P2STR(units[unit_no])); else snprintf(buf, buf_size, "%d%s", value, P2STR(units[unit_no])); } else { talk_fractional(tbuf, value, P2ID(units[unit_no])); } return buf; }
void splashf(int ticks, const char *fmt, ...) { va_list ap; /* If fmt is a lang ID then get the corresponding string (which still might contain % place holders). */ fmt = P2STR((unsigned char *)fmt); FOR_NB_SCREENS(i) { va_start(ap, fmt); splash_internal(&(screens[i]), fmt, ap); va_end(ap); } if (ticks) sleep(ticks); }
static const char * shortcut_menu_get_name(int selected_item, void * data, char * buffer, size_t buffer_len) { (void)data; (void)buffer; (void)buffer_len; struct shortcut *sc = get_shortcut(selected_item); if (!sc) return ""; if (sc->type == SHORTCUT_SETTING) return sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id)); else if (sc->type == SHORTCUT_SEPARATOR || sc->type == SHORTCUT_TIME) return sc->name; else if (sc->type == SHORTCUT_SHUTDOWN && sc->name[0] == '\0') { /* No translation support as only soft_shutdown has LANG_SHUTDOWN defined */ return type_strings[SHORTCUT_SHUTDOWN]; } return sc->name[0] ? sc->name : sc->u.path; }
void list_draw(struct screen *display, struct gui_synclist *list) { struct viewport list_icons; int start, end, line_height, style, i; const int screen = display->screen_type; const int list_start_item = list->start_item[screen]; const int icon_width = get_icon_width(screen) + ICON_PADDING; const bool scrollbar_in_left = (global_settings.scrollbar == SCROLLBAR_LEFT); const bool show_cursor = !global_settings.cursor_style && list->show_selection_marker; struct viewport *parent = (list->parent[screen]); #ifdef HAVE_LCD_COLOR unsigned char cur_line = 0; #endif int item_offset; bool show_title; struct viewport *list_text_vp = &list_text[screen]; line_height = font_get(parent->font)->height; display->set_viewport(parent); display->clear_viewport(); display->scroll_stop(list_text_vp); *list_text_vp = *parent; if ((show_title = draw_title(display, list))) { list_text_vp->y += line_height; list_text_vp->height -= line_height; } const int nb_lines = viewport_get_nb_lines(list_text_vp); start = list_start_item; end = start + nb_lines; #ifdef HAVE_TOUCHSCREEN if (list->selected_item == 0 || (list->nb_items < nb_lines)) y_offset = 0; /* reset in case it's a new list */ int draw_offset = y_offset; /* draw some extra items to not have empty lines at the top and bottom */ if (y_offset > 0) { /* make it negative for more consistent apparence when switching * directions */ draw_offset -= line_height; if (start > 0) start--; } else if (y_offset < 0) end++; #else #define draw_offset 0 #endif /* draw the scrollbar if its needed */ if (global_settings.scrollbar && nb_lines < list->nb_items) { struct viewport vp = *list_text_vp; vp.width = SCROLLBAR_WIDTH; vp.height = line_height * nb_lines; vp.x = parent->x; list_text_vp->width -= SCROLLBAR_WIDTH; if (scrollbar_in_left) list_text_vp->x += SCROLLBAR_WIDTH; else vp.x += list_text_vp->width; display->set_viewport(&vp); gui_scrollbar_draw(display, (scrollbar_in_left? 0: 1), 0, SCROLLBAR_WIDTH-1, vp.height, list->nb_items, list_start_item, list_start_item + nb_lines, VERTICAL); } else if (show_title) { /* shift everything a bit in relation to the title... */ if (!VP_IS_RTL(list_text_vp) && scrollbar_in_left) { list_text_vp->width -= SCROLLBAR_WIDTH; list_text_vp->x += SCROLLBAR_WIDTH; } else if (VP_IS_RTL(list_text_vp) && !scrollbar_in_left) { list_text_vp->width -= SCROLLBAR_WIDTH; } } /* setup icon placement */ list_icons = *list_text_vp; int icon_count = (list->callback_get_item_icon != NULL) ? 1 : 0; if (show_cursor) icon_count++; if (icon_count) { list_icons.width = icon_width * icon_count; list_text_vp->width -= list_icons.width + ICON_PADDING; if (VP_IS_RTL(&list_icons)) list_icons.x += list_text_vp->width + ICON_PADDING; else list_text_vp->x += list_icons.width + ICON_PADDING; } for (i=start; i<end && i<list->nb_items; i++) { /* do the text */ unsigned const char *s; char entry_buffer[MAX_PATH]; unsigned char *entry_name; int text_pos = 0; int line = i - start; s = list->callback_get_item_name(i, list->data, entry_buffer, sizeof(entry_buffer)); entry_name = P2STR(s); display->set_viewport(list_text_vp); style = STYLE_DEFAULT; /* position the string at the correct offset place */ int item_width,h; display->getstringsize(entry_name, &item_width, &h); item_offset = gui_list_get_item_offset(list, item_width, text_pos, display, list_text_vp); #ifdef HAVE_LCD_COLOR /* if the list has a color callback */ if (list->callback_get_item_color) { int color = list->callback_get_item_color(i, list->data); /* if color selected */ if (color >= 0) { style |= STYLE_COLORED|color; } } #endif /* draw the selected line */ if( #ifdef HAVE_TOUCHSCREEN /* don't draw it during scrolling */ scroll_mode == SCROLL_NONE && #endif i >= list->selected_item && i < list->selected_item + list->selected_size && list->show_selection_marker) {/* The selected item must be displayed scrolling */ if (global_settings.cursor_style == 1 #ifdef HAVE_REMOTE_LCD /* the global_settings.cursor_style check is here to make * sure if they want the cursor instead of bar it will work */ || (display->depth < 16 && global_settings.cursor_style) #endif ) { /* Display inverted-line-style */ style = STYLE_INVERT; } #ifdef HAVE_LCD_COLOR else if (global_settings.cursor_style == 2) { /* Display colour line selector */ style = STYLE_COLORBAR; } else if (global_settings.cursor_style == 3) { /* Display gradient line selector */ style = STYLE_GRADIENT; /* Make the lcd driver know how many lines the gradient should cover and current line number */ /* number of selected lines */ style |= NUMLN_PACK(list->selected_size); /* current line number, zero based */ style |= CURLN_PACK(cur_line); cur_line++; } #endif /* if the text is smaller than the viewport size */ if (item_offset> item_width - (list_text_vp->width - text_pos)) { /* don't scroll */ display->puts_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } else { display->puts_scroll_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } } else { if (list->scroll_all) display->puts_scroll_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); else display->puts_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } /* do the icon */ display->set_viewport(&list_icons); if (list->callback_get_item_icon != NULL) { screen_put_icon_with_offset(display, show_cursor?1:0, (line),show_cursor?ICON_PADDING:0,draw_offset, list->callback_get_item_icon(i, list->data)); } if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { screen_put_icon_with_offset(display, 0, line, 0, draw_offset, Icon_Cursor); } } display->set_viewport(parent); display->update_viewport(); display->set_viewport(NULL); }
static void quickscreen_fix_viewports(struct gui_quickscreen *qs, struct screen *display, struct viewport *parent, struct viewport vps[QUICKSCREEN_ITEM_COUNT], struct viewport *vp_icons) { int char_height, width, pad = 0; int left_width = 0, right_width = 0, vert_lines; unsigned char *s; int nb_lines = viewport_get_nb_lines(parent); /* nb_lines only returns the number of fully visible lines, small screens or really large fonts could cause problems with the calculation below. */ if (nb_lines == 0) nb_lines++; char_height = parent->height/nb_lines; /* center the icons VP first */ *vp_icons = *parent; vp_icons->width = CENTER_ICONAREA_SIZE; /* abosulte smallest allowed */ vp_icons->x = parent->x; vp_icons->x += (parent->width-CENTER_ICONAREA_SIZE)/2; vps[QUICKSCREEN_BOTTOM] = *parent; vps[QUICKSCREEN_TOP] = *parent; /* depending on the space the top/buttom items use 1 or 2 lines */ if (nb_lines < MIN_LINES) vert_lines = 1; else vert_lines = 2; vps[QUICKSCREEN_TOP].y = parent->y; vps[QUICKSCREEN_TOP].height = vps[QUICKSCREEN_BOTTOM].height = vert_lines*char_height; vps[QUICKSCREEN_BOTTOM].y = parent->y + parent->height - vps[QUICKSCREEN_BOTTOM].height; /* enough space vertically, so put a nice margin */ if (nb_lines >= MAX_NEEDED_LINES) { vps[QUICKSCREEN_TOP].y += MARGIN; vps[QUICKSCREEN_BOTTOM].y -= MARGIN; } vp_icons->y = vps[QUICKSCREEN_TOP].y + vps[QUICKSCREEN_TOP].height; vp_icons->height = vps[QUICKSCREEN_BOTTOM].y - vp_icons->y; /* adjust the left/right items widths to fit the screen nicely */ if (qs->items[QUICKSCREEN_LEFT]) { s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); left_width = display->getstringsize(s, NULL, NULL); } if (qs->items[QUICKSCREEN_RIGHT]) { s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); right_width = display->getstringsize(s, NULL, NULL); } width = MAX(left_width, right_width); if (width*2 + vp_icons->width > parent->width) { /* crop text viewports */ width = (parent->width - vp_icons->width)/2; } else { /* add more gap in icons vp */ int excess = parent->width - vp_icons->width - width*2; if (excess > MARGIN*4) { pad = MARGIN; excess -= MARGIN*2; } vp_icons->x -= excess/2; vp_icons->width += excess; } vps[QUICKSCREEN_LEFT] = *parent; vps[QUICKSCREEN_LEFT].x = parent->x + pad; vps[QUICKSCREEN_LEFT].width = width; vps[QUICKSCREEN_RIGHT] = *parent; vps[QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad; vps[QUICKSCREEN_RIGHT].width = width; vps[QUICKSCREEN_LEFT].height = vps[QUICKSCREEN_RIGHT].height = 2*char_height; vps[QUICKSCREEN_LEFT].y = vps[QUICKSCREEN_RIGHT].y = parent->y + (parent->height/2) - char_height; /* shrink the icons vp by a few pixels if there is room so the arrows aren't drawn right next to the text */ if (vp_icons->width > CENTER_ICONAREA_SIZE*2) { vp_icons->width -= CENTER_ICONAREA_SIZE*2/3; vp_icons->x += CENTER_ICONAREA_SIZE*2/6; } if (vp_icons->height > CENTER_ICONAREA_SIZE*2) { vp_icons->height -= CENTER_ICONAREA_SIZE*2/3; vp_icons->y += CENTER_ICONAREA_SIZE*2/6; } /* text alignment */ vps[QUICKSCREEN_LEFT].flags &= ~VP_FLAG_ALIGNMENT_MASK; /* left-aligned */ vps[QUICKSCREEN_TOP].flags |= VP_FLAG_ALIGN_CENTER; /* centered */ vps[QUICKSCREEN_BOTTOM].flags |= VP_FLAG_ALIGN_CENTER; /* centered */ vps[QUICKSCREEN_RIGHT].flags &= ~VP_FLAG_ALIGNMENT_MASK;/* right aligned*/ vps[QUICKSCREEN_RIGHT].flags |= VP_FLAG_ALIGN_RIGHT; }
static const char* set_option_formatter(char* buf, size_t size, int item, const char* unit) { (void)buf, (void)unit, (void)size; return P2STR(set_option_options[item].string); }
const char *option_get_valuestring(const struct settings_list *setting, char *buffer, int buf_len, intptr_t temp_var) { const char* str = buffer; if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) { bool val = (bool)temp_var; strlcpy(buffer, str(val? setting->bool_setting->lang_yes : setting->bool_setting->lang_no), buf_len); } #if 0 /* probably dont need this one */ else if ((setting->flags & F_FILENAME) == F_FILENAME) { struct filename_setting *info = setting->filename_setting; snprintf(buffer, buf_len, "%s%s%s", info->prefix, (char*)temp_var, info->suffix); } #endif else if (((setting->flags & F_INT_SETTING) == F_INT_SETTING) || ((setting->flags & F_TABLE_SETTING) == F_TABLE_SETTING)) { const struct int_setting *int_info = setting->int_setting; const struct table_setting *tbl_info = setting->table_setting; const char *unit; const char* (*formatter)(char*, size_t, int, const char*); if ((setting->flags & F_INT_SETTING) == F_INT_SETTING) { formatter = int_info->formatter; unit = unit_strings[int_info->unit]; } else { formatter = tbl_info->formatter; unit = unit_strings[tbl_info->unit]; } if (formatter) str = formatter(buffer, buf_len, (int)temp_var, unit); else snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:""); } else if ((setting->flags & F_T_SOUND) == F_T_SOUND) { char sign = ' '; const char *unit = sound_unit(setting->sound_setting->setting); int val = sound_val2phys(setting->sound_setting->setting, (int)temp_var); if (sound_numdecimals(setting->sound_setting->setting)) { int integer, dec; if(val < 0) { sign = '-'; val = abs(val); } integer = val / 10; dec = val % 10; snprintf(buffer, buf_len, "%c%d.%d %s", sign, integer, dec, unit); } else snprintf(buffer, buf_len, "%d %s", val, unit); } else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) { if (setting->flags & F_CHOICETALKS) { int setting_id; const struct choice_setting *info = setting->choice_setting; if (info->talks[(int)temp_var] < LANG_LAST_INDEX_IN_ARRAY) { strlcpy(buffer, str(info->talks[(int)temp_var]), buf_len); } else { find_setting(setting->setting, &setting_id); cfg_int_to_string(setting_id, (int)temp_var, buffer, buf_len); } } else { int value = (int)temp_var; char *val = P2STR(setting->choice_setting->desc[value]); strlcpy(buffer, val, buf_len); } } return str; }
bool option_screen(const struct settings_list *setting, struct viewport parent[NB_SCREENS], bool use_temp_var, unsigned char* option_title) { int action; bool done = false; struct gui_synclist lists; int oldvalue, nb_items = 0, selected = 0, temp_var; int *variable; bool allow_wrap = setting->flags & F_NO_WRAP ? false : true; int var_type = setting->flags&F_T_MASK; void (*function)(int) = NULL; char *title; if (var_type == F_T_INT || var_type == F_T_UINT) { variable = use_temp_var ? &temp_var: (int*)setting->setting; temp_var = oldvalue = *(int*)setting->setting; } else if (var_type == F_T_BOOL) { /* bools always use the temp variable... if use_temp_var is false it will be copied to setting->setting every change */ variable = &temp_var; temp_var = oldvalue = *(bool*)setting->setting?1:0; } else return false; /* only int/bools can go here */ gui_synclist_init(&lists, value_setting_get_name_cb, (void*)setting, false, 1, parent); if (setting->lang_id == -1) title = (char*)setting->cfg_vals; else title = P2STR(option_title); gui_synclist_set_title(&lists, title, Icon_Questionmark); gui_synclist_set_icon_callback(&lists, NULL); if(global_settings.talk_menu) gui_synclist_set_voice_callback(&lists, option_talk); val_to_selection(setting, oldvalue, &nb_items, &selected, &function); gui_synclist_set_nb_items(&lists, nb_items); gui_synclist_select_item(&lists, selected); gui_synclist_limit_scroll(&lists, true); gui_synclist_draw(&lists); /* talk the item */ gui_synclist_speak_item(&lists); while (!done) { if (list_do_action(CONTEXT_LIST, HZ, /* HZ so the status bar redraws */ &lists, &action, allow_wrap? LIST_WRAP_UNLESS_HELD: LIST_WRAP_OFF)) { /* setting changed */ selected = gui_synclist_get_sel_pos(&lists); *variable = selection_to_val(setting, selected); if (var_type == F_T_BOOL && !use_temp_var) *(bool*)setting->setting = (*variable==1); } else if (action == ACTION_NONE) continue; else if (action == ACTION_STD_CANCEL) { /* setting canceled, restore old value if changed */ if (*variable != oldvalue) { *variable = oldvalue; if (var_type == F_T_BOOL && !use_temp_var) *(bool*)setting->setting = (oldvalue==1); splash(HZ/2, ID2P(LANG_CANCEL)); } done = true; } else if (action == ACTION_STD_CONTEXT) { /* reset setting to default */ reset_setting(setting, variable); if (var_type == F_T_BOOL && !use_temp_var) *(bool*)setting->setting = (*variable==1); val_to_selection(setting, *variable, &nb_items, &selected, &function); gui_synclist_select_item(&lists, selected); gui_synclist_draw(&lists); gui_synclist_speak_item(&lists); } else if (action == ACTION_STD_OK) { /* setting accepted, store now if it used a temp var */ if (use_temp_var) { if (var_type == F_T_INT || var_type == F_T_UINT) *(int*)setting->setting = *variable; else *(bool*)setting->setting = (*variable==1); } settings_save(); done = true; } else if(default_event_handler(action) == SYS_USB_CONNECTED) return true; /* callback */ if ( function ) function(*variable); /* if the volume is changing we need to let the skins know */ if (function == sound_get_fn(SOUND_VOLUME)) global_status.last_volume_change = current_tick; } return false; }
int do_shortcut_menu(void *ignored) { (void)ignored; struct simplelist_info list; struct shortcut *sc; int done = GO_TO_PREVIOUS; if (first_handle == 0) shortcuts_init(); simplelist_info_init(&list, P2STR(ID2P(LANG_SHORTCUTS)), shortcut_count, NULL); list.get_name = shortcut_menu_get_name; list.action_callback = shortcut_menu_get_action; if (global_settings.show_icons) list.get_icon = shortcut_menu_get_icon; list.title_icon = Icon_Bookmark; if (global_settings.talk_menu) list.get_talk = shortcut_menu_speak_item; push_current_activity(ACTIVITY_SHORTCUTSMENU); while (done == GO_TO_PREVIOUS) { if (simplelist_show_list(&list)) break; /* some error happened?! */ if (list.selection == -1) break; else { sc = get_shortcut(list.selection); if (!sc) continue; switch (sc->type) { case SHORTCUT_PLAYLISTMENU: if (!file_exists(sc->u.path)) { splash(HZ, ID2P(LANG_NO_FILES)); break; } else { onplay_show_playlist_menu(sc->u.path); } break; case SHORTCUT_FILE: if (!file_exists(sc->u.path)) { splash(HZ, ID2P(LANG_NO_FILES)); break; } /* else fall through */ case SHORTCUT_BROWSER: { struct browse_context browse; browse_context_init(&browse, global_settings.dirfilter, 0, NULL, NOICON, sc->u.path, NULL); if (sc->type == SHORTCUT_FILE) browse.flags |= BROWSE_RUNFILE; done = rockbox_browse(&browse); } break; case SHORTCUT_SETTING: do_setting_screen(sc->u.setting, sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id)),NULL); break; case SHORTCUT_DEBUGITEM: run_debug_screen(sc->u.path); break; case SHORTCUT_SHUTDOWN: #if CONFIG_CHARGING if (charger_inserted()) charging_splash(); else #endif sys_poweroff(); break; case SHORTCUT_TIME: #if CONFIG_RTC if (sc->u.timedata.talktime) { talk_timedate(); talk_force_enqueue_next(); } else #endif { char timer_buf[10]; set_sleep_timer(sc->u.timedata.sleep_timeout * 60); splashf(HZ, "%s (%s)", str(LANG_SLEEP_TIMER), sleep_timer_formatter(timer_buf, sizeof(timer_buf), sc->u.timedata.sleep_timeout, NULL)); } break; case SHORTCUT_UNDEFINED: default: break; } } } pop_current_activity(); return done; }
char* menu_description(int menu, int position) { return P2STR(menus[menu].items[position].desc); }
void menu_draw(int m) { int i = 0; #ifdef HAVE_LCD_BITMAP int fw, fh; int menu_lines; int height = LCD_HEIGHT; lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); if (global_settings.statusbar) height -= STATUSBAR_HEIGHT; #if CONFIG_KEYPAD == RECORDER_PAD if(global_settings.buttonbar && menus[m].use_buttonbar) { buttonbar_set(menus[m].buttonbar[0], menus[m].buttonbar[1], menus[m].buttonbar[2]); height -= BUTTONBAR_HEIGHT; } #endif menu_lines = height / fh; #else int menu_lines = MENU_LINES; #endif lcd_clear_display(); #ifdef HAVE_LCD_BITMAP lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */ #endif /* Adjust cursor pos if it's below the screen */ if (menus[m].cursor - menus[m].top >= menu_lines) menus[m].top = menus[m].cursor - (menu_lines - 1); /* Adjust cursor pos if it's above the screen */ if(menus[m].cursor < menus[m].top) menus[m].top = menus[m].cursor; for (i = menus[m].top; (i < menus[m].itemcount) && (i<menus[m].top+menu_lines); i++) { /* We want to scroll the line where the cursor is */ if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) #ifdef HAVE_LCD_BITMAP if (global_settings.invert_cursor) lcd_puts_scroll_style(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc), STYLE_INVERT); else #endif lcd_puts_scroll(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc)); else lcd_puts(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc)); } /* place the cursor */ put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true); #ifdef HAVE_LCD_BITMAP if (global_settings.scrollbar && menus[m].itemcount > menu_lines) scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, height, menus[m].itemcount, menus[m].top, menus[m].top + menu_lines, VERTICAL); #if CONFIG_KEYPAD == RECORDER_PAD if(global_settings.buttonbar && menus[m].use_buttonbar) buttonbar_draw(); #endif /* CONFIG_KEYPAD == RECORDER_PAD */ #endif /* HAVE_LCD_BITMAP */ status_draw(true); lcd_update(); }
void list_draw(struct screen *display, struct gui_synclist *gui_list) { int text_pos; bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); bool draw_cursor; int i; int lines; int start, end; display->set_viewport(NULL); lines = display->getnblines(); display->clear_display(); start = 0; end = display->getnblines(); gui_list->last_displayed_start_item[display->screen_type] = gui_list->start_item[display->screen_type]; gui_list->last_displayed_selected_item = gui_list->selected_item; /* Adjust the position of icon, cursor, text for the list */ draw_cursor = true; if(draw_icons) text_pos = 2; /* here it's in chars */ else text_pos = 1; for (i = start; i < end; i++) { unsigned const char *s; char entry_buffer[MAX_PATH]; unsigned char *entry_name; int current_item = gui_list->start_item[display->screen_type] + i; /* When there are less items to display than the * current available space on the screen, we stop*/ if(current_item >= gui_list->nb_items) break; s = gui_list->callback_get_item_name(current_item, gui_list->data, entry_buffer, sizeof(entry_buffer)); entry_name = P2STR(s); if(gui_list->show_selection_marker && current_item >= gui_list->selected_item && current_item < gui_list->selected_item + gui_list->selected_size) {/* The selected item must be displayed scrolling */ display->puts_scroll(text_pos, i, entry_name); if (draw_cursor) { screen_put_icon_with_offset(display, 0, i, (draw_scrollbar || SHOW_LIST_TITLE)? SCROLLBAR_WIDTH: 0, 0, Icon_Cursor); } } else {/* normal item */ if(gui_list->scroll_all) { display->puts_scroll(text_pos, i, entry_name); } else { display->puts(text_pos, i, entry_name); } } /* Icons display */ if(draw_icons) { enum themable_icons icon; icon = gui_list->callback_get_item_icon(current_item, gui_list->data); if(icon > Icon_NOICON) { screen_put_icon(display, 1, i, icon); } } } display->update_viewport(); display->update(); }