Lists can now be completly draw using the skin engine!
due to lack of user feedback the actual tags may change, hopefully not though.

The way it works is the skin specifies a rectangle and a viewport label. For each item in the list that is being displayed all viewports with the specified label are drawn. However, instead of the viewport x/y position being offset from the top left corner like normal they are offset from the rectangle position in the list (so think of them as child-viewports of the rectangle which moves).
Normally the rectangle will move down the screen to show a normal list, this can be changed to move across the screen in a grid pattern.
The UI viewport is used to bound the items (i.e %Vi() )
Scrolling is completly disabled in all items except the currently selected item.

This works well in combination with the %cs tag to show differently styled lists based on the current screen :)

New tags:
%LT - Get the current items text
%LI - Get the current items icon number
%Lc - Use as a conditional to determine if the current item is the selected item
%LB - BAR TAG to show the scroll bar, params/options like other bar types. It still needs a bit of work though. Use as a conditional to find out if the bar is actually needed
%Lb(viewport, width, height [,tile]) - specify the viewport label to draw for each item and the size of each item. if the last param is 'tile' it will form a grid instead of a list

example.sbs:
%?cs<%Lb(a,100,20)|>
%V(0,0,10,-,1)%Vf(aabbcc)
%?LB<%LB(0,0,10,185, invert)>
%Vi(-,10,0,-,-35,1)
%Vl(a,5,5,160,12,1)
%s%?Lc<%Vg(00ffaa, ff0000, 000000)%Vs(gradient)%>%>%>%ac>zzzzzzz            %LT         zzzzz%s%?Lc<%ar%<%<%<>
%V(0,185,-,-,1)
%s%LT

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30461 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/SOURCES b/apps/SOURCES
index e0244b2..6b72d6a 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -75,6 +75,7 @@
 gui/list.c
 #ifdef HAVE_LCD_BITMAP
 gui/bitmap/list.c
+gui/bitmap/list-skinned.c
 #else
 gui/charcell/list.c
 #endif
diff --git a/apps/gui/list.c b/apps/gui/list.c
index f450bd5..fbcdcb2 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -121,6 +121,9 @@
 static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen)
 {
     struct viewport vp = *list->parent[screen];
+    int skin_count = skinlist_get_line_count(screen, list);
+    if (skin_count >= 0)
+        return skin_count;
     if (list_display_title(list, screen))
         vp.height -= font_get(list->parent[screen]->font)->height;
     return viewport_get_nb_lines(&vp);
@@ -239,7 +242,10 @@
 #endif
     FOR_NB_SCREENS(i)
     {
-        list_draw(&screens[i], gui_list);
+#ifdef HAVE_LCD_BITMAP        
+        if (!skinlist_draw(&screens[i], gui_list))
+#endif
+            list_draw(&screens[i], gui_list);
     }
 }
 
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 38d7e95..b54e7d7 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -25,6 +25,7 @@
 #include "config.h"
 #include "icon.h"
 #include "screen_access.h"
+#include "skin_engine/skin_engine.h"
 
 #define SCROLLBAR_WIDTH global_settings.scrollbar_width
 
@@ -173,6 +174,27 @@
 extern bool gui_synclist_do_button(struct gui_synclist * lists,
                                        int *action,
                                        enum list_wrap);
+#if defined(HAVE_LCD_BITMAP) && !defined(PLUGIN)
+struct listitem_viewport_cfg {
+    struct wps_data *data;
+    char*   label;
+    int     width;
+    int     height;
+    int     xmargin;
+    int     ymargin;
+    bool    tile;
+    struct skin_viewport selected_item_vp;
+};
+bool skinlist_draw(struct screen *display, struct gui_synclist *list);
+bool skinlist_is_selected_item(void);
+void skinlist_set_cfg(enum screen_type screen,
+                      struct listitem_viewport_cfg *cfg);
+const char* skinlist_get_item_text(void);
+enum themable_icons skinlist_get_item_icon(void);
+bool skinlist_needs_scrollbar(enum screen_type screen);
+void skinlist_get_scrollbar(int* nb_item, int* first_shown, int* last_shown);
+int skinlist_get_line_count(enum screen_type screen, struct gui_synclist *list);
+#endif
 
 #if  defined(HAVE_TOUCHSCREEN)
 /* this needs to be fixed if we ever get more than 1 touchscreen on a target */
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 2be5bb9..49f9f86 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -42,6 +42,7 @@
 #include "playlist.h"
 #include "audio.h"
 #include "tagcache.h"
