Index: apps/plugins/star.c =================================================================== --- apps/plugins/star.c (Revision 19800) +++ apps/plugins/star.c (Arbeitskopie) @@ -1006,6 +1006,7 @@ "Information","Keys","Quit"); FOR_NB_SCREENS(selection) { + rb->viewportmanager_set_custom_vp(false); rb->viewport_set_defaults(&vp[selection], selection); #if LCD_DEPTH > 1 if (rb->screens[selection]->depth > 1) @@ -1108,6 +1109,8 @@ level--; star_run_game(level); } + + rb->viewportmanager_set_custom_vp(false); return PLUGIN_OK; } Index: apps/settings.c =================================================================== --- apps/settings.c (Revision 19800) +++ apps/settings.c (Arbeitskopie) @@ -66,6 +66,7 @@ #include "filetypes.h" #include "option_select.h" #include "backdrop.h" +#include "viewport.h" #if CONFIG_TUNER #include "radio.h" @@ -968,7 +969,7 @@ #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC enc_global_settings_apply(); #endif - list_init_viewports(NULL); + viewportmanager_init_custom_vp(); } Index: apps/gui/bitmap/list.c =================================================================== --- apps/gui/bitmap/list.c (Revision 19800) +++ apps/gui/bitmap/list.c (Arbeitskopie) @@ -81,7 +81,7 @@ 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; + title_text[screen].x = title_icon.width + title_icon.x; display->set_viewport(&title_icon); screen_put_icon(display, 0, 0, list->title_icon); Index: apps/gui/gwps-common.c =================================================================== --- apps/gui/gwps-common.c (Revision 19800) +++ apps/gui/gwps-common.c (Arbeitskopie) @@ -85,7 +85,6 @@ if (wps->data->wps_sb_tag) draw = wps->data->show_sb_on_wps; -#if NB_SCREENS > 1 /* multi screen targets could show the bars on one screen but not both * so the viewportmanager can't be used in its current form... * Also, the WPS is a special screen so doing this is reasonable. @@ -93,12 +92,13 @@ if (draw) { struct gui_statusbar *bar; +#if NB_SCREENS > 1 bar = &statusbars.statusbars[wps->data->remote_wps?SCREEN_REMOTE:SCREEN_MAIN]; +#else + bar = &statusbars.statusbars[SCREEN_MAIN]; +#endif gui_statusbar_draw(bar, force); } -#else - viewportmanager_set_statusbar(draw); -#endif } #else #define gui_wps_statusbar_draw(wps, force) viewportmanager_set_statusbar(true) @@ -366,7 +366,6 @@ } #endif #endif - gui_wps[i].display->clear_display(); if (!gui_wps[i].data->wps_loaded) { if ( !gui_wps[i].data->num_tokens ) { Index: apps/gui/statusbar.c =================================================================== --- apps/gui/statusbar.c (Revision 19800) +++ apps/gui/statusbar.c (Arbeitskopie) @@ -262,10 +262,11 @@ memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info))) { struct viewport vp; - viewport_set_defaults(&vp, display->screen_type); + viewport_set_fullscreen(&vp, display->screen_type); vp.height = STATUSBAR_HEIGHT; vp.x = STATUSBAR_X_POS; vp.y = STATUSBAR_Y_POS; + vp.width = display->lcdwidth; display->set_viewport(&vp); display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); display->fillrect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); Index: apps/gui/list.c =================================================================== --- apps/gui/list.c (Revision 19800) +++ apps/gui/list.c (Arbeitskopie) @@ -68,12 +68,13 @@ void list_init_viewports(struct gui_synclist *list) { int i; - struct viewport *vp; FOR_NB_SCREENS(i) { - vp = &parent[i]; - if (!list || list->parent[i] == vp) - viewport_set_defaults(vp, i); + if (list->parent[i] == &parent[i]) + { + viewportmanager_set_custom_vp(true); + viewport_set_defaults(list->parent[i], i); + } } #ifdef HAVE_BUTTONBAR if (list && (list->parent[0] == &parent[0]) && global_settings.buttonbar) Index: apps/gui/viewport.c =================================================================== --- apps/gui/viewport.c (Revision 19800) +++ apps/gui/viewport.c (Arbeitskopie) @@ -34,8 +34,26 @@ #include "statusbar.h" #include "screen_access.h" #include "appevents.h" +#include "debug.h" +#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); +} + + static bool statusbar_enabled = true; +#ifdef HAVE_LCD_BITMAP +static bool custom_vp_enabled = true; +static struct viewport custom_vp[NB_SCREENS]; +#endif int viewport_get_nb_lines(struct viewport *vp) { @@ -47,8 +65,8 @@ #endif } - -void viewport_set_defaults(struct viewport *vp, enum screen_type screen) +/* fullscreen means possibly reduced by the height of the statusbar */ +void viewport_set_fullscreen(struct viewport *vp, enum screen_type screen) { vp->x = 0; vp->width = screens[screen].lcdwidth; @@ -86,6 +104,23 @@ #endif } +#ifdef HAVE_LCD_BITMAP +static void viewport_set_custom_vp(struct viewport *vp, enum screen_type screen) +{ + *vp = custom_vp[screen]; +} +#endif /* HAVE_LCD_BITMAP */ + +void viewport_set_defaults(struct viewport *vp, enum screen_type screen) +{ +#ifdef HAVE_LCD_BITMAP + if (custom_vp_enabled) + viewport_set_custom_vp(vp, screen); + else +#endif + viewport_set_fullscreen(vp, screen); +} + /* returns true if it was enabled BEFORE this call */ bool viewportmanager_set_statusbar(bool enabled) { @@ -97,7 +132,16 @@ ) { add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_draw_statusbars); - gui_syncstatusbar_draw(&statusbars, true); + if (!old) + { + int i; + FOR_NB_SCREENS(i) + { + screens[i].clear_display(); + screens[i].update(); + } + gui_syncstatusbar_draw(&statusbars, true); + } } else { @@ -119,3 +163,149 @@ (void)data; viewportmanager_set_statusbar(statusbar_enabled); } + +void viewportmanager_set_custom_vp(const bool enable) +{ +#if 0 + if (!custom_vp_enabled && enable) + { /* if leaving a fullscreen screen to a smaller one the screen needs to + be cleared so that dead parts are removed */ + int i; + FOR_NB_SCREENS(i) + { + debugf("cleared\n"); + screens[i].clear_display(); + screens[i].update(); + if (statusbar_enabled) + gui_syncstatusbar_draw(&statusbars, true); + } + } +#endif + custom_vp_enabled = enable; +} + +#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, + }; + + /* 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_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_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_ERROR; + } + else +#endif + {} + + if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) + return VP_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_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; + + /* Lastly, clip it to the statusbar */ + if(global_settings.statusbar && vp->y < STATUSBAR_HEIGHT) + { + int offset = STATUSBAR_HEIGHT - vp->y; + vp->y += offset; + vp->height -= offset; + } + return ptr; +} + +/* returns 0 if defaults are used, due to viewport_parse_viewport failure */ +int viewportmanager_init_custom_vp(void) +{ + int screen; + FOR_NB_SCREENS(screen) + { +#ifdef HAVE_REMOTE_LCD + if (screen= SCREEN_REMOTE) + { + if(!(viewport_parse_viewport(&custom_vp[screen], + global_settings.remote_list_vp_config, ',', screen))) + { + viewport_set_fullscreen(&custom_vp[screen], screen); + return 0; + } + } + else +#endif + { + if (!(viewport_parse_viewport(&custom_vp[screen], + global_settings.list_vp_config, ',', screen))) + { + viewport_set_fullscreen(&custom_vp[screen], screen); + return 0; + } + } + } + /* shedule a full screen redraw, will be done a bit later */ + viewportmanager_set_custom_vp(false); + return 1; +} + +#endif /* HAVE_LCD_BITMAP */ Index: apps/gui/gwps.c =================================================================== --- apps/gui/gwps.c (Revision 19800) +++ apps/gui/gwps.c (Arbeitskopie) @@ -127,7 +127,8 @@ bool update_track = false; int i; long last_left = 0, last_right = 0; - + + viewportmanager_set_custom_vp(false); viewportmanager_set_statusbar(false); wps_state_init(); @@ -293,9 +294,9 @@ #endif FOR_NB_SCREENS(i) gui_wps[i].display->stop_scroll(); + viewportmanager_set_statusbar(true); return GO_TO_PREVIOUS_BROWSER; break; - /* play/pause */ case ACTION_WPS_PLAY: if (global_settings.party_mode) Index: apps/gui/viewport.h =================================================================== --- apps/gui/viewport.h (Revision 19800) +++ apps/gui/viewport.h (Arbeitskopie) @@ -27,7 +27,11 @@ #include "system.h" #include "misc.h" #include "screen_access.h" +#include "debug.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); @@ -40,9 +44,14 @@ int viewport_load_config(const char *config, struct viewport *vp); void viewport_set_defaults(struct viewport *vp, enum screen_type screen); +void viewport_set_fullscreen(struct viewport *vp, enum screen_type screen); bool viewportmanager_set_statusbar(bool enabled); +void viewportmanager_set_custom_vp(const bool enable); /* callbacks for GUI_EVENT_* events */ void viewportmanager_draw_statusbars(void*data); void viewportmanager_statusbar_changed(void* data); +const char* viewport_parse_viewport(struct viewport *vp, + const char *ptr, char seperator, enum screen_type screen); +int viewportmanager_init_custom_vp(void); Index: apps/gui/wps_parser.c =================================================================== --- apps/gui/wps_parser.c (Revision 19800) +++ 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 @@ -584,26 +585,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; @@ -632,7 +613,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 */ @@ -640,80 +621,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/settings.h =================================================================== --- apps/settings.h (Revision 19800) +++ apps/settings.h (Arbeitskopie) @@ -741,6 +741,12 @@ /* If values are just added to the end, no need to bump plugin API version. */ /* new stuff to be added at the end */ +#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 }; /** global variables **/ Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (Revision 19800) +++ apps/settings_list.c (Arbeitskopie) @@ -177,6 +177,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"; @@ -1459,6 +1462,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.c =================================================================== --- apps/plugin.c (Revision 19800) +++ apps/plugin.c (Arbeitskopie) @@ -627,6 +627,7 @@ appsversion, /* new stuff at the end, sort into place next time the API gets incompatible */ + viewportmanager_set_custom_vp, }; int plugin_load(const char* plugin, const void* parameter) @@ -742,7 +743,7 @@ oldbars = viewportmanager_set_statusbar(false); rc = hdr->entry_point(parameter); - + viewportmanager_set_statusbar(true); button_clear_queue(); Index: apps/plugin.h =================================================================== --- apps/plugin.h (Revision 19800) +++ apps/plugin.h (Arbeitskopie) @@ -782,6 +782,7 @@ const char *appsversion; /* new stuff at the end, sort into place next time the API gets incompatible */ + void (*viewportmanager_set_custom_vp)(const bool enable); }; /* plugin header */ Index: apps/root_menu.c =================================================================== --- apps/root_menu.c (Revision 19800) +++ apps/root_menu.c (Arbeitskopie) @@ -47,7 +47,6 @@ #include "buttonbar.h" #include "action.h" #include "yesno.h" -#include "viewport.h" #include "tree.h" #if CONFIG_TUNER @@ -269,8 +268,6 @@ #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif - /* always re-enable the statusbar after the WPS */ - viewportmanager_set_statusbar(true); return ret_val; } #if CONFIG_TUNER Index: wps/WPSLIST =================================================================== --- wps/WPSLIST (Revision 19800) +++ 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 19800) +++ 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,12 @@ if($rwps && $has_remote ) { push @out, "rwps: /$rbdir/wps/$rwps\n"; } + if(defined($listviewport)) { + push @out, "list viewport: $listviewport\n"; + } + if(defined($remotelistviewport) && $has_remote) { + push @out, "remote list viewport: $listviewport\n"; + } if(-f "$rbdir/wps/$cfg") { print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; } @@ -342,6 +350,8 @@ undef $viewericon; undef $lineselecttextcolor; undef $filetylecolor; + undef $listviewport; + undef $remotelistviewport; next; } @@ -497,6 +507,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"; }