Index: apps/gui/bitmap/list.c =================================================================== --- apps/gui/bitmap/list.c (Revision 17518) +++ apps/gui/bitmap/list.c (Arbeitskopie) @@ -39,11 +39,18 @@ #include "misc.h" #include "talk.h" #include "viewport.h" +// define for some debugging info +/* +#define USE_DEBUG +*/ +#ifdef USE_DEBUG +#include "debug.h" +#endif #define SCROLLBAR_WIDTH 6 #define ICON_PADDING 1 -static struct viewport title_text[NB_SCREENS], title_icons[NB_SCREENS], +static struct viewport list_info[NB_SCREENS],title_text[NB_SCREENS], title_icons[NB_SCREENS], list_text[NB_SCREENS], list_icons[NB_SCREENS]; /* should probably be moved somewhere else */ @@ -57,6 +64,7 @@ struct viewport *vp); bool list_display_title(struct gui_synclist *list, struct viewport *vp); + /* Draw the list... internal screen layout: ----------------- @@ -71,12 +79,43 @@ static bool draw_title(struct screen *display, struct viewport *parent, struct gui_synclist *list) { + struct viewport *list_infos = &list_info[display->screen_type]; +#ifdef HAVE_REMOTE_LCD + if (display->screen_type == SCREEN_REMOTE) + { + if(!(viewport_parse_viewport(list_infos, + global_settings.remote_list_vp_config, ',', display->screen_type))) + viewport_set_defaults(list_infos,display->screen_type); + } + else +#endif + { + if ((!(viewport_parse_viewport(list_infos, + global_settings.list_vp_config, ',', display->screen_type))) && + display->screen_type == SCREEN_MAIN) + viewport_set_defaults(list_infos,display->screen_type); + } + +#ifdef USE_DEBUG + DEBUGF("list_infos->x:\t%d\n\n",list_infos->x); +#endif struct viewport *vp_icons = &title_icons[display->screen_type]; struct viewport *vp_text = &title_text[display->screen_type]; if (!list_display_title(list, parent)) return false; *vp_text = *parent; - vp_text->height = list_title_height(list, parent); + + vp_text->x = list_infos->x; + vp_text->y = list_infos->y; + vp_text->font = list_infos->font; + vp_text->fg_pattern = list_infos->fg_pattern; + vp_text->bg_pattern = list_infos->bg_pattern; + + + if (global_settings.statusbar && (vp_text->y < STATUSBAR_HEIGHT)) + vp_text->y = STATUSBAR_HEIGHT; + vp_text->height = font_get(vp_text->font)->height; + vp_text->width = list_infos->width; if (list->title_icon != Icon_NOICON && global_settings.show_icons) { *vp_icons = *vp_text; @@ -84,12 +123,20 @@ + 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->width -= vp_icons->width; + vp_text->x += vp_icons->width; + display->set_viewport(vp_icons); screen_put_icon(display, 0, 0, list->title_icon); } +#ifdef USE_DEBUG + DEBUGF("Global settings:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n", + list_infos->x, list_infos->y, + list_infos->width,list_infos->height); + DEBUGF("Titel viewport:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n", + vp_text->x,vp_text->y,vp_text->width,vp_text->height); +#endif + display->set_viewport(vp_text); vp_text->drawmode = STYLE_DEFAULT; #ifdef HAVE_LCD_COLOR @@ -105,6 +152,27 @@ void list_draw(struct screen *display, struct viewport *parent, struct gui_synclist *list) { + struct viewport *list_infos = &list_info[display->screen_type]; + +#ifdef HAVE_REMOTE_LCD + if (display->screen_type == SCREEN_REMOTE) + { + if(!(viewport_parse_viewport(list_infos, + global_settings.remote_list_vp_config, ',', display->screen_type))) + { + viewport_set_defaults(list_infos,display->screen_type); + } + } + else +#endif + { + if ((!(viewport_parse_viewport(list_infos, + global_settings.list_vp_config, ',', display->screen_type))) && + display->screen_type == SCREEN_MAIN) + { + viewport_set_defaults(list_infos,display->screen_type); + } + } int start, end, line_height, i; int icon_width = get_icon_width(display->screen_type) + ICON_PADDING; bool show_cursor = !global_settings.cursor_style && @@ -119,28 +187,64 @@ display->clear_viewport(); display->stop_scroll(); list_text[display->screen_type] = *parent; + + list_text[display->screen_type].font = list_infos->font; + list_text[display->screen_type].fg_pattern = list_infos->fg_pattern; + list_text[display->screen_type].bg_pattern = list_infos->bg_pattern; + + line_height = font_get((list_text[display->screen_type]).font)->height; + list_text[display->screen_type].width = list_infos->width; + list_text[display->screen_type].x = list_infos->x; + list_text[display->screen_type].height = list_infos->height; + list_text[display->screen_type].y = list_infos->y; + + /* move list a bit down if needed */ + if (global_settings.statusbar && (list_infos->y < STATUSBAR_HEIGHT)) + { + list_text[display->screen_type].y += STATUSBAR_HEIGHT; + list_text[display->screen_type].height -= STATUSBAR_HEIGHT; + } + if ((show_title = draw_title(display, parent, 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 += + (font_get(list_infos->font)->height); + list_text[display->screen_type].height -= + (font_get(list_infos->font)->height); } - +#ifdef USE_DEBUG + DEBUGF("List Text:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n", + list_text[display->screen_type].x,list_text[display->screen_type].y, + list_text[display->screen_type].width,list_text[display->screen_type].height); +#endif start = list->start_item[display->screen_type]; end = start + viewport_get_nb_lines(&list_text[display->screen_type]); - + /* draw the scrollbar if its needed */ - if (global_settings.scrollbar && - viewport_get_nb_lines(&list_text[display->screen_type]) < list->nb_items) + bool draw_scrollbar = (global_settings.scrollbar && + viewport_get_nb_lines(&list_text[display->screen_type]) + < list->nb_items); +#ifdef USE_DEBUG + DEBUGF("nb_items:\t%d\n",list->nb_items); +#endif + if (draw_scrollbar) { struct viewport vp; vp = list_text[display->screen_type]; + vp.x = list_infos->x; vp.width = SCROLLBAR_WIDTH; - list_text[display->screen_type].width -= SCROLLBAR_WIDTH; - list_text[display->screen_type].x += SCROLLBAR_WIDTH; - vp.height = line_height * - viewport_get_nb_lines(&list_text[display->screen_type]); - vp.x = parent->x; + list_text[display->screen_type].width -= vp.width; + list_text[display->screen_type].x += vp.width; + + /* shorten scrollbar to fit the lines */ + vp.height = line_height * + viewport_get_nb_lines(&list_text[display->screen_type]); +#ifdef USE_DEBUG + DEBUGF("vp_get_nb_lines:\t%d\n",viewport_get_nb_lines(&list_text[display->screen_type])); + DEBUGF("Scrollbar:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n",vp.x,vp.y,vp.width,vp.height); +#endif display->set_viewport(&vp); + gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, vp.height, list->nb_items, list->start_item[display->screen_type], @@ -153,7 +257,7 @@ list_text[display->screen_type].width -= SCROLLBAR_WIDTH; list_text[display->screen_type].x += SCROLLBAR_WIDTH; } - + /* setup icon placement */ list_icons[display->screen_type] = list_text[display->screen_type]; int icon_count = global_settings.show_icons && Index: apps/gui/list.c =================================================================== --- apps/gui/list.c (Revision 17518) +++ apps/gui/list.c (Arbeitskopie) @@ -38,6 +38,13 @@ #include "talk.h" #include "viewport.h" #include "list.h" +// define for some debugging info +/* +#define USE_DEBUG +*/ +#ifdef USE_DEBUG +#include "debug.h" +#endif #ifdef HAVE_LCD_CHARCELLS #define SCROLL_LIMIT 1 @@ -62,7 +69,7 @@ void list_draw(struct screen *display, struct viewport *parent, struct gui_synclist *list); #ifdef HAVE_LCD_BITMAP -static struct viewport parent[NB_SCREENS]; +static struct viewport list_info[NB_SCREENS], parent[NB_SCREENS]; void list_init_viewports(struct gui_synclist *list) { int i; @@ -177,7 +184,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) @@ -246,15 +252,43 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, enum screen_type screen) { + int nb_lines; int difference = gui_list->selected_item - gui_list->start_item[screen]; +#ifndef HAVE_LCD_BITMAP struct viewport vp = *gui_list->parent[screen]; -#ifdef HAVE_LCD_BITMAP + nb_lines = viewport_get_nb_lines(&vp); +#else + struct viewport *list_infos = &(list_info[screen]); + +#ifdef HAVE_REMOTE_LCD + if (screen == SCREEN_REMOTE) + { + if (!(viewport_parse_viewport(list_infos, + global_settings.remote_list_vp_config, ',', screen))) + viewport_set_defaults(list_infos, screen); + } + else +#endif + { + if (!(viewport_parse_viewport(list_infos, + global_settings.list_vp_config, ',', screen))) + viewport_set_defaults(list_infos, screen); + } + /* shorten height depending on statusbar and list title */ + if (global_settings.statusbar) + { + list_infos->height -= STATUSBAR_HEIGHT; + } if (list_display_title(gui_list, gui_list->parent[screen])) - vp.height -= list_title_height(gui_list,gui_list->parent[screen]); + { + list_infos->height -= font_get(list_infos->font)->height; + } + nb_lines = viewport_get_nb_lines(list_infos); #endif - nb_lines = viewport_get_nb_lines(&vp); - +#ifdef USE_DEBUG +DEBUGF("nb_lines:\t%d\n\n", nb_lines); +#endif /* edge case,, selected last item */ if (gui_list->selected_item == gui_list->nb_items -1) { @@ -347,12 +381,36 @@ int i, nb_lines, screen_top; FOR_NB_SCREENS(i) { +#ifndef HAVE_LCD_BITMAP struct viewport vp = *gui_list->parent[i]; -#ifdef HAVE_LCD_BITMAP + nb_lines = viewport_get_nb_lines(&vp); +#else + struct viewport *list_infos = &(list_info[i]); +#ifdef HAVE_REMOTE_LCD + if (i == SCREEN_REMOTE) + { + if (!(viewport_parse_viewport(list_infos, + global_settings.remote_list_vp_config, ',', i))) + viewport_set_defaults(list_infos, i); + } + else +#endif + { + if (!(viewport_parse_viewport(list_infos, + global_settings.list_vp_config, ',', i))) + viewport_set_defaults(list_infos, i); + } + if (global_settings.statusbar) + { + list_infos->height -= STATUSBAR_HEIGHT; + } if (list_display_title(gui_list, gui_list->parent[i])) - vp.height -= list_title_height(gui_list,gui_list->parent[i]); + { + list_infos->height -= font_get(list_infos->font)->height; + } + nb_lines = viewport_get_nb_lines(list_infos); + #endif - nb_lines = viewport_get_nb_lines(&vp); if (offset > 0) { screen_top = gui_list->nb_items-nb_lines; Index: apps/gui/viewport.c =================================================================== --- apps/gui/viewport.c (Revision 17518) +++ apps/gui/viewport.c (Arbeitskopie) @@ -32,6 +32,8 @@ #include "statusbar.h" #include "screen_access.h" +#define VP_STRUCTURE_PARAM_ERROR 0 + int viewport_get_nb_lines(struct viewport *vp) { #ifdef HAVE_LCD_BITMAP @@ -42,7 +44,6 @@ #endif } - void viewport_set_defaults(struct viewport *vp, enum screen_type screen) { vp->xmargin = 0; @@ -82,3 +83,63 @@ } #endif } + +#ifdef HAVE_LCD_BITMAP + +/* Generic viewport parsing function to parse viewports structures like + * the %V tag */ +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; + + /* Work out the depth of this display */ + depth = screens[screen].depth; +#ifdef HAVE_LCD_COLOR + if (depth == 16) + { + if (!(ptr = parse_list("dddddcc", 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", 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", seperator, ptr, &vp->x, &vp->y, &vp->width, + &vp->height, &vp->font))) + return VP_STRUCTURE_PARAM_ERROR; + } + else +#endif + {} + /* Validate the viewport dimensions - we know that the numbers are + non-negative integers */ + if ((vp->x >= screens[screen].width) || + ((vp->x + vp->width) > screens[screen].width) || + (vp->y >= screens[screen].height) || + ((vp->y + vp->height) > screens[screen].height)) + { + 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; +} + +#endif Index: apps/gui/viewport.h =================================================================== --- apps/gui/viewport.h (Revision 17518) +++ apps/gui/viewport.h (Arbeitskopie) @@ -38,3 +38,6 @@ int viewport_load_config(const char *config, struct viewport *vp); void viewport_set_defaults(struct viewport *vp, enum screen_type screen); + +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 17518) +++ apps/gui/wps_parser.c (Arbeitskopie) @@ -23,6 +23,7 @@ #include "gwps.h" #include "file.h" #include "misc.h" +#include "viewport.h" #ifdef __PCTOOL__ #define DEBUGF printf #define FONT_SYSFIXED 0 @@ -540,9 +541,6 @@ struct wps_data *wps_data) { const char *ptr = wps_bufptr; - struct viewport* vp; - int depth; - (void)token; /* Kill warnings */ if (*wps_bufptr != '|') @@ -550,86 +548,35 @@ ptr = wps_bufptr + 1; /* format: %V|x|y|width|height|fg_pattern|bg_pattern| */ - if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) return WPS_ERROR_INVALID_PARAM; wps_data->num_viewports++; - vp = &wps_data->viewports[wps_data->num_viewports].vp; + struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; /* Set the defaults for fields not user-specified */ vp->drawmode = DRMODE_SOLID; vp->xmargin = 0; vp->ymargin = 0; - - /* 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", '|', 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) { - if (!(ptr = parse_list("dddddgg", '|', 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", '|', 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; - /* 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; - - /* Validate the viewport dimensions - we know that the numbers are - non-negative integers */ -#ifdef HAVE_REMOTE_LCD - if (wps_data->remote_wps) - { - if ((vp->x >= LCD_REMOTE_WIDTH) || - ((vp->x + vp->width) > LCD_REMOTE_WIDTH) || - (vp->y >= LCD_REMOTE_HEIGHT) || - ((vp->y + vp->height) > LCD_REMOTE_HEIGHT)) - { - return WPS_ERROR_INVALID_PARAM; - } - } - else -#endif - { - 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; - } - } - 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 17518) +++ apps/settings.h (Arbeitskopie) @@ -421,7 +421,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[MAX_PATH+1]; /* viewport file for the lists */ +#endif +#ifdef HAVE_REMOTE_LCD + unsigned char remote_list_vp_config[MAX_PATH+1]; /* viewport file for the lists */ +#endif /* misc options */ int repeat_mode; /* 0=off 1=repeat all 2=repeat one 3=shuffle 4=ab */ Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (Revision 17518) +++ apps/settings_list.c (Arbeitskopie) @@ -106,7 +106,6 @@ CHARPTR(default),name,NULL, \ {.filename_setting= \ (struct filename_setting[]){{prefix,suffix,len}}} } - /* Used for settings which use the set_option() setting screen. The ... arg is a list of pointers to strings to display in the setting screen. These can either be literal strings, or ID2P(LANG_*) */ @@ -158,6 +157,9 @@ {cb, formatter, get_talk_id, unit, count, \ (const int[]){__VA_ARGS__}}}}} +#define VIEWPORT_SETTING(var,name,default, max_length) \ + FILENAME_SETTING(0,var,name,default, NULL, NULL, max_length) + /* 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"; @@ -1322,6 +1324,14 @@ #endif /* CONFIG_CODEC == SWCODEC */ FILENAME_SETTING(0, playlist_catalog_dir, "playlist catalog directory", PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL, MAX_FILENAME+1), + + /* Customizable list */ +#ifdef HAVE_LCD_BITMAP + VIEWPORT_SETTING(list_vp_config, "list viewport", "",34), +#endif +#ifdef HAVE_REMOTE_LCD + VIEWPORT_SETTING(remote_list_vp_config, "remote list viewport", "",34), +#endif }; const int nb_settings = sizeof(settings)/sizeof(*settings); Index: wps/WPSLIST =================================================================== --- wps/WPSLIST (Revision 17518) +++ 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: nimbus-13.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 17518) +++ wps/wpsbuild.pl (Arbeitskopie) @@ -258,6 +258,16 @@ if($rwps && $has_remote ) { push @out, "rwps: /.rockbox/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 ".rockbox/wps/$cfg") { print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; } @@ -308,6 +318,8 @@ undef $viewericon; undef $lineselecttextcolor; undef $filetylecolor; + undef $listviewport; + undef $remotelistviewport; next; } @@ -463,6 +475,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"; }