Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Meins
Thursday, March 27th, 2008 at 7:59:05pm UTC 

  1. Index: apps/gui/bitmap/list.c
  2. ===================================================================
  3. --- apps/gui/bitmap/list.c      (Revision 16838)
  4. +++ apps/gui/bitmap/list.c      (Arbeitskopie)
  5. @@ -40,12 +40,19 @@
  6.  #include "misc.h"
  7.  #include "talk.h"
  8.  #include "viewport.h"
  9. +// define for some debugging info
  10. +/*
  11. +#define USE_DEBUG
  12. +*/
  13. +#ifdef USE_DEBUG
  14. +#include "debug.h"
  15. +#endif
  16.  
  17.  #define SCROLLBAR_WIDTH 6
  18.  #define ICON_PADDING 1
  19.  
  20.  /* globals */
  21. -struct viewport title_text[NB_SCREENS], title_icons[NB_SCREENS],
  22. +struct viewport list_dimension[NB_SCREENS],title_text[NB_SCREENS], title_icons[NB_SCREENS],
  23.                  list_text[NB_SCREENS], list_icons[NB_SCREENS];
  24.  
  25.  /* should probably be moved somewhere else */
  26. @@ -59,6 +66,16 @@
  27.                               struct viewport *vp);
  28.  bool list_display_title(struct gui_synclist *list, struct viewport *vp);
  29.  
  30. +/* This will contain the information about the list dimensions */
  31. +/*
  32. +struct list_dimension {
  33. +    int xpos;
  34. +    int ypos;
  35. +    int width;
  36. +    int height;
  37. +} list_dimensions;
  38. +*/
  39. +
  40.  /* Draw the list...
  41.      internal screen layout:
  42.          -----------------
  43. @@ -73,12 +90,29 @@
  44.  static bool draw_title(struct screen *display, struct viewport *parent,
  45.                         struct gui_synclist *list)
  46.  {
  47. +    struct viewport *list_dimensions = &list_dimension[display->screen_type];
  48. +    if(!(viewport_parse_viewport(list_dimensions,
  49. +             global_settings.list_vp_config)))//, display->screen_type)))
  50. +        viewport_set_defaults(list_dimensions,display->screen_type);
  51. +   
  52. +#ifdef USE_DEBUG
  53. +    DEBUGF("list_dimensions->x:\t%d\n\n",list_dimensions->x);
  54. +#endif
  55.      struct viewport *vp_icons = &title_icons[display->screen_type];
  56.      struct viewport *vp_text = &title_text[display->screen_type];
  57.      if (!list_display_title(list, parent))
  58.          return false;
  59.      *vp_text = *parent;
  60. +
  61. +   
  62. +    vp_text->x = list_dimensions->x;
  63. +    vp_text->y = list_dimensions->y;
  64. +
  65. +   
  66. +    if (global_settings.statusbar && (vp_text->y < STATUSBAR_HEIGHT))
  67. +        vp_text->y = STATUSBAR_HEIGHT;
  68.      vp_text->height = list_title_height(list, parent);
  69. +    vp_text->width = list_dimensions->width;
  70.      if (list->title_icon != Icon_NOICON && global_settings.show_icons)
  71.      {
  72.          *vp_icons = *vp_text;
  73. @@ -86,12 +120,22 @@
  74.                            + ICON_PADDING*2;
  75.          vp_icons->x += ICON_PADDING;
  76.          
  77. -        vp_text->width -= vp_icons->width + vp_icons->x;
  78. -        vp_text->x += vp_icons->width + vp_icons->x;
  79. -       
  80. +        vp_text->width -= vp_icons->width;
  81. +        vp_text->x += vp_icons->width;
  82. +
  83.          display->set_viewport(vp_icons);
  84.          screen_put_icon(display, 0, 0, list->title_icon);
  85.      }
  86. +#ifdef USE_DEBUG
  87. +/*
  88. +    DEBUGF("Global settings:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n",
  89. +            list_dimensions.x, list_dimensions.y,
  90. +            list_dimensions.width,list_dimensions.height);
  91. +*/
  92. +    DEBUGF("Titel viewport:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n",
  93. +            vp_text->x,vp_text->y,vp_text->width,vp_text->height);
  94. +#endif
  95. +
  96.      display->set_viewport(vp_text);
  97.      vp_text->drawmode = STYLE_DEFAULT;
  98.  #ifdef HAVE_LCD_COLOR
  99. @@ -107,6 +151,11 @@
  100.  void list_draw(struct screen *display, struct viewport *parent,
  101.                 struct gui_synclist *list)
  102.  {
  103. +    struct viewport *list_dimensions = &list_dimension[display->screen_type];
  104. +    if(!(viewport_parse_viewport(list_dimensions,
  105. +            global_settings.list_vp_config)))//,display->screen_type)))
  106. +        viewport_set_defaults(list_dimensions,display->screen_type);
  107. +   
  108.      int start, end, line_height, i;
  109.      int icon_width = get_icon_width(display->screen_type) + ICON_PADDING;
  110.      bool show_cursor = !global_settings.cursor_style &&
  111. @@ -116,33 +165,57 @@
  112.  #endif
  113.      int item_offset;
  114.      bool show_title;
  115. +    int statusbar = global_settings.statusbar?STATUSBAR_HEIGHT+1:0;
  116.      line_height = font_get(parent->font)->height;
  117.      display->set_viewport(parent);
  118.      display->clear_viewport();
  119.      display->stop_scroll();
  120.      list_text[display->screen_type] = *parent;
  121. +
  122. +    list_text[display->screen_type].width = list_dimensions->width;
  123. +    list_text[display->screen_type].x = list_dimensions->x;
  124. +    list_text[display->screen_type].height = list_dimensions->height - statusbar;
  125. +    list_text[display->screen_type].y = list_dimensions->y +
  126. +             ((list_dimensions->y < statusbar)?statusbar:0);
  127.      if ((show_title = draw_title(display, parent, list)))
  128.      {
  129.          list_text[display->screen_type].y += list_title_height(list, parent);
  130.          list_text[display->screen_type].height -= list_title_height(list, parent);
  131.      }
  132. -       
  133. +#ifdef USE_DEBUG
  134. +    DEBUGF("List Text:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n",
  135. +            list_text[display->screen_type].x,list_text[display->screen_type].y,
  136. +            list_text[display->screen_type].width,list_text[display->screen_type].height);
  137. +#endif
  138.      start = list->start_item[display->screen_type];
  139.      end = start + viewport_get_nb_lines(&list_text[display->screen_type]);
  140. -   
  141. +
  142.      /* draw the scrollbar if its needed */
  143. -    if (global_settings.scrollbar &&
  144. -        viewport_get_nb_lines(&list_text[display->screen_type]) < list->nb_items)
  145. +    bool draw_scrollbar = (global_settings.scrollbar &&
  146. +            viewport_get_nb_lines(&list_text[display->screen_type])
  147. +            < list->nb_items);
  148. +#ifdef USE_DEBUG
  149. +    DEBUGF("nb_items:\t%d\n",list->nb_items);
  150. +#endif
  151. +    if (draw_scrollbar)
  152.      {
  153.          struct viewport vp;
  154.          vp = list_text[display->screen_type];
  155. +        /* looks nicer with 1pix indent if listxpos == 0 */
  156. +        vp.x = (list_dimensions->x) + (list_dimensions->x?0:1);
  157.          vp.width = SCROLLBAR_WIDTH;
  158. -        list_text[display->screen_type].width -= SCROLLBAR_WIDTH;
  159. -        list_text[display->screen_type].x += SCROLLBAR_WIDTH;
  160. -        vp.height = line_height *
  161. -                    viewport_get_nb_lines(&list_text[display->screen_type]);
  162. -        vp.x = parent->x;
  163. +        list_text[display->screen_type].width -= vp.width;
  164. +        list_text[display->screen_type].x += vp.width;
  165. +
  166. +        /* shorten scrollbar to fit the lines */
  167. +        vp.height = line_height *
  168. +                viewport_get_nb_lines(&list_text[display->screen_type]);
  169. +#ifdef USE_DEBUG
  170. +        DEBUGF("vp_get_nb_lines:\t%d\n",viewport_get_nb_lines(&list_text[display->screen_type]));
  171. +        DEBUGF("Scrollbar:\nx\t%d\ny\t%d\nwidth\t%d\nheight\t%d\n\n",vp.x,vp.y,vp.width,vp.height);
  172. +#endif
  173.          display->set_viewport(&vp);
  174. +
  175.          gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1,
  176.                             vp.height, list->nb_items,
  177.                             list->start_item[display->screen_type],
  178. @@ -155,7 +228,7 @@
  179.          list_text[display->screen_type].width -= SCROLLBAR_WIDTH;
  180.          list_text[display->screen_type].x += SCROLLBAR_WIDTH;
  181.      }
  182. -   
  183. +
  184.      /* setup icon placement */
  185.      list_icons[display->screen_type] = list_text[display->screen_type];
  186.      int icon_count = global_settings.show_icons &&
  187. Index: apps/gui/list.c
  188. ===================================================================
  189. --- apps/gui/list.c     (Revision 16838)
  190. +++ apps/gui/list.c     (Arbeitskopie)
  191. @@ -246,12 +246,22 @@
  192.  static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
  193.                                               enum screen_type screen)
  194.  {
  195. +
  196.      int nb_lines;
  197.      int difference = gui_list->selected_item - gui_list->start_item[screen];
  198.      struct viewport vp = *gui_list->parent[screen];
  199.  #ifdef HAVE_LCD_BITMAP
  200. +    /* a,b and c are dummys actually not needed here */
  201. +    char a,b,c;
  202. +    int list_dimensions_height;
  203. +    list_dimensions_height = LCD_HEIGHT;
  204. +    parse_list_list_viewport(a,b,c,list_dimensions_height);
  205. +    vp.height = list_dimensions_height;
  206.      if (list_display_title(gui_list, gui_list->parent[screen]))
  207. +    {
  208.          vp.height -= list_title_height(gui_list,gui_list->parent[screen]);
  209. +    }
  210. +    vp.height -= (global_settings.statusbar?STATUSBAR_HEIGHT+1:0);
  211.  #endif
  212.      nb_lines = viewport_get_nb_lines(&vp);
  213.      
  214. Index: apps/gui/viewport.c
  215. ===================================================================
  216. --- apps/gui/viewport.c (Revision 16838)
  217. +++ apps/gui/viewport.c (Arbeitskopie)
  218. @@ -31,7 +31,10 @@
  219.  #include "viewport.h"
  220.  #include "statusbar.h"
  221.  #include "screen_access.h"
  222. +#include "debug.h"
  223.  
  224. +#define VP_STRUCTURE_PARAM_ERROR 0
  225. +
  226.  int viewport_get_nb_lines(struct viewport *vp)
  227.  {
  228.  #ifdef HAVE_LCD_BITMAP
  229. @@ -82,3 +85,60 @@
  230.      }
  231.  #endif
  232.  }
  233. +
  234. +int viewport_parse_viewport(struct viewport *vp,
  235. +         const char *bufptr)//, enum screen_type screen)
  236. +{
  237. +/*
  238. +
  239. +#ifndef HAVE_REMOTE_LCD
  240. +    void(screen);
  241. +#endif
  242. +*/
  243. +    DEBUGF("Bis hier NP\n");
  244. +    const char *ptr = bufptr;
  245. +#if (LCD_DEPTH > 2)
  246. +    if (!(ptr = parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width,
  247. +            &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern
  248. +            )))
  249. +           
  250. +#endif
  251. +#if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2)
  252. +    if (!(ptr = parse_list("dddddgg", '|', ptr, &vp->x, &vp->y, &vp->width,
  253. +            &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern)))
  254. +#endif
  255. +#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)
  256. +    if (!(ptr = (parse_list("ddddd", '|', ptr, &vp->x, &vp->y, &vp->width,
  257. +                                                  &vp->height, &vp->font)))
  258. +#endif
  259. +        return VP_STRUCTURE_PARAM_ERROR;
  260. +
  261. +
  262. +    /* Validate the viewport dimensions - we know that the numbers are
  263. +       non-negative integers */
  264. +#ifdef HAVE_REMOTE_LCD
  265. +    if (screen == SCREEN_REMOTE)
  266. +    {
  267. +        if ((vp->x >= LCD_REMOTE_WIDTH) ||
  268. +            ((vp->x + vp->width) > LCD_REMOTE_WIDTH) ||
  269. +            (vp->y >= LCD_REMOTE_HEIGHT) ||
  270. +            ((vp->y + vp->height) > LCD_REMOTE_HEIGHT))
  271. +        {
  272. +            return VP_STRUCTURE_PARAM_ERROR;
  273. +        }
  274. +    }
  275. +    else
  276. +#endif
  277. +    {
  278. +        if ((vp->x >= LCD_WIDTH) ||
  279. +            ((vp->x + vp->width) > LCD_WIDTH) ||
  280. +            (vp->y >= LCD_HEIGHT) ||
  281. +            ((vp->y + vp->height) > LCD_HEIGHT))
  282. +        {
  283. +            return VP_STRUCTURE_PARAM_ERROR;
  284. +        }
  285. +    }
  286. +
  287. +    DEBUGF("Alles ok in viewport.c\n");
  288. +    return 1;
  289. +}
  290. Index: apps/gui/list.h
  291. ===================================================================
  292. --- apps/gui/list.h     (Revision 16838)
  293. +++ apps/gui/list.h     (Arbeitskopie)
  294. @@ -26,6 +26,13 @@
  295.  
  296.  #define SCROLLBAR_WIDTH  6
  297.  
  298. +/* macro used to parse the user definable list dimensions in the config.cfg;
  299. + * needs to be extended (or replaced ;)) when more setting are available */
  300. +#ifdef HAVE_LCD_BITMAP
  301. +#define parse_list_list_viewport(a,b,c,d) \
  302. +    const char *ptr = (global_settings.list_vp_config); \
  303. +    parse_list("dddd",'|',ptr, &a, &b, &c, &d);
  304. +#endif
  305.  enum list_wrap {
  306.      LIST_WRAP_ON = 0,
  307.      LIST_WRAP_OFF,
  308. Index: apps/gui/viewport.h
  309. ===================================================================
  310. --- apps/gui/viewport.h (Revision 16838)
  311. +++ apps/gui/viewport.h (Arbeitskopie)
  312. @@ -38,3 +38,6 @@
  313.  int viewport_load_config(const char *config, struct viewport *vp);
  314.  
  315.  void viewport_set_defaults(struct viewport *vp, enum screen_type screen);
  316. +
  317. +int viewport_parse_viewport(struct viewport *vp,
  318. +        const char *ptr);//, enum screen_type screen);
  319. Index: apps/gui/wps_parser.c
  320. ===================================================================
  321. --- apps/gui/wps_parser.c       (Revision 16838)
  322. +++ apps/gui/wps_parser.c       (Arbeitskopie)
  323. @@ -22,6 +22,7 @@
  324.  #include "gwps.h"
  325.  #include "file.h"
  326.  #include "misc.h"
  327. +#include "viewport.h"
  328.  #ifdef __PCTOOL__
  329.  #define DEBUGF printf
  330.  #define FONT_SYSFIXED 0
  331. @@ -544,9 +545,10 @@
  332.                            struct wps_data *wps_data)
  333.  {
  334.      const char *ptr = wps_bufptr;
  335. -    struct viewport* vp;
  336. +/*
  337.      int depth;
  338. -
  339. +*/
  340. +    DEBUGF("HALLOOO\n");
  341.      (void)token; /* Kill warnings */
  342.  
  343.      if (*wps_bufptr != '|')
  344. @@ -554,25 +556,47 @@
  345.  
  346.      ptr = wps_bufptr + 1;
  347.      /* format: %V|x|y|width|height|fg_pattern|bg_pattern| */
  348. -
  349. +    DEBUGF("ptr:\t%c\n",*ptr);
  350.      if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS)
  351.          return WPS_ERROR_INVALID_PARAM;
  352.  
  353.      wps_data->num_viewports++;
  354. -    vp = &wps_data->viewports[wps_data->num_viewports].vp;
  355. +    struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp;
  356.  
  357.      /* Set the defaults for fields not user-specified */
  358.      vp->drawmode = DRMODE_SOLID;
  359.      vp->xmargin  = 0;
  360.      vp->ymargin  = 0;
  361. +    DEBUGF("Und hier? vp->x:\t%d\n", vp->x);
  362. +#ifdef HAVE_REMOTE_LCD
  363. +    if (!(wps_data->remote_wps))
  364. +#endif
  365. +#if 1 /* works not */
  366. +        if (!(viewport_parse_viewport(vp, ptr)))//, 0)))
  367. +            return WPS_ERROR_INVALID_PARAM;
  368. +#else /* works */
  369. +        if (!(ptr = parse_list("dddddcc", '|', ptr, &vp->x, &vp->y, &vp->width,
  370. +            &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern)))
  371. +            return WPS_ERROR_INVALID_PARAM;
  372. +#endif
  373. +#ifdef HAVE_REMOTE_LCD
  374. +    else
  375. +        if(!(viewport_parse_viewport(vp, ptr, SCREEN_REMOTE)))
  376. +            return WPS_ERROR_INVALID_PARAM;
  377. +#endif
  378.  
  379. +/* Below: commented old stuff out */
  380. +
  381.      /* Work out the depth of this display */
  382. +/*
  383.  #ifdef HAVE_REMOTE_LCD
  384.      depth = (wps_data->remote_wps ? LCD_REMOTE_DEPTH : LCD_DEPTH);
  385.  #else
  386.      depth = LCD_DEPTH;
  387.  #endif
  388. +*/
  389.  
  390. +/*
  391.  #ifdef HAVE_LCD_COLOR
  392.      if (depth == 16)
  393.      {
  394. @@ -600,6 +624,7 @@
  395.        else
  396.  #endif
  397.      {}
  398. +*/
  399.  
  400.      /* Check for trailing | */
  401.      if (*ptr != '|')
  402. @@ -611,6 +636,7 @@
  403.  
  404.      /* Validate the viewport dimensions - we know that the numbers are
  405.         non-negative integers */
  406. +/*
  407.  #ifdef HAVE_REMOTE_LCD
  408.      if (wps_data->remote_wps)
  409.      {
  410. @@ -633,7 +659,7 @@
  411.              return WPS_ERROR_INVALID_PARAM;
  412.          }
  413.      }
  414. -
  415. +*/
  416.      wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1;
  417.  
  418.      wps_data->viewports[wps_data->num_viewports].first_line = wps_data->num_lines;
  419. Index: apps/settings.h
  420. ===================================================================
  421. --- apps/settings.h     (Revision 16838)
  422. +++ apps/settings.h     (Arbeitskopie)
  423. @@ -419,7 +419,14 @@
  424.  #endif
  425.      unsigned char wps_file[MAX_FILENAME+1];  /* last wps */
  426.      unsigned char lang_file[MAX_FILENAME+1]; /* last language */
  427. -
  428. +#ifdef HAVE_LCD_BITMAP
  429. +    unsigned char list_vp_config[MAX_PATH+1]; /* viewport file for the lists */
  430. +#endif
  431. +#if 0 /* FIXME: handle remotes with custom list dimensions */
  432. +#ifdef HAVE_REMOTE_LCD
  433. +    unsigned char remote_list_vp_config[MAX_PATH+1]; /* viewport file for the lists */
  434. +#endif
  435. +#endif
  436.      /* misc options */
  437.  
  438.      int repeat_mode;   /* 0=off 1=repeat all 2=repeat one 3=shuffle 4=ab */
  439. Index: apps/settings_list.c
  440. ===================================================================
  441. --- apps/settings_list.c        (Revision 16838)
  442. +++ apps/settings_list.c        (Arbeitskopie)
  443. @@ -106,7 +106,6 @@
  444.                  CHARPTR(default),name,NULL,                         \
  445.                  {.filename_setting=                                 \
  446.                      (struct filename_setting[]){{prefix,suffix,len}}} }
  447. -
  448.  /*  Used for settings which use the set_option() setting screen.
  449.      the ... arg is a list of pointers to strings to display in the setting screen.
  450.      These can either be literal strings, or ID2P(LANG_*) */
  451. @@ -156,6 +155,9 @@
  452.                      {cb, formatter, get_talk_id, unit, count,       \
  453.                      (const int[]){__VA_ARGS__}}}}}
  454.  
  455. +#define VIEWPORT_SETTING(var,name,default, max_length)      \
  456. +        FILENAME_SETTING(0,var,name,default, NULL, NULL, max_length)
  457. +
  458.  /* some sets of values which are used more than once, to save memory */
  459.  static const char off_on[] = "off,on";
  460.  static const char off_on_ask[] = "off,on,ask";
  461. @@ -1233,6 +1235,16 @@
  462.  #endif /* CONFIG_CODEC == SWCODEC */
  463.      FILENAME_SETTING(0, playlist_catalog_dir, "playlist catalog directory",
  464.                      PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL, MAX_FILENAME+1),
  465. +
  466. +    /* Customizable list */
  467. +#ifdef HAVE_LCD_BITMAP
  468. +    VIEWPORT_SETTING(list_vp_config, "list viewport", "",4+4+4+4+2+8+8),
  469. +#endif
  470. +#if 0 /* FIXME: handle remotes with custom list dimensions */
  471. +#ifdef HAVE_REMOTE_LCD
  472. +    VIEWPORT_SETTING(remote_list_vp_config, "remote list viewport", ""),
  473. +#endif
  474. +#endif
  475.  };
  476.  
  477.  const int nb_settings = sizeof(settings)/sizeof(*settings);

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right