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 | |
parent | 3eb5826c8a289d2ff2af246388e17d4aa6483da4 (diff) | |
download | rockbox-9acd242839b83aa64c6633461bbc523f50b070f4.tar.gz rockbox-9acd242839b83aa64c6633461bbc523f50b070f4.zip |
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')
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 57 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 6 |
3 files changed, 37 insertions, 30 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 1418d91b57..78db4eb371 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -214,8 +214,8 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) | |||
214 | } | 214 | } |
215 | if (!pb->nobar) | 215 | if (!pb->nobar) |
216 | { | 216 | { |
217 | if (pb->have_bitmap_pb) | 217 | if (pb->image) |
218 | gui_bitmap_scrollbar_draw(display, &pb->bm, | 218 | gui_bitmap_scrollbar_draw(display, &pb->image->bm, |
219 | x, y, width, height, | 219 | x, y, width, height, |
220 | length, 0, end, flags); | 220 | length, 0, end, flags); |
221 | else | 221 | else |
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, | |||
581 | { | 581 | { |
582 | #ifdef HAVE_LCD_BITMAP | 582 | #ifdef HAVE_LCD_BITMAP |
583 | struct progressbar *pb; | 583 | struct progressbar *pb; |
584 | struct skin_token_list *item; | ||
585 | struct viewport *vp = &curr_vp->vp; | 584 | struct viewport *vp = &curr_vp->vp; |
586 | struct skin_tag_parameter *param = element->params; | 585 | struct skin_tag_parameter *param = element->params; |
587 | int curr_param = 0; | 586 | int curr_param = 0; |
587 | char *image_filename = NULL; | ||
588 | 588 | ||
589 | if (element->params_count == 0 && | 589 | if (element->params_count == 0 && |
590 | element->tag->type != SKIN_TOKEN_PROGRESSBAR) | 590 | element->tag->type != SKIN_TOKEN_PROGRESSBAR) |
@@ -596,11 +596,10 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
596 | if (!pb) | 596 | if (!pb) |
597 | return WPS_ERROR_INVALID_PARAM; | 597 | return WPS_ERROR_INVALID_PARAM; |
598 | pb->vp = vp; | 598 | pb->vp = vp; |
599 | pb->have_bitmap_pb = false; | ||
600 | pb->bm.data = NULL; /* no bitmap specified */ | ||
601 | pb->follow_lang_direction = follow_lang_direction > 0; | 599 | pb->follow_lang_direction = follow_lang_direction > 0; |
602 | pb->nofill = false; | 600 | pb->nofill = false; |
603 | pb->nobar = false; | 601 | pb->nobar = false; |
602 | pb->image = NULL; | ||
604 | pb->slider = NULL; | 603 | pb->slider = NULL; |
605 | pb->invert_fill_direction = false; | 604 | pb->invert_fill_direction = false; |
606 | pb->horizontal = true; | 605 | pb->horizontal = true; |
@@ -615,11 +614,6 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
615 | return 0; | 614 | return 0; |
616 | } | 615 | } |
617 | 616 | ||
618 | item = new_skin_token_list_item(token, pb); | ||
619 | if (!item) | ||
620 | return -1; | ||
621 | add_to_ll_chain(&wps_data->progressbars, item); | ||
622 | |||
623 | /* (x, y, width, height, ...) */ | 617 | /* (x, y, width, height, ...) */ |
624 | if (!isdefault(param)) | 618 | if (!isdefault(param)) |
625 | pb->x = param->data.number; | 619 | pb->x = param->data.number; |
@@ -696,7 +690,8 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
696 | { | 690 | { |
697 | curr_param++; | 691 | curr_param++; |
698 | param++; | 692 | param++; |
699 | pb->bm.data = param->data.text; | 693 | image_filename = param->data.text; |
694 | |||
700 | } | 695 | } |
701 | else /* option needs the next param */ | 696 | else /* option needs the next param */ |
702 | return -1; | 697 | return -1; |
@@ -710,10 +705,37 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
710 | else if (!strcmp(param->data.text, "horizontal")) | 705 | else if (!strcmp(param->data.text, "horizontal")) |
711 | pb->horizontal = true; | 706 | pb->horizontal = true; |
712 | else if (curr_param == 4) | 707 | else if (curr_param == 4) |
713 | pb->bm.data = param->data.text; | 708 | image_filename = param->data.text; |
714 | 709 | ||
715 | curr_param++; | 710 | curr_param++; |
716 | } | 711 | } |
712 | |||
713 | if (image_filename) | ||
714 | { | ||
715 | pb->image = find_image(image_filename, wps_data); | ||
716 | if (!pb->image) /* load later */ | ||
717 | { | ||
718 | struct gui_img* img = (struct gui_img*)skin_buffer_alloc(sizeof(struct gui_img)); | ||
719 | if (!img) | ||
720 | return WPS_ERROR_INVALID_PARAM; | ||
721 | /* save a pointer to the filename */ | ||
722 | img->bm.data = (char*)image_filename; | ||
723 | img->label = image_filename; | ||
724 | img->x = 0; | ||
725 | img->y = 0; | ||
726 | img->num_subimages = 1; | ||
727 | img->always_display = false; | ||
728 | img->display = -1; | ||
729 | img->using_preloaded_icons = false; | ||
730 | img->vp = &curr_vp->vp; | ||
731 | struct skin_token_list *item = | ||
732 | (struct skin_token_list *)new_skin_token_list_item(NULL, img); | ||
733 | if (!item) | ||
734 | return WPS_ERROR_INVALID_PARAM; | ||
735 | add_to_ll_chain(&wps_data->images, item); | ||
736 | pb->image = img; | ||
737 | } | ||
738 | } | ||
717 | 739 | ||
718 | 740 | ||
719 | if (token->type == SKIN_TOKEN_VOLUME) | 741 | if (token->type == SKIN_TOKEN_VOLUME) |
@@ -1033,7 +1055,6 @@ static void skin_data_reset(struct wps_data *wps_data) | |||
1033 | wps_data->tree = NULL; | 1055 | wps_data->tree = NULL; |
1034 | #ifdef HAVE_LCD_BITMAP | 1056 | #ifdef HAVE_LCD_BITMAP |
1035 | wps_data->images = NULL; | 1057 | wps_data->images = NULL; |
1036 | wps_data->progressbars = NULL; | ||
1037 | #endif | 1058 | #endif |
1038 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | 1059 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
1039 | if (wps_data->backdrop_id >= 0) | 1060 | if (wps_data->backdrop_id >= 0) |
@@ -1118,19 +1139,7 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1118 | { | 1139 | { |
1119 | struct skin_token_list *list; | 1140 | struct skin_token_list *list; |
1120 | bool retval = true; /* return false if a single image failed to load */ | 1141 | bool retval = true; /* return false if a single image failed to load */ |
1121 | /* do the progressbars */ | 1142 | |
1122 | list = wps_data->progressbars; | ||
1123 | while (list) | ||
1124 | { | ||
1125 | struct progressbar *pb = (struct progressbar*)list->token->value.data; | ||
1126 | if (pb->bm.data) | ||
1127 | { | ||
1128 | pb->have_bitmap_pb = load_skin_bmp(wps_data, &pb->bm, bmpdir); | ||
1129 | if (!pb->have_bitmap_pb) /* no success */ | ||
1130 | retval = false; | ||
1131 | } | ||
1132 | list = list->next; | ||
1133 | } | ||
1134 | /* regular images */ | 1143 | /* regular images */ |
1135 | list = wps_data->images; | 1144 | list = wps_data->images; |
1136 | while (list) | 1145 | while (list) |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 16020a3590..24edde7b93 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -103,9 +103,8 @@ struct progressbar { | |||
103 | short width; | 103 | short width; |
104 | short height; | 104 | short height; |
105 | bool follow_lang_direction; | 105 | bool follow_lang_direction; |
106 | /*progressbar image*/ | 106 | |
107 | struct bitmap bm; | 107 | struct gui_img *image; |
108 | bool have_bitmap_pb; | ||
109 | 108 | ||
110 | bool invert_fill_direction; | 109 | bool invert_fill_direction; |
111 | bool nofill; | 110 | bool nofill; |
@@ -263,7 +262,6 @@ struct wps_data | |||
263 | struct skin_element *tree; | 262 | struct skin_element *tree; |
264 | #ifdef HAVE_LCD_BITMAP | 263 | #ifdef HAVE_LCD_BITMAP |
265 | struct skin_token_list *images; | 264 | struct skin_token_list *images; |
266 | struct skin_token_list *progressbars; | ||
267 | #endif | 265 | #endif |
268 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | 266 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
269 | struct { | 267 | struct { |