diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-10-12 12:46:57 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-10-12 12:46:57 +0000 |
commit | 9acd242839b83aa64c6633461bbc523f50b070f4 (patch) | |
tree | 045cdbc51c719f42c3ddd1a6b33c699dcd4dfde5 /apps/gui/skin_engine/skin_parser.c | |
parent | 3eb5826c8a289d2ff2af246388e17d4aa6483da4 (diff) |
skin bar tag: Load an image from a label or filename. i.e %xl(bar_image, pb.bmp,0,0) %pb(0,0,10,10,bar_image) or %pb(0,0,10,10, pb.bmp) both are acceptable.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28249 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index f5923747ab..ed475acb2b 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -581,10 +581,10 @@ static int parse_progressbar_tag(struct skin_element* element, { #ifdef HAVE_LCD_BITMAP struct progressbar *pb; - struct skin_token_list *item; struct viewport *vp = &curr_vp->vp; struct skin_tag_parameter *param = element->params; int curr_param = 0; + char *image_filename = NULL; if (element->params_count == 0 && element->tag->type != SKIN_TOKEN_PROGRESSBAR) @@ -596,11 +596,10 @@ static int parse_progressbar_tag(struct skin_element* element, if (!pb) return WPS_ERROR_INVALID_PARAM; pb->vp = vp; - pb->have_bitmap_pb = false; - pb->bm.data = NULL; /* no bitmap specified */ pb->follow_lang_direction = follow_lang_direction > 0; pb->nofill = false; pb->nobar = false; + pb->image = NULL; pb->slider = NULL; pb->invert_fill_direction = false; pb->horizontal = true; @@ -615,11 +614,6 @@ static int parse_progressbar_tag(struct skin_element* element, return 0; } - item = new_skin_token_list_item(token, pb); - if (!item) - return -1; - add_to_ll_chain(&wps_data->progressbars, item); - /* (x, y, width, height, ...) */ if (!isdefault(param)) pb->x = param->data.number; @@ -696,7 +690,8 @@ static int parse_progressbar_tag(struct skin_element* element, { curr_param++; param++; - pb->bm.data = param->data.text; + image_filename = param->data.text; + } else /* option needs the next param */ return -1; @@ -710,10 +705,37 @@ static int parse_progressbar_tag(struct skin_element* element, else if (!strcmp(param->data.text, "horizontal")) pb->horizontal = true; else if (curr_param == 4) - pb->bm.data = param->data.text; + image_filename = param->data.text; curr_param++; } + + if (image_filename) + { + pb->image = find_image(image_filename, wps_data); + if (!pb->image) /* load later */ + { + struct gui_img* img = (struct gui_img*)skin_buffer_alloc(sizeof(struct gui_img)); + if (!img) + return WPS_ERROR_INVALID_PARAM; + /* save a pointer to the filename */ + img->bm.data = (char*)image_filename; + img->label = image_filename; + img->x = 0; + img->y = 0; + img->num_subimages = 1; + img->always_display = false; + img->display = -1; + img->using_preloaded_icons = false; + img->vp = &curr_vp->vp; + struct skin_token_list *item = + (struct skin_token_list *)new_skin_token_list_item(NULL, img); + if (!item) + return WPS_ERROR_INVALID_PARAM; + add_to_ll_chain(&wps_data->images, item); + pb->image = img; + } + } if (token->type == SKIN_TOKEN_VOLUME) @@ -1033,7 +1055,6 @@ static void skin_data_reset(struct wps_data *wps_data) wps_data->tree = NULL; #ifdef HAVE_LCD_BITMAP wps_data->images = NULL; - wps_data->progressbars = NULL; #endif #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 if (wps_data->backdrop_id >= 0) @@ -1118,19 +1139,7 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) { struct skin_token_list *list; bool retval = true; /* return false if a single image failed to load */ - /* do the progressbars */ - list = wps_data->progressbars; - while (list) - { - struct progressbar *pb = (struct progressbar*)list->token->value.data; - if (pb->bm.data) - { - pb->have_bitmap_pb = load_skin_bmp(wps_data, &pb->bm, bmpdir); - if (!pb->have_bitmap_pb) /* no success */ - retval = false; - } - list = list->next; - } + /* regular images */ list = wps_data->images; while (list) |