Index: apps/screens.c =================================================================== --- apps/screens.c (Revision 19353) +++ apps/screens.c (Arbeitskopie) @@ -513,7 +513,7 @@ FOR_NB_SCREENS(s) { - viewport_set_defaults(&vp[s], s); + viewport_set_defaults(&vp[s], s, false, false); nb_lines = viewport_get_nb_lines(&vp[s]); /* minimum lines needed is 2 + title line */ Index: apps/recorder/radio.c =================================================================== --- apps/recorder/radio.c (Revision 19353) +++ apps/recorder/radio.c (Arbeitskopie) @@ -468,7 +468,7 @@ gui_syncstatusbar_draw(&statusbars,true); FOR_NB_SCREENS(i) { - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false, false); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) vp[i].height -= BUTTONBAR_HEIGHT; Index: apps/recorder/recording.c =================================================================== --- apps/recorder/recording.c (Revision 19353) +++ 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, 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, 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/pictureflow.c =================================================================== --- apps/plugins/pictureflow.c (Revision 19353) +++ apps/plugins/pictureflow.c (Arbeitskopie) @@ -128,6 +128,7 @@ #define ERROR_NO_ALBUMS -1 #define ERROR_BUFFER_FULL -2 +static struct viewport vp[NB_SCREENS]; /** structs we use */ @@ -1568,7 +1569,7 @@ "Rebuild cache"); do { - selection=rb->do_menu(&settings_menu,&selection, NULL, false); + selection=rb->do_menu(&settings_menu,&selection, vp, true); switch(selection) { case 0: rb->set_bool("Show FPS", &(config.show_fps)); @@ -1630,7 +1631,7 @@ "Settings", "Return", "Quit"); while (1) { - switch (rb->do_menu(&main_menu,&selection, NULL, false)) { + switch (rb->do_menu(&main_menu,&selection, vp, true)) { case 0: result = settings_menu(); if ( result != 0 ) return result; @@ -2135,6 +2136,9 @@ #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif + int screen; + FOR_NB_SCREENS(screen) + rb->viewport_set_defaults(&vp[screen], screen, true, true); /* Turn off backlight timeout */ backlight_force_on(rb); /* backlight control in lib/helper.c */ #ifdef HAVE_ADJUSTABLE_CPU_FREQ Index: apps/plugins/star.c =================================================================== --- apps/plugins/star.c (Revision 19353) +++ apps/plugins/star.c (Arbeitskopie) @@ -1005,10 +1005,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, true); #if LCD_DEPTH > 1 if (rb->screens[selection]->depth > 1) { Index: apps/plugins/text_editor.c =================================================================== --- apps/plugins/text_editor.c (Revision 19353) +++ apps/plugins/text_editor.c (Arbeitskopie) @@ -36,6 +36,7 @@ static int line_count = 0; static int last_action_line = 0; static int last_char_index = 0; +struct viewport vp[NB_SCREENS]; #define ACTION_INSERT 0 #define ACTION_GET 1 @@ -205,7 +206,8 @@ void setup_lists(struct gui_synclist *lists, int sel) { - rb->gui_synclist_init(lists,list_get_name_cb,0, false, 1, NULL); + rb->gui_synclist_init(lists,list_get_name_cb,0, false, 1, vp); + /* we don't want custom list */ rb->gui_synclist_set_icon_callback(lists,NULL); rb->gui_synclist_set_nb_items(lists,line_count); rb->gui_synclist_limit_scroll(lists,true); @@ -226,7 +228,7 @@ "Concat To Above", "Save", "Show Playback Menu",); - switch (rb->do_menu(&menu, NULL, NULL, false)) + switch (rb->do_menu(&menu, NULL, vp, false)) { case 0: /* cut */ rb->strcpy(copy_buffer,&buffer[do_action(ACTION_GET,0,cur_sel)]); @@ -326,6 +328,9 @@ rb = api; + int i; + FOR_NB_SCREENS(i) + rb->viewport_set_defaults(&vp[i], i, true, true); copy_buffer[0]='\0'; prev_show_statusbar = rb->global_settings->statusbar; rb->global_settings->statusbar = false; @@ -408,7 +413,7 @@ { MENUITEM_STRINGLIST(menu, "Edit What?", NULL, "Extension", "Color",); - switch (rb->do_menu(&menu, NULL, NULL, false)) + switch (rb->do_menu(&menu, NULL, vp, true)) { case 0: edit_text = true; @@ -476,7 +481,7 @@ "Show Playback Menu", "Save Changes", "Save As...", "Save and Exit", "Ignore Changes and Exit"); - switch (rb->do_menu(&menu, NULL, NULL, false)) + switch (rb->do_menu(&menu, NULL, vp, true)) { case 0: break; Index: apps/gui/bitmap/list.c =================================================================== --- apps/gui/bitmap/list.c (Revision 19353) +++ apps/gui/bitmap/list.c (Arbeitskopie) @@ -44,6 +44,8 @@ #define SCROLLBAR_WIDTH 6 #define ICON_PADDING 1 +/* just to have it shorter */ +#define parent (list->parent[display->screen_type]) static struct viewport title_text[NB_SCREENS], title_icons[NB_SCREENS], list_text[NB_SCREENS], list_icons[NB_SCREENS]; @@ -57,7 +59,7 @@ 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,12 +72,11 @@ | | | | ------------------ */ -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)) + if (!list_display_title(list, display->screen_type)) return false; *vp_text = *parent; vp_text->height = list_title_height(list, parent); @@ -86,9 +87,9 @@ + 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; - + vp_text->x = vp_icons->width + vp_icons->x; + vp_text->width -= vp_text->x; + display->set_viewport(vp_icons); screen_put_icon(display, 0, 0, list->title_icon); } @@ -104,8 +105,7 @@ 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) { int start, end, line_height, i; int icon_width = get_icon_width(display->screen_type) + ICON_PADDING; @@ -117,11 +117,17 @@ int item_offset; bool show_title; line_height = font_get(parent->font)->height; + /* clean up unused parts of the screen */ + { + struct viewport fullscreen; + viewport_set_defaults(&fullscreen, display->screen_type, false, true); + display->set_viewport(&fullscreen); + display->clear_viewport(); + } + display->stop_scroll(); display->set_viewport(parent); - 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); @@ -278,10 +284,8 @@ screen_put_icon(display, 0, (i-start), Icon_Cursor); } } - + display->update(); display->set_viewport(parent); - display->update_viewport(); - display->set_viewport(NULL); } @@ -292,7 +296,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 * list) { short x, y; unsigned button = action_get_touchscreen_press(&x, &y); @@ -316,21 +320,21 @@ else { int nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); - if (nb_lines < gui_list->nb_items) + if (nb_lines < list->nb_items) { int scrollbar_size = nb_lines * font_get(parent->font)->height; int actual_y = y - list_text[SCREEN_MAIN].y; - int new_selection = (actual_y * gui_list->nb_items) / scrollbar_size; + int new_selection = (actual_y * list->nb_items) / scrollbar_size; int start_item = new_selection - nb_lines/2; if(start_item < 0) start_item = 0; - else if(start_item > gui_list->nb_items - nb_lines) - start_item = gui_list->nb_items - nb_lines; + else if(start_item > list->nb_items - nb_lines) + start_item = list->nb_items - nb_lines; - gui_list->start_item[SCREEN_MAIN] = start_item; - gui_synclist_select_item(gui_list, new_selection); + list->start_item[SCREEN_MAIN] = start_item; + gui_synclist_select_item(list, new_selection); return ACTION_REDRAW; } @@ -362,15 +366,15 @@ 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 (list->start_item[SCREEN_MAIN]+line > 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 != list->selected_item - list->start_item[SCREEN_MAIN] && 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(list, list->start_item[SCREEN_MAIN]+line); return ACTION_REDRAW; } @@ -404,7 +408,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, 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 19353) +++ 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 19353) +++ 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, false); screens[i].stop_scroll(); gui_yesno_draw(&(yn[i])); } Index: apps/gui/buttonbar.c =================================================================== --- apps/gui/buttonbar.c (Revision 19353) +++ 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 19353) +++ apps/gui/pitchscreen.c (Arbeitskopie) @@ -177,7 +177,6 @@ display->putsxy(0, h / 2, "-2%"); } /* Lastly, a fullscreen update */ - display->set_viewport(NULL); display->update(); } @@ -270,7 +269,7 @@ FOR_NB_SCREENS(i) { screens[i].clear_display(); - viewport_set_defaults(&parent[i], i); + viewport_set_defaults(&parent[i], i, false, 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 19353) +++ 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, true); vp.height = STATUSBAR_HEIGHT; vp.x = STATUSBAR_X_POS; vp.y = STATUSBAR_Y_POS; Index: apps/gui/list.c =================================================================== --- apps/gui/list.c (Revision 19353) +++ 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,12 +73,10 @@ { vp = &parent[i]; if (!list) - viewport_set_defaults(vp, i); - else if (list->parent[i] == vp) + viewport_set_defaults(vp, i, false, false); + else if (list->parent[i] == vp) /* NULL was passed to the list */ { - viewport_set_defaults(vp, i); - list->parent[i]->y = gui_statusbar_height(); - list->parent[i]->height = screens[i].lcdheight - list->parent[i]->y; + viewport_set_defaults(vp, i, false, false); } } #ifdef HAVE_BUTTONBAR @@ -106,12 +104,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 /* @@ -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,7 +252,7 @@ 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])) + if (list_display_title(gui_list, screen)) vp.height -= list_title_height(gui_list,gui_list->parent[screen]); #endif nb_lines = viewport_get_nb_lines(&vp); @@ -351,7 +350,7 @@ { struct viewport vp = *gui_list->parent[i]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(gui_list, gui_list->parent[i])) + if (list_display_title(gui_list, i)) vp.height -= list_title_height(gui_list,gui_list->parent[i]); #endif nb_lines = viewport_get_nb_lines(&vp); @@ -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,7 +790,7 @@ { struct viewport vp = *lists->parent[screen]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(lists, lists->parent[screen])) + if (list_display_title(lists, screen)) vp.height -= list_title_height(lists, lists->parent[screen]); #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, 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 19353) +++ apps/gui/quickscreen.c (Arbeitskopie) @@ -70,7 +70,8 @@ /* center the icons VP first */ vp_icons[screen] = *parent; vp_icons[screen].width = CENTER_ICONAREA_WIDTH; /* abosulte smallest allowed */ - vp_icons[screen].x = (parent->width-parent->x-CENTER_ICONAREA_WIDTH)/2; + vp_icons[screen].x = parent->x; + vp_icons[screen].x += (parent->width-CENTER_ICONAREA_WIDTH)/2; vps[screen][QUICKSCREEN_BOTTOM] = *parent; if (nb_lines <= MIN_LINES) /* make the bottom item use 1 line */ @@ -219,11 +220,8 @@ display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], (vp_icons[screen].width/2) - 4, vp_icons[screen].height - 7, 7, 8); - display->update_viewport(); - display->set_viewport(parent); - display->update_viewport(); - display->set_viewport(NULL); + display->update(); } static void talk_qs_option(struct settings_list *opt, bool enqueue) @@ -283,7 +281,7 @@ { screens[i].set_viewport(NULL); screens[i].stop_scroll(); - viewport_set_defaults(&vp[i], i); + viewport_set_defaults(&vp[i], i, false, 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 19353) +++ apps/gui/viewport.c (Arbeitskopie) @@ -32,8 +32,23 @@ #include "misc.h" #include "viewport.h" #include "statusbar.h" +#include "buttonbar.h" + #include "screen_access.h" +#include "debug.h" +#define VP_STRUCTURE_PARAM_ERROR 0 +#warning REMOVE DEBUG HERE +void DEBUG_VP(struct viewport vp, char* string) +{ + DEBUGF("%s debug:\n.x: %d\t.y: %d\n\r.width: %d\t.height: %d\n\n"\ + ,string, vp.x,vp.y,vp.width,vp.height); +} +void DEBUG_VP_PTR(struct viewport *vp, char* string) +{ + DEBUGF("%s debug:\n->x: %d\t\t->y: %d\n\r->width: %d\t->height: %d\n\n", + string, vp->x,vp->y,vp->width,vp->height); +} int viewport_get_nb_lines(struct viewport *vp) { #ifdef HAVE_LCD_BITMAP @@ -44,14 +59,31 @@ #endif } +static bool customlist_init(struct viewport *vp, enum screen_type screen); -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, const bool force_fullscreen) { + /* assume customlist vp is properly fixed for bars if it's used */ + if (!force_fullscreen) /* parse custom list from settings */ + { + if (customlist_init(vp, screen)) + return; /* parsing succeeded, stop */ + } + 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 +113,121 @@ vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; } #endif +#ifdef HAVE_BUTTONBAR + if (!ignore_bars && global_settings.buttonbar && screen == 0) + vp->height -= BUTTONBAR_HEIGHT; +#endif } + +#ifdef HAVE_LCD_BITMAP + +/* Generic viewport parsing function to parse viewports structures like + * the %V tag; basically just a wrapper for parse_list, so improvements + * should aim parse_list */ +const char* viewport_parse_viewport(struct viewport *vp, + const char *bufptr, const char seperator, enum screen_type screen) +{ + /* parse the list to the viewport struct */ + const char *ptr = bufptr; + int depth; + uint32_t set = 0; + + enum { + PL_X = 0, + PL_Y, + PL_WIDTH, + PL_HEIGHT, + PL_FONT, + PL_FG, + PL_BG, + }; + + /* set the defaults, the string might be incomplete */ + viewport_set_defaults(vp, screen, true, true); + + /* Work out the depth of this display */ + depth = screens[screen].depth; +#ifdef HAVE_LCD_COLOR + if (depth == 16) + { + if (!(ptr = parse_list("dddddcc", &set, seperator, ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern))) + return VP_STRUCTURE_PARAM_ERROR; + } + else +#endif +#if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2) + if (depth == 2) { + if (!(ptr = parse_list("dddddgg", &set, seperator, ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern))) + return VP_STRUCTURE_PARAM_ERROR; + } + else +#endif +#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1) + if (depth == 1) + { + if (!(ptr = parse_list("ddddd", &set, seperator, ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font))) + return VP_STRUCTURE_PARAM_ERROR; + } + else +#endif + {} + + if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) + return VP_STRUCTURE_PARAM_ERROR; + + /* fix defaults */ + if (!LIST_VALUE_PARSED(set, PL_WIDTH)) + vp->width = screens[screen].lcdwidth - vp->x; + if (!LIST_VALUE_PARSED(set, PL_HEIGHT)) + vp->height = screens[screen].lcdheight - vp->y; + +#if (LCD_DEPTH == 16) + if (!LIST_VALUE_PARSED(set, PL_FG)) + vp->fg_pattern = global_settings.fg_color; + if (!LIST_VALUE_PARSED(set, PL_BG)) + vp->bg_pattern = global_settings.bg_color; +#endif + /* Validate the viewport dimensions - we know that the numbers are + non-negative integers */ + if ((vp->x >= screens[screen].lcdwidth) || + ((vp->x + vp->width) > screens[screen].lcdwidth) || + (vp->y >= screens[screen].lcdheight) || + ((vp->y + vp->height) > screens[screen].lcdheight)) + { + return VP_STRUCTURE_PARAM_ERROR; + } + + /* Default to using the user font if the font was an invalid number */ + if ((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI)) + vp->font = FONT_UI; + + return ptr; +} + +/* returns false if defaults are used, due to viewport_parse_viewport failure */ +static bool customlist_init(struct viewport *vp, enum screen_type screen) +{ +#ifdef HAVE_REMOTE_LCD + if (screen= SCREEN_REMOTE) + { + if(!(viewport_parse_viewport(vp, + global_settings.remote_list_vp_config, ',', screen))) + { + return false; + } + } + else +#endif + { + if (!(viewport_parse_viewport(vp, + global_settings.list_vp_config, ',', screen))) + { + return false; + } + } + return true; +} +#endif Index: apps/gui/viewport.h =================================================================== --- apps/gui/viewport.h (Revision 19353) +++ apps/gui/viewport.h (Arbeitskopie) @@ -28,6 +28,9 @@ #include "misc.h" #include "screen_access.h" +void DEBUG_VP(struct viewport vp, char* string); +void DEBUG_VP_PTR(struct viewport *vp, char* string); + /* return the number of text lines in the vp viewport */ int viewport_get_nb_lines(struct viewport *vp); @@ -39,4 +42,8 @@ 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, const bool force_fullscreen); + +const char* viewport_parse_viewport(struct viewport *vp, + const char *ptr, char seperator, enum screen_type screen); Index: apps/gui/wps_parser.c =================================================================== --- apps/gui/wps_parser.c (Revision 19353) +++ apps/gui/wps_parser.c (Arbeitskopie) @@ -26,6 +26,7 @@ #include "file.h" #include "misc.h" #include "plugin.h" +#include "viewport.h" #ifdef __PCTOOL__ #ifdef WPSEDITOR @@ -579,26 +580,6 @@ { (void)token; /* Kill warnings */ const char *ptr = wps_bufptr; - struct viewport* vp; - int depth; - uint32_t set = 0; - enum { - PL_X = 0, - PL_Y, - PL_WIDTH, - PL_HEIGHT, - PL_FONT, - PL_FG, - PL_BG, - }; - int lcd_width = LCD_WIDTH, lcd_height = LCD_HEIGHT; -#ifdef HAVE_REMOTE_LCD - if (wps_data->remote_wps) - { - lcd_width = LCD_REMOTE_WIDTH; - lcd_height = LCD_REMOTE_HEIGHT; - } -#endif if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) return WPS_ERROR_INVALID_PARAM; @@ -627,7 +608,7 @@ return WPS_ERROR_INVALID_PARAM; ptr++; - vp = &wps_data->viewports[wps_data->num_viewports].vp; + struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ /* Set the defaults for fields not user-specified */ @@ -635,80 +616,27 @@ /* Work out the depth of this display */ #ifdef HAVE_REMOTE_LCD - depth = (wps_data->remote_wps ? LCD_REMOTE_DEPTH : LCD_DEPTH); -#else - depth = LCD_DEPTH; -#endif - -#ifdef HAVE_LCD_COLOR - if (depth == 16) + if (!(wps_data->remote_wps)) { - if (!(ptr = parse_list("dddddcc", &set, '|', ptr, &vp->x, &vp->y, &vp->width, - &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern))) - return WPS_ERROR_INVALID_PARAM; - } - else #endif -#if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2) - if (depth == 2) { - /* Default to black on white */ - vp->fg_pattern = 0; - vp->bg_pattern = 3; - if (!(ptr = parse_list("dddddgg", &set, '|', ptr, &vp->x, &vp->y, &vp->width, - &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern))) + if (!(ptr = viewport_parse_viewport(vp, ptr, '|', SCREEN_MAIN))) return WPS_ERROR_INVALID_PARAM; +#ifdef HAVE_REMOTE_LCD } - else -#endif -#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1) - if (depth == 1) + else { - if (!(ptr = parse_list("ddddd", &set, '|', ptr, &vp->x, &vp->y, - &vp->width, &vp->height, &vp->font))) + if (!(ptr = viewport_parse_viewport(vp, ptr, '|', SCREEN_REMOTE))) return WPS_ERROR_INVALID_PARAM; } - else + #endif - {} + /* Check for trailing | */ if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; - if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) - return WPS_ERROR_INVALID_PARAM; - - /* fix defaults */ - if (!LIST_VALUE_PARSED(set, PL_WIDTH)) - vp->width = lcd_width - vp->x; - if (!LIST_VALUE_PARSED(set, PL_HEIGHT)) - vp->height = lcd_height - vp->y; - - /* Default to using the user font if the font was an invalid number */ - if (!LIST_VALUE_PARSED(set, PL_FONT) || - ((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI))) - vp->font = FONT_UI; - /* Validate the viewport dimensions - we know that the numbers are - non-negative integers */ - if ((vp->x >= lcd_width) || - ((vp->x + vp->width) > lcd_width) || - (vp->y >= lcd_height) || - ((vp->y + vp->height) > lcd_height)) - { - return WPS_ERROR_INVALID_PARAM; - } - -#ifdef HAVE_LCD_COLOR - if (depth == 16) - { - if (!LIST_VALUE_PARSED(set, PL_FG)) - vp->fg_pattern = global_settings.fg_color; - if (!LIST_VALUE_PARSED(set, PL_BG)) - vp->bg_pattern = global_settings.bg_color; - } -#endif - wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1; wps_data->viewports[wps_data->num_viewports].first_line = wps_data->num_lines; Index: apps/menu.c =================================================================== --- apps/menu.c (Revision 19353) +++ 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/settings.h =================================================================== --- apps/settings.h (Revision 19353) +++ apps/settings.h (Arbeitskopie) @@ -449,7 +449,12 @@ #endif unsigned char wps_file[MAX_FILENAME+1]; /* last wps */ unsigned char lang_file[MAX_FILENAME+1]; /* last language */ - +#ifdef HAVE_LCD_BITMAP + unsigned char list_vp_config[50]; /* viewport string for the lists */ +#endif +#ifdef HAVE_REMOTE_LCD + unsigned char remote_list_vp_config[50]; /* viewport file for the remote lists */ +#endif /* misc options */ int repeat_mode; /* 0=off 1=repeat all 2=repeat one 3=shuffle 4=ab */ Index: apps/menus/recording_menu.c =================================================================== --- apps/menus/recording_menu.c (Revision 19353) +++ 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, 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 19353) +++ 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, false); #ifdef HAVE_BUTTONBAR if (global_settings.buttonbar) { Index: apps/alarm_menu.c =================================================================== --- apps/alarm_menu.c (Revision 19353) +++ 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/settings_list.c =================================================================== --- apps/settings_list.c (Revision 19353) +++ apps/settings_list.c (Arbeitskopie) @@ -173,6 +173,9 @@ {.custom = (void*)default}, name, NULL, \ {.custom_setting = (struct custom_setting[]){ \ {load_from_cfg, write_to_cfg, is_change, set_default}}}} +#define VIEWPORT_SETTING(var,name,default) \ + TEXT_SETTING(0,var,name,default, NULL, NULL) + /* some sets of values which are used more than once, to save memory */ static const char off_on[] = "off,on"; static const char off_on_ask[] = "off,on,ask"; @@ -1429,6 +1432,13 @@ qs_load_from_cfg, qs_write_to_cfg, qs_is_changed, qs_set_default), #endif + /* Customizable list */ +#ifdef HAVE_LCD_BITMAP + VIEWPORT_SETTING(list_vp_config, "list viewport", ""), +#endif +#ifdef HAVE_REMOTE_LCD + VIEWPORT_SETTING(remote_list_vp_config, "remote list viewport", ""), +#endif }; const int nb_settings = sizeof(settings)/sizeof(*settings); Index: apps/plugin.h =================================================================== --- apps/plugin.h (Revision 19353) +++ apps/plugin.h (Arbeitskopie) @@ -315,7 +315,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, const bool force_fullscreen); /* list */ void (*gui_synclist_init)(struct gui_synclist * lists, list_get_name callback_get_item_name, void * data, Index: wps/WPSLIST =================================================================== --- wps/WPSLIST (Revision 19353) +++ wps/WPSLIST (Arbeitskopie) @@ -68,6 +68,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -80,6 +82,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -92,6 +96,8 @@ viewers iconset: selector type: bar (inverse) Statusbar: on +list viewport: +remote list viewport: @@ -104,6 +110,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -151,6 +159,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -158,6 +168,8 @@ Author: Mike Sobel Font: 13-Nimbus.fnt Statusbar: on +list viewport: +remote list viewport: @@ -172,6 +184,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -203,6 +217,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -225,6 +241,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -256,6 +274,8 @@ iconset: viewers iconset: selector type: bar (inverse) +list viewport: +remote list viewport: @@ -341,6 +361,10 @@ # Whether the WPS is designed to have the statusbar on or off Statusbar: on + +# list & remote list viewports +list viewport: +remote list viewport: Index: wps/wpsbuild.pl =================================================================== --- wps/wpsbuild.pl (Revision 19353) +++ wps/wpsbuild.pl (Arbeitskopie) @@ -51,6 +51,8 @@ my $viewericon; my $lineselecttextcolor; my $filetylecolor; +my $listviewport; +my $remotelistviewport; # LCD sizes my ($main_height, $main_width, $main_depth); @@ -288,6 +290,16 @@ if($rwps && $has_remote ) { push @out, "rwps: /$rbdir/wps/$rwps\n"; } + if(defined($listviewport)) { + if($listviewport eq '') { + push @out, "list viewport:\n"; + } + } + if((defined($remotelistviewport)) && $has_remote) { + if($remotelistviewport eq '') { + push @out, "remote list viewport:\n"; + } + } if(-f "$rbdir/wps/$cfg") { print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; } @@ -342,6 +354,8 @@ undef $viewericon; undef $lineselecttextcolor; undef $filetylecolor; + undef $listviewport; + undef $remotelistviewport; next; } @@ -497,6 +511,12 @@ elsif($l =~ /^filetype colours: *(.*)/i) { $filetylecolor = $1; } + elsif($l =~ /^list viewport: *(.*)/i) { + $listviewport = $1; + } + elsif($l =~ /^remote list viewport: *(.*)/i) { + $remotelistviewport = $1; + } else{ #print "Unknown line: $l!\n"; }