All pastes #959954 Raw Edit

Meins

public diff v1 · immutable
#959954 ·published 2008-03-27 19:59 UTC
rendered paste body
Index: apps/gui/bitmap/list.c===================================================================--- apps/gui/bitmap/list.c	(Revision 16838)+++ apps/gui/bitmap/list.c	(Arbeitskopie)@@ -40,12 +40,19 @@ #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  /* globals */-struct viewport title_text[NB_SCREENS], title_icons[NB_SCREENS],+struct viewport list_dimension[NB_SCREENS],title_text[NB_SCREENS], title_icons[NB_SCREENS],                 list_text[NB_SCREENS], list_icons[NB_SCREENS];  /* should probably be moved somewhere else */@@ -59,6 +66,16 @@                              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,12 +90,29 @@ static bool draw_title(struct screen *display, struct viewport *parent,                        struct gui_synclist *list) {+    struct viewport *list_dimensions = &list_dimension[display->screen_type];+    if(!(viewport_parse_viewport(list_dimensions,+             global_settings.list_vp_config)))//, display->screen_type)))+        viewport_set_defaults(list_dimensions,display->screen_type);+    +#ifdef USE_DEBUG+    DEBUGF("list_dimensions->x:\t%d\n\n",list_dimensions->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->x = list_dimensions->x;+    vp_text->y = list_dimensions->y;++    +    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;@@ -86,12 +120,22 @@                           + 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_dimensions.x, list_dimensions.y,+            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@@ -107,6 +151,11 @@ void list_draw(struct screen *display, struct viewport *parent,                struct gui_synclist *list) {+    struct viewport *list_dimensions = &list_dimension[display->screen_type];+    if(!(viewport_parse_viewport(list_dimensions,+            global_settings.list_vp_config)))//,display->screen_type)))+        viewport_set_defaults(list_dimensions,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 &&@@ -116,33 +165,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->x;+    list_text[display->screen_type].height = list_dimensions->height - statusbar;+    list_text[display->screen_type].y = list_dimensions->y ++             ((list_dimensions->y < 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->x) + (list_dimensions->x?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 +228,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 16838)+++ 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/viewport.c===================================================================--- apps/gui/viewport.c	(Revision 16838)+++ apps/gui/viewport.c	(Arbeitskopie)@@ -31,7 +31,10 @@ #include "viewport.h" #include "statusbar.h" #include "screen_access.h"+#include "debug.h" +#define VP_STRUCTURE_PARAM_ERROR 0+ int viewport_get_nb_lines(struct viewport *vp) { #ifdef HAVE_LCD_BITMAP@@ -82,3 +85,60 @@     } #endif }++int viewport_parse_viewport(struct viewport *vp,+         const char *bufptr)//, enum screen_type screen)+{+/*++#ifndef HAVE_REMOTE_LCD+    void(screen);+#endif+*/+    DEBUGF("Bis hier NP\n");+    const char *ptr = bufptr;+#if (LCD_DEPTH > 2)+    if (!(ptr = parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width,+            &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern+            )))+            +#endif+#if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2)+    if (!(ptr = parse_list("dddddgg", '|', ptr, &vp->x, &vp->y, &vp->width,+            &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern)))+#endif+#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)+    if (!(ptr = (parse_list("ddddd", '|', ptr, &vp->x, &vp->y, &vp->width,+                                                  &vp->height, &vp->font)))+#endif+        return VP_STRUCTURE_PARAM_ERROR;+++    /* Validate the viewport dimensions - we know that the numbers are+       non-negative integers */+#ifdef HAVE_REMOTE_LCD+    if (screen == SCREEN_REMOTE)+    {+        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 VP_STRUCTURE_PARAM_ERROR;+        }+    }+    else+#endif+    {+        if ((vp->x >= LCD_WIDTH) ||+            ((vp->x + vp->width) > LCD_WIDTH) ||+            (vp->y >= LCD_HEIGHT) ||+            ((vp->y + vp->height) > LCD_HEIGHT))+        {+            return VP_STRUCTURE_PARAM_ERROR;+        }+    }++    DEBUGF("Alles ok in viewport.c\n");+    return 1;+}Index: apps/gui/list.h===================================================================--- apps/gui/list.h	(Revision 16838)+++ 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/gui/viewport.h===================================================================--- apps/gui/viewport.h	(Revision 16838)+++ 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);++int viewport_parse_viewport(struct viewport *vp,+        const char *ptr);//, enum screen_type screen);Index: apps/gui/wps_parser.c===================================================================--- apps/gui/wps_parser.c	(Revision 16838)+++ apps/gui/wps_parser.c	(Arbeitskopie)@@ -22,6 +22,7 @@ #include "gwps.h" #include "file.h" #include "misc.h"+#include "viewport.h" #ifdef __PCTOOL__ #define DEBUGF printf #define FONT_SYSFIXED 0@@ -544,9 +545,10 @@                           struct wps_data *wps_data) {     const char *ptr = wps_bufptr;-    struct viewport* vp;+/*     int depth;-+*/+    DEBUGF("HALLOOO\n");     (void)token; /* Kill warnings */      if (*wps_bufptr != '|')@@ -554,25 +556,47 @@      ptr = wps_bufptr + 1;     /* format: %V|x|y|width|height|fg_pattern|bg_pattern| */-+    DEBUGF("ptr:\t%c\n",*ptr);     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;+    DEBUGF("Und hier? vp->x:\t%d\n", vp->x);+#ifdef HAVE_REMOTE_LCD+    if (!(wps_data->remote_wps))+#endif+#if 1 /* works not */+        if (!(viewport_parse_viewport(vp, ptr)))//, 0)))+            return WPS_ERROR_INVALID_PARAM;+#else /* works */+        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;+#endif+#ifdef HAVE_REMOTE_LCD+    else+        if(!(viewport_parse_viewport(vp, ptr, SCREEN_REMOTE)))+            return WPS_ERROR_INVALID_PARAM;+#endif +/* Below: commented old stuff out */+     /* 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)     {@@ -600,6 +624,7 @@       else #endif     {}+*/      /* Check for trailing | */     if (*ptr != '|')@@ -611,6 +636,7 @@      /* Validate the viewport dimensions - we know that the numbers are        non-negative integers */+/* #ifdef HAVE_REMOTE_LCD     if (wps_data->remote_wps)     {@@ -633,7 +659,7 @@             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 16838)+++ 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 16838)+++ 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_*) */@@ -156,6 +155,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";@@ -1233,6 +1235,16 @@ #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", "",4+4+4+4+2+8+8),+#endif+#if 0 /* FIXME: handle remotes with custom list dimensions */+#ifdef HAVE_REMOTE_LCD+    VIEWPORT_SETTING(remote_list_vp_config, "remote list viewport", ""),+#endif+#endif };  const int nb_settings = sizeof(settings)/sizeof(*settings);