+#include "list.h"
 
 #ifdef HAVE_LCD_BITMAP
 #include "peakmeter.h"
@@ -169,6 +170,13 @@
         length = MAX_PEAK;
         end = peak_meter_scale_value(val, length);
     }
+    else if (pb->type == SKIN_TOKEN_LIST_SCROLLBAR)
+    {
+        int val, min, max;
+        skinlist_get_scrollbar(&val, &min, &max);
+        end = val - min;
+        length = max - min;
+    }
 #if CONFIG_TUNER
     else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
     {
diff --git a/apps/gui/skin_engine/skin_display.h b/apps/gui/skin_engine/skin_display.h
index 9faaea3..81d04e5 100644
--- a/apps/gui/skin_engine/skin_display.h
+++ b/apps/gui/skin_engine/skin_display.h
@@ -36,6 +36,11 @@
 void clear_image_pos(struct gui_wps *gwps, struct gui_img *img);
 void wps_draw_image(struct gui_wps *gwps, struct gui_img *img, int subimage);
 void wps_display_images(struct gui_wps *gwps, struct viewport* vp);
+
+
+void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps,
+                        struct skin_viewport* skin_viewport, unsigned long refresh_type);
+
 #endif
 
 /* Evaluate the conditional that is at *token_index and return whether a skip
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 58ac5f5..049c117 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -483,6 +483,32 @@
 }
 #endif
 
+
+static int parse_listitemviewport(struct skin_element *element,
+                                  struct wps_token *token,
+                                  struct wps_data *wps_data)
+{
+    struct listitem_viewport_cfg *cfg = 
+        (struct listitem_viewport_cfg *)skin_buffer_alloc(
+                                sizeof(struct listitem_viewport_cfg));
+    if (!cfg)
+        return -1;
+    cfg->data = wps_data;
+    cfg->tile = false;
+    cfg->label = element->params[0].data.text;
+    cfg->width = -1;
+    cfg->height = -1;
+    if (!isdefault(&element->params[1]))
+        cfg->width = element->params[1].data.number;
+    if (!isdefault(&element->params[2]))
+        cfg->height = element->params[2].data.number;
+    if (element->params_count > 3 &&
+        !strcmp(element->params[3].data.text, "tile"))
+        cfg->tile = true;
+    token->value.data = (void*)cfg;
+    return 0;
+}
+
 #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
 static int parse_viewporttextstyle(struct skin_element *element,
                                    struct wps_token *token,
@@ -877,6 +903,8 @@
         token->type = SKIN_TOKEN_PEAKMETER_LEFTBAR;
     else if (token->type == SKIN_TOKEN_PEAKMETER_RIGHT)
         token->type = SKIN_TOKEN_PEAKMETER_RIGHTBAR;
+    else if (token->type == SKIN_TOKEN_LIST_NEEDS_SCROLLBAR)
+        token->type = SKIN_TOKEN_LIST_SCROLLBAR;
     pb->type = token->type;
         
     return 0;
@@ -1719,6 +1747,7 @@
                 case SKIN_TOKEN_PLAYER_PROGRESSBAR:
                 case SKIN_TOKEN_PEAKMETER_LEFT:
                 case SKIN_TOKEN_PEAKMETER_RIGHT:
+                case SKIN_TOKEN_LIST_NEEDS_SCROLLBAR:
 #ifdef HAVE_RADIO_RSSI
                 case SKIN_TOKEN_TUNER_RSSI:
 #endif
@@ -1809,6 +1838,9 @@
                     function = parse_skinvar;
                     break;
 #endif
+                case SKIN_TOKEN_LIST_ITEM_CFG:
+                    function = parse_listitemviewport;
+                    break;
                 default:
                     break;
             }
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index 27e6747..dd266b1 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -46,6 +46,7 @@
 #include "playlist.h"
 #include "root_menu.h"
 #include "misc.h"
+#include "list.h"
 
 
 #define MAX_LINE 1024
@@ -142,6 +143,11 @@
             }
         }
         break;
+        case SKIN_TOKEN_LIST_ITEM_CFG:
+            if (do_refresh)
+                skinlist_set_cfg(gwps->display->screen_type, 
+                                    token->value.data);
+            break;
 #ifdef HAVE_LCD_BITMAP
         case SKIN_TOKEN_UIVIEWPORT_ENABLE:
             sb_set_info_vp(gwps->display->screen_type, 
@@ -164,6 +170,7 @@
 #ifdef HAVE_LCD_BITMAP
         case SKIN_TOKEN_PROGRESSBAR:
         case SKIN_TOKEN_TUNER_RSSI_BAR:
+        case SKIN_TOKEN_LIST_SCROLLBAR:
         {
             struct progressbar *bar = (struct progressbar*)token->value.data;
             if (do_refresh)
@@ -488,10 +495,10 @@
                 if (!do_non_text_tags(info->gwps, info, child, &info->skin_vp->vp))
                 {
                     static char tempbuf[128];
-                    const char *value = get_token_value(info->gwps, child->data,
+                    const char *valuestr = get_token_value(info->gwps, child->data,
                                                         info->offset, tempbuf,
                                                         sizeof(tempbuf), NULL);
-                    if (value)
+                    if (valuestr)
                     {
 #if CONFIG_RTC
                         if (child->tag->flags&SKIN_RTC_REFRESH)
@@ -499,7 +506,7 @@
 #endif
                         needs_update = needs_update || 
                                 ((child->tag->flags&info->refresh_type)!=0);
-                        strlcat(info->cur_align_start, value, 
+                        strlcat(info->cur_align_start, valuestr, 
                                 info->buf_size - (info->cur_align_start-info->buf));
                     }
                 }
@@ -612,8 +619,8 @@
     return changed_lines || ret;
 }
 
-static void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps,
-                                 struct skin_viewport* skin_viewport, unsigned long refresh_type)
+void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps,
+                        struct skin_viewport* skin_viewport, unsigned long refresh_type)
 {
     struct screen *display = gwps->display;
     char linebuf[MAX_LINE];
@@ -784,10 +791,11 @@
 }
 
 #ifdef HAVE_LCD_BITMAP
-static __attribute__((noinline)) void skin_render_playlistviewer(struct playlistviewer* viewer,
-                                       struct gui_wps *gwps,
-                                       struct skin_viewport* skin_viewport,
-                                       unsigned long refresh_type)
+static __attribute__((noinline)) 
+void skin_render_playlistviewer(struct playlistviewer* viewer,
+                                struct gui_wps *gwps,
+                                struct skin_viewport* skin_viewport,
+                                unsigned long refresh_type)
 {
     struct screen *display = gwps->display;
     char linebuf[MAX_LINE];
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index ec6f606..8e15ddc 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -71,6 +71,7 @@
 #include "radio.h"
 #include "tuner.h"
 #endif
+#include "list.h"
 
 #define NOINLINE __attribute__ ((noinline))
 
@@ -894,6 +895,17 @@
                 *intval = sb_get_icon(gwps->display->screen_type);
             snprintf(buf, buf_size, "%d",sb_get_icon(gwps->display->screen_type));
             return buf;
+        case SKIN_TOKEN_LIST_ITEM_TEXT:
+            return skinlist_get_item_text();
+        case SKIN_TOKEN_LIST_ITEM_IS_SELECTED:
+            return skinlist_is_selected_item()?"s":"";
+        case SKIN_TOKEN_LIST_ITEM_ICON:
+            if (intval)
+                *intval = skinlist_get_item_icon();
+            snprintf(buf, buf_size, "%d",skinlist_get_item_icon());
+            return buf;
+        case SKIN_TOKEN_LIST_NEEDS_SCROLLBAR:
+            return skinlist_needs_scrollbar(gwps->display->screen_type) ? "s" : "";
 #endif
         case SKIN_TOKEN_PLAYLIST_NAME:
             return playlist_name(NULL, buf, buf_size);
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 01f67d4..136ec29 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -193,6 +193,7 @@
     struct viewport *vp;
     unsigned colour;
 };
+
 #ifdef HAVE_TOUCHSCREEN
 struct touchregion {
     char* label;            /* label to identify this region */
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 58f58e4..3f914bd 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -139,6 +139,7 @@
 }
         
 #endif
