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,47 +64,51 @@ | | | | ------------------ */ -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)) + const int screen = display->screen_type; + if (!list_display_title(list, screen)) return false; - *vp_text = *parent; - vp_text->height = list_title_height(list, parent); + title_text[screen] = *(list->parent[screen]); + title_text[screen].height + = font_get(title_text[screen].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) + struct viewport title_icon = *(list->parent[screen]); + title_icon = title_text[screen]; + title_icon.width = get_icon_width(screen) + 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[screen].width -= title_icon.width + title_icon.x; + title_text[screen].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[screen].drawmode = STYLE_DEFAULT; #ifdef HAVE_LCD_COLOR if (list->title_color >= 0) { - vp_text->drawmode |= (STYLE_COLORED|list->title_color);} + title_text[screen].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[screen]); + display->puts_scroll_style(0, 0, list->title, + title_text[screen].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 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 screen = display->screen_type; + const int icon_width = get_icon_width(screen) + ICON_PADDING; + 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 @@ -120,55 +118,55 @@ display->set_viewport(parent); display->clear_viewport(); display->stop_scroll(); - list_text[display->screen_type] = *parent; - if ((show_title = draw_title(display, parent, list))) + list_text[screen] = *parent; + 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[screen].y += line_height; + list_text[screen].height -= line_height; } - - start = list->start_item[display->screen_type]; - end = start + viewport_get_nb_lines(&list_text[display->screen_type]); + + start = list->start_item[screen]; + end = start + viewport_get_nb_lines(&list_text[screen]); /* draw the scrollbar if its needed */ if (global_settings.scrollbar && - viewport_get_nb_lines(&list_text[display->screen_type]) < list->nb_items) + viewport_get_nb_lines(&list_text[screen]) < list->nb_items) { struct viewport vp; - vp = list_text[display->screen_type]; + vp = list_text[screen]; vp.width = SCROLLBAR_WIDTH; - list_text[display->screen_type].width -= SCROLLBAR_WIDTH; - list_text[display->screen_type].x += SCROLLBAR_WIDTH; + list_text[screen].width -= SCROLLBAR_WIDTH; + list_text[screen].x += SCROLLBAR_WIDTH; vp.height = line_height * - viewport_get_nb_lines(&list_text[display->screen_type]); + viewport_get_nb_lines(&list_text[screen]); vp.x = parent->x; display->set_viewport(&vp); gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, vp.height, list->nb_items, - list->start_item[display->screen_type], - list->start_item[display->screen_type] + end-start, + list->start_item[screen], + list->start_item[screen] + end-start, VERTICAL); } else if (show_title) { /* shift everything right a bit... */ - list_text[display->screen_type].width -= SCROLLBAR_WIDTH; - list_text[display->screen_type].x += SCROLLBAR_WIDTH; + list_text[screen].width -= SCROLLBAR_WIDTH; + list_text[screen].x += SCROLLBAR_WIDTH; } /* setup icon placement */ - list_icons[display->screen_type] = list_text[display->screen_type]; + list_icons = list_text[screen]; 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_text[display->screen_type].width -= - list_icons[display->screen_type].width + ICON_PADDING; - list_text[display->screen_type].x += - list_icons[display->screen_type].width + ICON_PADDING; + list_icons.width = icon_width * icon_count; + list_text[screen].width -= + list_icons.width + ICON_PADDING; + list_text[screen].x += + list_icons.width + ICON_PADDING; } for (i=start; inb_items; i++) @@ -181,14 +179,14 @@ s = list->callback_get_item_name(i, list->data, entry_buffer, sizeof(entry_buffer)); entry_name = P2STR(s); - display->set_viewport(&list_text[display->screen_type]); - list_text[display->screen_type].drawmode = STYLE_DEFAULT; + display->set_viewport(&list_text[screen]); + list_text[screen].drawmode = 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[display->screen_type]); + &list_text[screen]); #ifdef HAVE_LCD_COLOR /* if the list has a color callback */ @@ -198,73 +196,75 @@ /* if color selected */ if (color >= 0) { - list_text[display->screen_type].drawmode |= STYLE_COLORED|color; + list_text[screen].drawmode |= STYLE_COLORED|color; } } #endif - if(i >= list->selected_item && - i < list->selected_item + list->selected_size && list->show_selection_marker) + if(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 */ + /* 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 */ - list_text[display->screen_type].drawmode = STYLE_INVERT; + list_text[screen].drawmode = STYLE_INVERT; } #ifdef HAVE_LCD_COLOR else if (global_settings.cursor_style == 2) { /* Display colour line selector */ - list_text[display->screen_type].drawmode = STYLE_COLORBAR; + list_text[screen].drawmode = STYLE_COLORBAR; } else if (global_settings.cursor_style == 3) { /* Display gradient line selector */ - list_text[display->screen_type].drawmode = STYLE_GRADIENT; + list_text[screen].drawmode = STYLE_GRADIENT; /* Make the lcd driver know how many lines the gradient should cover and current line number */ /* number of selected lines */ - list_text[display->screen_type].drawmode |= NUMLN_PACK(list->selected_size); + list_text[screen].drawmode |= NUMLN_PACK(list->selected_size); /* current line number, zero based */ - list_text[display->screen_type].drawmode |= CURLN_PACK(cur_line); + list_text[screen].drawmode |= CURLN_PACK(cur_line); cur_line++; } #endif /* if the text is smaller than the viewport size */ - if (item_offset > item_width - (list_text[display->screen_type].width - text_pos)) + if (item_offset> item_width + - (list_text[screen].width - text_pos)) { /* don't scroll */ display->puts_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); } else { display->puts_scroll_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); } } else { if (list->scroll_all) display->puts_scroll_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); else display->puts_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); } /* 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)); + (i-start),show_cursor?ICON_PADDING:0,0, + list->callback_get_item_icon(i, list->data)); if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { @@ -274,14 +274,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,18 +290,20 @@ */ 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); int line; struct screen *display = &screens[SCREEN_MAIN]; + const int screen = display->screen_type; + if (button == BUTTON_NONE) return ACTION_NONE; - if (xnb_items) { - int scrollbar_size = nb_lines * font_get(parent->font)->height; - int actual_y = y - list_text[SCREEN_MAIN].y; + int scrollbar_size = nb_lines* + font_get(gui_list->parent[screen]->font)->height; + int actual_y = y - list_text[screen].y; - int new_selection = (actual_y * gui_list->nb_items) / scrollbar_size; + int new_selection = (actual_y * gui_list->nb_items) + / scrollbar_size; int start_item = new_selection - nb_lines/2; if(start_item < 0) @@ -329,7 +331,7 @@ else if(start_item > gui_list->nb_items - nb_lines) start_item = gui_list->nb_items - nb_lines; - gui_list->start_item[SCREEN_MAIN] = start_item; + gui_list->start_item[screen] = start_item; gui_synclist_select_item(gui_list, new_selection); return ACTION_REDRAW; @@ -350,27 +352,31 @@ * | will bring up the context menu of it. | * |--------------------------------------------------------| */ - if (y > list_text[SCREEN_MAIN].y) + if (y > list_text[screen].y) { int line_height, actual_y; static int last_y = 0; - actual_y = y - list_text[SCREEN_MAIN].y; - line_height = font_get(parent->font)->height; + actual_y = y - list_text[screen].y; + line_height = font_get(gui_list->parent[screen]->font)->height; line = actual_y / line_height; if(actual_y%line_height == 0) /* Pressed a border */ return ACTION_NONE; - if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) /* Pressed below the list*/ + if (gui_list->start_item[screen]+line > gui_list->nb_items) + { + /* Pressed below the list*/ return ACTION_NONE; - + } last_y = actual_y; - if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button ^ BUTTON_REL) + if (line != gui_list->selected_item + - gui_list->start_item[screen] && button ^ BUTTON_REL) { if(button & BUTTON_REPEAT) scrolling = true; - gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); + gui_synclist_select_item(gui_list, gui_list->start_item[screen] + + line); return ACTION_REDRAW; } @@ -378,15 +384,17 @@ { if(!scrolling) { - /* Pen was hold on the same line as the previously selected one - * => simulate long button press + /* Pen was hold on the same line as the + * previously selected one + * => simulate long button press */ return ACTION_STD_CONTEXT; } else { - /* Pen was moved across several lines and then released on this one - * => do nothing + /* Pen was moved across several lines and then released on + * this one + * => do nothing */ scrolling = false; return ACTION_NONE; @@ -394,8 +402,8 @@ } else if(button == BUTTON_REL) { - /* Pen was released on either the same line as the previously selected one - * or an other one + /* Pen was released on either the same line as the previously + * selected one or an other one * => simulate short press */ return ACTION_STD_OK; @@ -404,11 +412,16 @@ 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].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) + { return ACTION_STD_CANCEL; + } } return ACTION_NONE; } 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,10 +181,11 @@ #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) +int gui_list_get_item_offset(struct gui_synclist * gui_list, + int item_width, + int text_pos, + struct screen * display, + struct viewport *vp) { int item_offset; @@ -241,7 +243,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 +255,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); @@ -273,7 +275,10 @@ if (global_settings.scroll_paginated) { if (gui_list->start_item[screen] > gui_list->selected_item) - gui_list->start_item[screen] = (gui_list->selected_item/nb_lines)*nb_lines; + { + gui_list->start_item[screen] = (gui_list->selected_item/nb_lines) + *nb_lines; + } if (gui_list->nb_items <= nb_lines) gui_list->start_item[screen] = 0; } @@ -293,7 +298,7 @@ if (bottom < 0) bottom = 0; gui_list->start_item[screen] = MIN(bottom, gui_list->start_item[screen] + - 2*gui_list->selected_size); + 2*gui_list->selected_size); } else if (global_settings.scroll_paginated) { @@ -351,8 +356,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 +583,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 +626,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 +796,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 +860,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); @@ -900,14 +905,16 @@ { bool stdok = action==ACTION_STD_OK; action = info->action_callback(action, &lists); - if (stdok && action == ACTION_STD_CANCEL) /* callback asked us to exit */ + if (stdok && action == ACTION_STD_CANCEL) { + /* callback asked us to exit */ info->selection = gui_synclist_get_sel_pos(&lists); break; } if (info->get_name == NULL) - gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); + gui_synclist_set_nb_items(&lists, + simplelist_line_count*info->selection_size); } if (action == ACTION_STD_CANCEL) { @@ -918,7 +925,10 @@ (old_line_count != simplelist_line_count)) { if (info->get_name == NULL) - gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); + { + gui_synclist_set_nb_items(&lists, + simplelist_line_count*info->selection_size); + } gui_synclist_draw(&lists); old_line_count = simplelist_line_count; } 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); @@ -496,7 +457,7 @@ else if (!in_stringlist) { int type; - selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); + selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu); temp = menu->submenus[selected]; type = (temp->flags&MENU_TYPE_MASK); if ((type == MT_SETTING_W_TEXT || type == MT_SETTING)) @@ -640,9 +601,9 @@ temp->function->param); else return_value = temp->function->function(); - if (!(menu->flags&MENU_EXITAFTERTHISMENU) || (temp->flags&MENU_EXITAFTERTHISMENU)) + 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 +619,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,