From 70ebe46d74dbb10160a878cdb120c9b3e7a8e30c Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 12 Aug 2010 13:27:10 +0000 Subject: New feature for the %xl (image load) tag. If you give it the filename __list_icons__ it will use the list icon strip instead of loading a different bmp. example: %xl(I, __list_icons__, 0, 0) %xd(I, %Li) ^ display the list icon at position 0,0 in that viewport. (you can of course %xd(Ia) if you really wanted also.) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27787 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_display.c | 6 +++++- apps/gui/skin_engine/skin_parser.c | 26 ++++++++++++++++++++------ apps/gui/skin_engine/skin_render.c | 6 +++++- apps/gui/skin_engine/wps_internals.h | 1 + apps/gui/statusbar-skinned.c | 10 ++++++++++ lib/skin_parser/tag_table.h | 1 + manual/appendix/wps_tags.tex | 1 + 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 83fea8c73c..d0044b14d8 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -441,7 +441,11 @@ void wps_display_images(struct gui_wps *gwps, struct viewport* vp) while (list) { struct gui_img *img = (struct gui_img*)list->token->value.data; - if (img->loaded) + if (img->using_preloaded_icons && img->display >= 0) + { + screen_put_icon(display, img->x, img->y, img->display); + } + else if (img->loaded) { if (img->display >= 0) { diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 94953f098e..39eefc69e0 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -243,6 +243,13 @@ static int parse_image_display(struct skin_element *element, } id->label = label; id->offset = 0; + img->using_preloaded_icons = false; + if (!strcmp(img->bm.data, "__list_icons__")) + { + img->num_subimages = Icon_Last_Themeable; + img->using_preloaded_icons = true; + token->type = SKIN_TOKEN_IMAGE_DISPLAY_LISTICON; + } if (element->params_count > 1) { @@ -302,7 +309,6 @@ static int parse_image_load(struct skin_element *element, img->y = y; img->num_subimages = 1; img->always_display = false; - // img->just_drawn = false; img->display = -1; /* save current viewport */ @@ -318,6 +324,7 @@ static int parse_image_load(struct skin_element *element, if (img->num_subimages <= 0) return WPS_ERROR_INVALID_PARAM; } + struct skin_token_list *item = (struct skin_token_list *)new_skin_token_list_item(NULL, img); if (!item) @@ -994,11 +1001,19 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) struct gui_img *img = (struct gui_img*)list->token->value.data; if (img->bm.data) { - img->loaded = load_skin_bmp(wps_data, &img->bm, bmpdir); - if (img->loaded) - img->subimage_height = img->bm.height / img->num_subimages; + if (img->using_preloaded_icons) + { + img->loaded = true; + list->token->type = SKIN_TOKEN_IMAGE_DISPLAY_LISTICON; + } else - retval = false; + { + img->loaded = load_skin_bmp(wps_data, &img->bm, bmpdir); + if (img->loaded) + img->subimage_height = img->bm.height / img->num_subimages; + else + retval = false; + } } list = list->next; } @@ -1022,7 +1037,6 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) retval = false; } #endif /* has backdrop support */ - return retval; } diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index d48dd6b5b8..47cc9c8ad0 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c @@ -142,6 +142,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, } break; #ifdef HAVE_LCD_BITMAP + case SKIN_TOKEN_IMAGE_DISPLAY_LISTICON: case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY: { struct image_display *id = token->value.data; @@ -163,7 +164,10 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, /* NOTE: get_token_value() returns values starting at 1! */ if (a == -1) a = (out && *out) ? 1 : 2; - a--; + if (token->type == SKIN_TOKEN_IMAGE_DISPLAY_LISTICON) + a -= 2; /* 2 is added in statusbar-skinned.c! */ + else + a--; a += id->offset; /* Clear the image, as in conditionals */ diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index e42fc5a53b..d42977ff19 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -81,6 +81,7 @@ struct gui_img { bool loaded; /* load state */ bool always_display; /* not using the preload/display mechanism */ int display; + bool using_preloaded_icons; /* using the icon system instead of a bmp */ }; struct image_display { diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index 3b4dd24512..4dce84b787 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c @@ -77,6 +77,16 @@ static int set_title_worker(char* title, enum themable_icons icon, /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ token->value.i = icon+2; } + else if (element->params_count) + { + int i; + for (i=0; iparams_count; i++) + { + if (element->params[i].type == CODE) + retval |= set_title_worker(title, icon, data, + element->params[i].data.code); + } + } } if (element->children_count) { diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h index 2ba43b1bac..c96feccc65 100644 --- a/lib/skin_parser/tag_table.h +++ b/lib/skin_parser/tag_table.h @@ -156,6 +156,7 @@ enum skin_token_type { SKIN_TOKEN_IMAGE_PRELOAD, SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY, SKIN_TOKEN_IMAGE_DISPLAY, + SKIN_TOKEN_IMAGE_DISPLAY_LISTICON, /* Albumart */ SKIN_TOKEN_ALBUMART_LOAD, diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index 0089786f2e..ca6f3d99a0 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -317,6 +317,7 @@ Examples: & Preload an image for later display (useful for when your images are displayed conditionally).\newline \config{n}: image ID (a-z and A-Z) for later referencing in \config{\%xd}\newline \config{filename}: file name relative to \fname{/.rockbox/} and including ``.bmp''\newline + If the filename is __list_icons__ the list icon bitmap will be used instead\newline \config{x}: x coordinate\newline \config{y}: y coordinate\newline \config{nimages}: (optional) number of sub-images (tiled vertically, of the same height) -- cgit