+static bool force_waiting = false;
 void sb_skin_update(enum screen_type screen, bool force)
 {
     struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data;
@@ -146,8 +147,9 @@
     int i = screen;
     if (!data->wps_loaded)
         return;
-    if (TIME_AFTER(current_tick, next_update[i]) || force)
+    if (TIME_AFTER(current_tick, next_update[i]) || force || force_waiting)
     {
+        force_waiting = false;
 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
         /* currently, all remotes are readable without backlight
          * so still update those */
@@ -168,6 +170,7 @@
     /* the WPS handles changing the actual id3 data in the id3 pointers
      * we imported, we just want a full update */
     skin_request_full_update(CUSTOM_STATUSBAR);
+    force_waiting = true;
     /* force timeout in wps main loop, so that the update is instantly */
     queue_post(&button_queue, BUTTON_NONE, 0);
 }
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 45094e4..34ebbf9 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -28,7 +28,7 @@
 #include "screen_access.h"
 #include "settings.h"
 #include "misc.h"
-
+#include "list.h"
 /*some short cuts for fg/bg/line selector handling */
 #ifdef HAVE_LCD_COLOR
 #define FG_FALLBACK global_settings.fg_color
@@ -178,6 +178,7 @@
         screens[screen].backdrop_show(NULL);
 #endif
         screens[screen].stop_scroll();
+        skinlist_set_cfg(screen, NULL);
     }
     /* let list initialize viewport in case viewport dimensions is changed. */
     send_event(GUI_EVENT_THEME_CHANGED, NULL);
