Index: apps/gui/bitmap/list.c =================================================================== --- apps/gui/bitmap/list.c (Revision 16821) +++ apps/gui/bitmap/list.c (Arbeitskopie) @@ -40,6 +40,13 @@ #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 @@ -59,6 +66,14 @@ struct viewport *vp); bool list_display_title(struct gui_synclist *list, struct viewport *vp); +/* This will contain the information about the list dimensions */ +struct list_dimension { + int xpos; + int ypos; + int width; + int height; +} list_dimensions; + /* Draw the list... internal screen layout: ----------------- @@ -73,40 +88,69 @@ static bool draw_title(struct screen *display, struct viewport *parent, struct gui_synclist *list) { - struct viewport *vp_icons = &title_icons[display->screen_type]; - struct viewport *vp_text = &title_text[display->screen_type]; +#ifdef USE_DEBUG + DEBUGF("list_dimensions.xpos:\t%d\n\n",list_dimensions.xpos); +#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 = *parent; + + + vp_text.x = list_dimensions.xpos; + vp_text.y = list_dimensions.ypos; + + + if (global_settings.statusbar && (vp_text.y < STATUSBAR_HEIGHT)) + vp_text.y = STATUSBAR_HEIGHT; + vp_text.height = list_title_height(list, parent); + vp_text.width = list_dimensions.width; if (list->title_icon != Icon_NOICON && global_settings.show_icons) { - *vp_icons = *vp_text; - vp_icons->width = get_icon_width(display->screen_type) + vp_icons = vp_text; + vp_icons.width = get_icon_width(display->screen_type) + ICON_PADDING*2; - vp_icons->x += ICON_PADDING; + 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); + 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); } - display->set_viewport(vp_text); - vp_text->drawmode = STYLE_DEFAULT; +#ifdef USE_DEBUG + DEBUGF("Global settings:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n", + list_dimensions.xpos, list_dimensions.ypos, + list_dimensions.width,list_dimensions.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 if (list->title_color >= 0) { - vp_text->drawmode |= (STYLE_COLORED|list->title_color);} + vp_text.drawmode |= (STYLE_COLORED|list->title_color);} #endif display->puts_scroll_style_offset(0, 0, list->title, - vp_text->drawmode, 0); + vp_text.drawmode, 0); return true; } void list_draw(struct screen *display, struct viewport *parent, struct gui_synclist *list) { + /* FIXME: default values defined here instead of in settings_list */ + list_dimensions.xpos = 0; + list_dimensions.ypos = 0; + list_dimensions.width = LCD_WIDTH; + list_dimensions.height = LCD_HEIGHT; + /* load user defined list dimensions with this macro (see list.h) */ + parse_list_list_viewport(list_dimensions.xpos,list_dimensions.ypos, + list_dimensions.width,list_dimensions.height); + int start, end, line_height, i; int icon_width = get_icon_width(display->screen_type) + ICON_PADDING; bool show_cursor = !global_settings.cursor_style && @@ -116,33 +160,57 @@ #endif int item_offset; bool show_title; + int statusbar = global_settings.statusbar?STATUSBAR_HEIGHT+1:0; line_height = font_get(parent->font)->height; display->set_viewport(parent); display->clear_viewport(); display->stop_scroll(); list_text[display->screen_type] = *parent; + + list_text[display->screen_type].width = list_dimensions.width; + list_text[display->screen_type].x = list_dimensions.xpos; + list_text[display->screen_type].height = list_dimensions.height - statusbar; + list_text[display->screen_type].y = list_dimensions.ypos + + ((list_dimensions.ypos < statusbar)?statusbar:0); 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); } - +#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]; + /* looks nicer with 1pix indent if listxpos == 0 */ + vp.x = (list_dimensions.xpos) + (list_dimensions.xpos?0:1); 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], @@ -155,7 +223,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 16821) +++ apps/gui/list.c (Arbeitskopie) @@ -246,12 +246,22 @@ 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]; struct viewport vp = *gui_list->parent[screen]; #ifdef HAVE_LCD_BITMAP + /* a,b and c are dummys actually not needed here */ + char a,b,c; + int list_dimensions_height; + list_dimensions_height = LCD_HEIGHT; + parse_list_list_viewport(a,b,c,list_dimensions_height); + vp.height = list_dimensions_height; if (list_display_title(gui_list, gui_list->parent[screen])) + { vp.height -= list_title_height(gui_list,gui_list->parent[screen]); + } + vp.height -= (global_settings.statusbar?STATUSBAR_HEIGHT+1:0); #endif nb_lines = viewport_get_nb_lines(&vp); Index: apps/gui/list.h =================================================================== --- apps/gui/list.h (Revision 16821) +++ apps/gui/list.h (Arbeitskopie) @@ -26,6 +26,13 @@ #define SCROLLBAR_WIDTH 6 +/* macro used to parse the user definable list dimensions in the config.cfg; + * needs to be extended (or replaced ;)) when more setting are available */ +#ifdef HAVE_LCD_BITMAP +#define parse_list_list_viewport(a,b,c,d) \ + const char *ptr = (global_settings.list_vp_config); \ + parse_list("dddd",'|',ptr, &a, &b, &c, &d); +#endif enum list_wrap { LIST_WRAP_ON = 0, LIST_WRAP_OFF, Index: apps/settings.h =================================================================== --- apps/settings.h (Revision 16821) +++ apps/settings.h (Arbeitskopie) @@ -419,7 +419,14 @@ #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 +#if 0 /* FIXME: handle remotes with custom list dimensions */ +#ifdef HAVE_REMOTE_LCD + unsigned char remote_list_vp_config[MAX_PATH+1]; /* viewport file for the lists */ +#endif +#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 16821) +++ apps/settings_list.c (Arbeitskopie) @@ -1233,6 +1236,18 @@ #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 + FILENAME_SETTING(F_THEMESETTING, list_vp_config, "list viewport", "", + NULL, NULL, MAX_PATH+1), +#endif +#if 0 /* FIXME: handle remotes with custom list dimensions */ +#ifdef HAVE_REMOTE_LCD + FILENAME_SETTING(F_THEMESETTING, remote_list_vp_config, "remote list viewport", "", + NULL, NULL, MAX_PATH+1), +#endif +#endif }; const int nb_settings = sizeof(settings)/sizeof(*settings);