Index: apps/screens.c =================================================================== --- apps/screens.c (Revision 19596) +++ apps/screens.c (Arbeitskopie) @@ -511,7 +511,7 @@ FOR_NB_SCREENS(s) { - viewport_set_defaults(&vp[s], s); + viewport_set_defaults(&vp[s], s, false); screens[s].set_viewport(&vp[s]); nb_lines = viewport_get_nb_lines(&vp[s]); Index: apps/recorder/radio.c =================================================================== --- apps/recorder/radio.c (Revision 19596) +++ apps/recorder/radio.c (Arbeitskopie) @@ -492,7 +492,7 @@ gui_syncstatusbar_draw(&statusbars,true); FOR_NB_SCREENS(i) { - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) vp[i].height -= BUTTONBAR_HEIGHT; Index: apps/recorder/recording.c =================================================================== --- apps/recorder/recording.c (Revision 19596) +++ apps/recorder/recording.c (Arbeitskopie) @@ -1088,7 +1088,7 @@ /* top vp, 4 lines, force sys font if total screen < 6 lines NOTE: one could limit the list to 1 line and get away with 5 lines */ v = &vp_top[i]; - viewport_set_defaults(v, i); /*already takes care of statusbar*/ + viewport_set_defaults(v, i, false); /*already takes care of statusbar*/ if (viewport_get_nb_lines(v) < 4) { /* compact needs 4 lines total */ @@ -1106,7 +1106,7 @@ /* list section, rest of the screen */ v = &vp_list[i]; - viewport_set_defaults(v, i); + viewport_set_defaults(v, i, false); v->font = vp_top[i].font; v->y = vp_top[i].y + vp_top[i].height; v->height = screens[i].lcdheight - v->y; /* the rest */ Index: apps/plugins/star.c =================================================================== --- apps/plugins/star.c (Revision 19596) +++ apps/plugins/star.c (Arbeitskopie) @@ -1007,10 +1007,7 @@ "Information","Keys","Quit"); FOR_NB_SCREENS(selection) { - rb->viewport_set_defaults(&vp[selection], selection); - /* we are hiding the statusbar so fix the height also */ - vp[selection].y = 0; - vp[selection].height = rb->screens[selection]->lcdheight; + rb->viewport_set_defaults(&vp[selection], selection, true); #if LCD_DEPTH > 1 if (rb->screens[selection]->depth > 1) { Index: apps/gui/bitmap/list.c =================================================================== --- apps/gui/bitmap/list.c (Revision 19596) +++ apps/gui/bitmap/list.c (Arbeitskopie) @@ -45,19 +45,13 @@ #define SCROLLBAR_WIDTH 6 #define ICON_PADDING 1 -static struct viewport title_text[NB_SCREENS], title_icons[NB_SCREENS], - list_text[NB_SCREENS], list_icons[NB_SCREENS]; +/* these are static to make scrolling work */ +static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS]; -/* should probably be moved somewhere else */ -int list_title_height(struct gui_synclist *list, struct viewport *vp) -{ - (void)list; - return font_get(vp->font)->height; -} int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, int text_pos, struct screen * display, struct viewport *vp); -bool list_display_title(struct gui_synclist *list, struct viewport *vp); +bool list_display_title(struct gui_synclist *list, enum screen_type screen); /* Draw the list... internal screen layout: @@ -70,46 +64,47 @@ | | | | ------------------ */ -static bool draw_title(struct screen *display, struct viewport *parent, - struct gui_synclist *list) +static bool draw_title(struct screen *display, struct gui_synclist *list) { - struct viewport *vp_icons = &title_icons[display->screen_type]; - struct viewport *vp_text = &title_text[display->screen_type]; - if (!list_display_title(list, parent)) + struct viewport title_icon = *(list->parent[display->screen_type]); + if (!list_display_title(list, display->screen_type)) return false; - *vp_text = *parent; - vp_text->height = list_title_height(list, parent); + title_text[display->screen_type] = *(list->parent[display->screen_type]); + title_text[display->screen_type].height + = font_get(title_text[display->screen_type].font)->height; if (list->title_icon != Icon_NOICON && global_settings.show_icons) { - *vp_icons = *vp_text; - vp_icons->width = get_icon_width(display->screen_type) + title_icon = title_text[display->screen_type]; + title_icon.width = get_icon_width(display->screen_type) + ICON_PADDING*2; - vp_icons->x += ICON_PADDING; - - vp_text->width -= vp_icons->width + vp_icons->x; - vp_text->x += vp_icons->width + vp_icons->x; - - display->set_viewport(vp_icons); + title_icon.x += ICON_PADDING; + + title_text[display->screen_type].width -= title_icon.width + title_icon.x; + title_text[display->screen_type].x += title_icon.width + title_icon.x; + + display->set_viewport(&title_icon); screen_put_icon(display, 0, 0, list->title_icon); } - display->set_viewport(vp_text); - vp_text->drawmode = STYLE_DEFAULT; + title_text[display->screen_type].drawmode = STYLE_DEFAULT; #ifdef HAVE_LCD_COLOR if (list->title_color >= 0) { - vp_text->drawmode |= (STYLE_COLORED|list->title_color);} + title_text[display->screen_type].drawmode + |= (STYLE_COLORED|list->title_color); + } #endif - display->puts_scroll_style_offset(0, 0, list->title, - vp_text->drawmode, 0); + display->set_viewport(&title_text[display->screen_type]); + display->puts_scroll_style(0, 0, list->title, title_text[display->screen_type].drawmode); return true; } -void list_draw(struct screen *display, struct viewport *parent, - struct gui_synclist *list) +void list_draw(struct screen *display, struct gui_synclist *list) { + struct viewport *parent = (list->parent[display->screen_type]); + struct viewport list_icons; int start, end, line_height, i; - int icon_width = get_icon_width(display->screen_type) + ICON_PADDING; - bool show_cursor = !global_settings.cursor_style && + const int icon_width = get_icon_width(display->screen_type) + ICON_PADDING; + const bool show_cursor = !global_settings.cursor_style && list->show_selection_marker; #ifdef HAVE_LCD_COLOR unsigned char cur_line = 0; @@ -121,12 +116,12 @@ display->clear_viewport(); display->stop_scroll(); list_text[display->screen_type] = *parent; - if ((show_title = draw_title(display, parent, list))) + if ((show_title = draw_title(display, list))) { - list_text[display->screen_type].y += list_title_height(list, parent); - list_text[display->screen_type].height -= list_title_height(list, parent); + list_text[display->screen_type].y += line_height; + list_text[display->screen_type].height -= line_height; } - + start = list->start_item[display->screen_type]; end = start + viewport_get_nb_lines(&list_text[display->screen_type]); @@ -157,18 +152,18 @@ } /* setup icon placement */ - list_icons[display->screen_type] = list_text[display->screen_type]; + list_icons = list_text[display->screen_type]; int icon_count = global_settings.show_icons && (list->callback_get_item_icon != NULL) ? 1 : 0; if (show_cursor) icon_count++; if (icon_count) { - list_icons[display->screen_type].width = icon_width * icon_count; + list_icons.width = icon_width * icon_count; list_text[display->screen_type].width -= - list_icons[display->screen_type].width + ICON_PADDING; + list_icons.width + ICON_PADDING; list_text[display->screen_type].x += - list_icons[display->screen_type].width + ICON_PADDING; + list_icons.width + ICON_PADDING; } for (i=start; inb_items; i++) @@ -261,7 +256,7 @@ /* do the icon */ if (list->callback_get_item_icon && global_settings.show_icons) { - display->set_viewport(&list_icons[display->screen_type]); + display->set_viewport(&list_icons); screen_put_icon_with_offset(display, show_cursor?1:0, (i-start),show_cursor?ICON_PADDING:0,0, list->callback_get_item_icon(i, list->data)); @@ -274,14 +269,12 @@ else if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { - display->set_viewport(&list_icons[display->screen_type]); + display->set_viewport(&list_icons); screen_put_icon(display, 0, (i-start), Icon_Cursor); } } - display->set_viewport(parent); display->update_viewport(); - display->set_viewport(NULL); } @@ -292,7 +285,7 @@ */ static bool scrolling=false; -unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct viewport *parent) +unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) { short x, y; unsigned button = action_get_touchscreen_press(&x, &y); @@ -318,7 +311,7 @@ int nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); if (nb_lines < gui_list->nb_items) { - int scrollbar_size = nb_lines * font_get(parent->font)->height; + int scrollbar_size = nb_lines * font_get(gui_list->parent[display->screen_type]->font)->height; int actual_y = y - list_text[SCREEN_MAIN].y; int new_selection = (actual_y * gui_list->nb_items) / scrollbar_size; @@ -356,7 +349,7 @@ static int last_y = 0; actual_y = y - list_text[SCREEN_MAIN].y; - line_height = font_get(parent->font)->height; + line_height = font_get(gui_list->parent[display->screen_type]->font)->height; line = actual_y / line_height; if(actual_y%line_height == 0) /* Pressed a border */ @@ -404,7 +397,7 @@ return ACTION_NONE; } /* Title goes up one level (only on BUTTON_REL&~BUTTON_REPEAT) */ - else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL) + else if (y > title_text[SCREEN_MAIN].y && draw_title(display, gui_list) && button == BUTTON_REL) return ACTION_STD_CANCEL; /* Title or statusbar is cancel (only on BUTTON_REL&~BUTTON_REPEAT) */ else if (global_settings.statusbar && button == BUTTON_REL) Index: apps/gui/charcell/list.c =================================================================== --- apps/gui/charcell/list.c (Revision 19596) +++ apps/gui/charcell/list.c (Arbeitskopie) @@ -40,10 +40,8 @@ #include "misc.h" #include "talk.h" -void list_draw(struct screen *display, struct viewport *parent, - struct gui_synclist *gui_list) +void list_draw(struct screen *display, struct gui_synclist *gui_list) { - (void)parent; int text_pos; bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); Index: apps/gui/yesno.c =================================================================== --- apps/gui/yesno.c (Revision 19596) +++ apps/gui/yesno.c (Arbeitskopie) @@ -144,7 +144,7 @@ yn[i].result_message[YESNO_NO]=no_message; yn[i].display=&screens[i]; yn[i].vp = &vp[i]; - viewport_set_defaults(yn[i].vp, i); + viewport_set_defaults(yn[i].vp, i, false); screens[i].stop_scroll(); gui_yesno_draw(&(yn[i])); } Index: apps/gui/buttonbar.c =================================================================== --- apps/gui/buttonbar.c (Revision 19596) +++ apps/gui/buttonbar.c (Arbeitskopie) @@ -44,7 +44,7 @@ gui_buttonbar_unset(buttonbar); FOR_NB_SCREENS(i) { - viewport_set_defaults(&bb_vp[i], i); + viewport_set_defaults(&bb_vp[i], i, false); bb_vp[i].font = FONT_SYSFIXED; bb_vp[i].y = screens[i].lcdheight - BUTTONBAR_HEIGHT; bb_vp[i].height = BUTTONBAR_HEIGHT; Index: apps/gui/pitchscreen.c =================================================================== --- apps/gui/pitchscreen.c (Revision 19596) +++ apps/gui/pitchscreen.c (Arbeitskopie) @@ -270,7 +270,7 @@ FOR_NB_SCREENS(i) { screens[i].clear_display(); - viewport_set_defaults(&parent[i], i); + viewport_set_defaults(&parent[i], i, false); max_lines[i] = viewport_get_nb_lines(&parent[i]); pitchscreen_fix_viewports(&parent[i], pitch_viewports[i]); Index: apps/gui/statusbar.c =================================================================== --- apps/gui/statusbar.c (Revision 19596) +++ apps/gui/statusbar.c (Arbeitskopie) @@ -174,7 +174,7 @@ { struct screen * display = bar->display; struct viewport vp; - viewport_set_defaults(&vp, display->screen_type); + viewport_set_defaults(&vp, display->screen_type, false); vp.height = STATUSBAR_HEIGHT; vp.x = STATUSBAR_X_POS; vp.y = STATUSBAR_Y_POS; Index: apps/gui/list.c =================================================================== --- apps/gui/list.c (Revision 19596) +++ apps/gui/list.c (Arbeitskopie) @@ -61,7 +61,7 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list, int offset); -void list_draw(struct screen *display, struct viewport *parent, struct gui_synclist *list); +void list_draw(struct screen *display, struct gui_synclist *list); #ifdef HAVE_LCD_BITMAP static struct viewport parent[NB_SCREENS]; @@ -73,10 +73,10 @@ { vp = &parent[i]; if (!list) - viewport_set_defaults(vp, i); + viewport_set_defaults(vp, i, false); else if (list->parent[i] == vp) { - viewport_set_defaults(vp, i); + viewport_set_defaults(vp, i, false); list->parent[i]->y = gui_statusbar_height(); list->parent[i]->height = screens[i].lcdheight - list->parent[i]->y; } @@ -106,12 +106,13 @@ #endif #ifdef HAVE_LCD_BITMAP -bool list_display_title(struct gui_synclist *list, struct viewport *vp) +bool list_display_title(struct gui_synclist *list, enum screen_type screen) { - return list->title != NULL && viewport_get_nb_lines(vp)>2; + return list->title != NULL && + viewport_get_nb_lines(list->parent[screen])>2; } #else -#define list_display_title(l,v) false +#define list_display_title(l, i) false #endif /* @@ -180,8 +181,6 @@ #ifdef HAVE_LCD_BITMAP -int list_title_height(struct gui_synclist *list, struct viewport *vp); - int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, int text_pos, struct screen * display, struct viewport *vp) { @@ -241,7 +240,7 @@ last_list = gui_list; FOR_NB_SCREENS(i) { - list_draw(&screens[i], gui_list->parent[i], gui_list); + list_draw(&screens[i], gui_list); } } @@ -253,8 +252,8 @@ int difference = gui_list->selected_item - gui_list->start_item[screen]; struct viewport vp = *gui_list->parent[screen]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(gui_list, gui_list->parent[screen])) - vp.height -= list_title_height(gui_list,gui_list->parent[screen]); + if (list_display_title(gui_list, screen)) + vp.height -= font_get(gui_list->parent[screen]->font)->height; #endif nb_lines = viewport_get_nb_lines(&vp); @@ -351,8 +350,8 @@ { struct viewport vp = *gui_list->parent[i]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(gui_list, gui_list->parent[i])) - vp.height -= list_title_height(gui_list,gui_list->parent[i]); + if (list_display_title(gui_list, i)) + vp.height -= font_get(gui_list->parent[i]->font)->height; #endif nb_lines = viewport_get_nb_lines(&vp); if (offset > 0) @@ -578,7 +577,7 @@ extern intptr_t get_action_data(void); #if defined(HAVE_TOUCHSCREEN) /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ -unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct viewport *parent); +unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list); #endif bool gui_synclist_do_button(struct gui_synclist * lists, @@ -621,7 +620,7 @@ #if defined(HAVE_TOUCHSCREEN) if (action == ACTION_TOUCHSCREEN) - action = *actionptr = gui_synclist_do_touchscreen(lists, &parent[SCREEN_MAIN]); + action = *actionptr = gui_synclist_do_touchscreen(lists); #endif switch (wrap) @@ -791,8 +790,8 @@ { struct viewport vp = *lists->parent[screen]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(lists, lists->parent[screen])) - vp.height -= list_title_height(lists, lists->parent[screen]); + if (list_display_title(lists, screen)) + vp.height -= font_get(lists->parent[screen]->font)->height; #endif return item <= (lists->start_item[screen] + viewport_get_nb_lines(&vp)); } @@ -855,7 +854,7 @@ getname = simplelist_static_getname; FOR_NB_SCREENS(i) { - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false); } gui_synclist_init(&lists, getname, info->callback_data, info->scroll_all, info->selection_size, vp); Index: apps/gui/quickscreen.c =================================================================== --- apps/gui/quickscreen.c (Revision 19596) +++ apps/gui/quickscreen.c (Arbeitskopie) @@ -283,7 +283,7 @@ { screens[i].set_viewport(NULL); screens[i].stop_scroll(); - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false); quickscreen_fix_viewports(qs, &screens[i], &vp[i]); gui_quickscreen_draw(qs, &screens[i], &vp[i]); } Index: apps/gui/viewport.c =================================================================== --- apps/gui/viewport.c (Revision 19596) +++ apps/gui/viewport.c (Arbeitskopie) @@ -32,6 +32,8 @@ #include "misc.h" #include "viewport.h" #include "statusbar.h" +#include "buttonbar.h" + #include "screen_access.h" int viewport_get_nb_lines(struct viewport *vp) @@ -45,13 +47,22 @@ } -void viewport_set_defaults(struct viewport *vp, enum screen_type screen) +void viewport_set_defaults(struct viewport *vp, enum screen_type screen, + const bool ignore_bars) { vp->x = 0; vp->width = screens[screen].lcdwidth; - vp->y = gui_statusbar_height(); - vp->height = screens[screen].lcdheight - vp->y; + if(!ignore_bars) /* respect bars */ + { + vp->y = gui_statusbar_height(); + vp->height = screens[screen].lcdheight - vp->y; + } + else + { + vp->y = 0; + vp->height = screens[screen].lcdheight; + } #ifdef HAVE_LCD_BITMAP vp->drawmode = DRMODE_SOLID; vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ @@ -81,4 +92,8 @@ vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; } #endif +#ifdef HAVE_BUTTONBAR + if (!ignore_bars && global_settings.buttonbar && screen == 0) + vp->height -= BUTTONBAR_HEIGHT; +#endif } Index: apps/gui/viewport.h =================================================================== --- apps/gui/viewport.h (Revision 19596) +++ apps/gui/viewport.h (Arbeitskopie) @@ -39,4 +39,5 @@ returns a combination of the above to say which were loaded ok from the string */ int viewport_load_config(const char *config, struct viewport *vp); -void viewport_set_defaults(struct viewport *vp, enum screen_type screen); +void viewport_set_defaults(struct viewport *vp, enum screen_type screen, + const bool ignore_bars); Index: apps/menu.c =================================================================== --- apps/menu.c (Revision 19596) +++ apps/menu.c (Arbeitskopie) @@ -283,29 +283,6 @@ } return 0; } -/* this is used to reload the default menu viewports when the - theme changes. nothing happens if the menu is using a supplied parent vp */ -static void init_default_menu_viewports(struct viewport parent[NB_SCREENS], bool hide_bars) -{ - int i; - FOR_NB_SCREENS(i) - { - viewport_set_defaults(&parent[i], i); - /* viewport_set_defaults() fixes the vp for the bars, so resize */ - if (hide_bars) - { - if (global_settings.statusbar) - { - parent[i].y -= STATUSBAR_HEIGHT; - parent[i].height += STATUSBAR_HEIGHT; - } - } - } -#ifdef HAVE_BUTTONBAR - if (!hide_bars && global_settings.buttonbar) - parent[0].height -= BUTTONBAR_HEIGHT; -#endif -} bool do_setting_from_menu(const struct menu_item_ex *temp, struct viewport parent[NB_SCREENS]) @@ -383,8 +360,7 @@ int menu_stack_selected_item[MAX_MENUS]; int stack_top = 0; bool in_stringlist, done = false; - - struct viewport *vps, menu_vp[NB_SCREENS]; /* menu_vp will hopefully be phased out */ + struct viewport *vps = NULL; #ifdef HAVE_BUTTONBAR struct gui_buttonbar buttonbar; gui_buttonbar_init(&buttonbar); @@ -396,27 +372,12 @@ if (start_menu == NULL) menu = &main_menu_; else menu = start_menu; - - init_default_menu_viewports(menu_vp, hide_bars); - - if (parent) - { - vps = parent; - /* if hide_bars == true we assume the viewport is correctly sized */ - } - else - { - vps = menu_vp; - } - FOR_NB_SCREENS(i) - { - screens[i].set_viewport(&vps[i]); - screens[i].clear_viewport(); - screens[i].set_viewport(NULL); - } - init_menu_lists(menu, &lists, selected, true, vps); + + /* if hide_bars is true, assume parent has been fixed before passed into + * this function, e.g. with viewport_set_defaults(parent, screen, true) */ + init_menu_lists(menu, &lists, selected, true, parent); + vps = *(lists.parent); in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID); - /* load the callback, and only reload it if menu changes */ get_menu_callback(menu, &menu_callback); @@ -642,7 +603,6 @@ return_value = temp->function->function(); if (!(menu->flags&MENU_EXITAFTERTHISMENU) || (temp->flags&MENU_EXITAFTERTHISMENU)) { - init_default_menu_viewports(menu_vp, hide_bars); init_menu_lists(menu, &lists, selected, true, vps); } if (temp->flags&MENU_FUNC_CHECK_RETVAL) @@ -658,9 +618,8 @@ case MT_SETTING: case MT_SETTING_W_TEXT: { - if (do_setting_from_menu(temp, menu_vp)) + if (do_setting_from_menu(temp, vps)) { - init_default_menu_viewports(menu_vp, hide_bars); init_menu_lists(menu, &lists, selected, true,vps); redraw_lists = false; /* above does the redraw */ } Index: apps/menus/recording_menu.c =================================================================== --- apps/menus/recording_menu.c (Revision 19596) +++ apps/menus/recording_menu.c (Arbeitskopie) @@ -486,7 +486,7 @@ { screens[i].clear_display(); screens[i].update(); - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false); vp[i].height -= SYSFONT_HEIGHT*2; trig_xpos[i] = 0; trig_ypos[i] = vp[i].y + vp[i].height; Index: apps/menus/time_menu.c =================================================================== --- apps/menus/time_menu.c (Revision 19596) +++ apps/menus/time_menu.c (Arbeitskopie) @@ -264,7 +264,7 @@ FOR_NB_SCREENS(i) { - viewport_set_defaults(&clock[i], i); + viewport_set_defaults(&clock[i], i, false); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) { Index: apps/alarm_menu.c =================================================================== --- apps/alarm_menu.c (Revision 19596) +++ apps/alarm_menu.c (Arbeitskopie) @@ -80,7 +80,7 @@ } FOR_NB_SCREENS(i) { - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false); } while(!done) { Index: apps/plugin.h =================================================================== --- apps/plugin.h (Revision 19596) +++ apps/plugin.h (Arbeitskopie) @@ -317,7 +317,8 @@ void (*lcd_remote_bitmap)(const fb_remote_data *src, int x, int y, int width, int height); #endif - void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen); + void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen, + const bool ignore_bars); /* list */ void (*gui_synclist_init)(struct gui_synclist * lists, list_get_name callback_get_item_name, void * data,