diff --git a/apps/misc.c b/apps/misc.c
index 69c62da..6e2bf32 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -56,6 +56,7 @@
 #include "playlist.h"
 #include "yesno.h"
 #include "viewport.h"
+#include "list.h"
 
 #include "debug.h"
 
@@ -1078,11 +1079,25 @@
 static int current_activity_top = 0;
 void push_current_activity(enum current_activity screen)
 {
+#if HAVE_LCD_BITMAP
+    int i;
+#endif
     current_activity[current_activity_top++] = screen;
+#if HAVE_LCD_BITMAP
+    FOR_NB_SCREENS(i)
+        skinlist_set_cfg(i, NULL);
+#endif
 }
 void pop_current_activity(void)
 {
+#if HAVE_LCD_BITMAP
+    int i;
+#endif
     current_activity_top--;
+#if HAVE_LCD_BITMAP
+    FOR_NB_SCREENS(i)
+        skinlist_set_cfg(i, NULL);
+#endif
 }
 enum current_activity get_current_activity(void)
 {
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index db8c2e5..849e1d9 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -188,7 +188,12 @@
     
     { SKIN_TOKEN_VIEWPORT_CUSTOMLIST,   "Vp" , "IC", SKIN_REFRESH_DYNAMIC|NOBREAK },
     { SKIN_TOKEN_LIST_TITLE_TEXT,       "Lt" , "", SKIN_REFRESH_DYNAMIC },
+    { SKIN_TOKEN_LIST_ITEM_TEXT,        "LT", "",  SKIN_REFRESH_DYNAMIC },
     { SKIN_TOKEN_LIST_TITLE_ICON,       "Li" , "", SKIN_REFRESH_DYNAMIC },
+    { SKIN_TOKEN_LIST_ITEM_ICON,        "LI", "",  SKIN_REFRESH_DYNAMIC },
+    { SKIN_TOKEN_LIST_ITEM_CFG,         "Lb" , "Sii|S", SKIN_REFRESH_STATIC },
+    { SKIN_TOKEN_LIST_ITEM_IS_SELECTED, "Lc" , "", SKIN_REFRESH_DYNAMIC },
+    { SKIN_TOKEN_LIST_NEEDS_SCROLLBAR,  "LB", BAR_PARAMS, SKIN_REFRESH_DYNAMIC },
     
     { SKIN_TOKEN_VIEWPORT_FGCOLOUR,       "Vf" , "s", SKIN_REFRESH_STATIC|NOBREAK },
     { SKIN_TOKEN_VIEWPORT_BGCOLOUR,       "Vb" , "s", SKIN_REFRESH_STATIC|NOBREAK },
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h
index 58c14b5..5a93e36 100644
--- a/lib/skin_parser/tag_table.h
+++ b/lib/skin_parser/tag_table.h
@@ -212,6 +212,13 @@
     SKIN_TOKEN_DRAW_INBUILTBAR,
     SKIN_TOKEN_LIST_TITLE_TEXT,
     SKIN_TOKEN_LIST_TITLE_ICON,
+    SKIN_TOKEN_LIST_ITEM_CFG,
+    SKIN_TOKEN_LIST_SELECTED_ITEM_CFG,
+    SKIN_TOKEN_LIST_ITEM_IS_SELECTED,
+    SKIN_TOKEN_LIST_ITEM_TEXT,
+    SKIN_TOKEN_LIST_ITEM_ICON,
+    SKIN_TOKEN_LIST_NEEDS_SCROLLBAR,
+    SKIN_TOKEN_LIST_SCROLLBAR,
     
     SKIN_TOKEN_LOAD_FONT,