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
This commit is contained in:
Jonathan Gordon 2010-10-12 12:46:57 +00:00
parent 3eb5826c8a
commit 9acd242839
4 changed files with 40 additions and 31 deletions

View file

@ -214,8 +214,8 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
}
if (!pb->nobar)
{
if (pb->have_bitmap_pb)
gui_bitmap_scrollbar_draw(display, &pb->bm,
if (pb->image)
gui_bitmap_scrollbar_draw(display, &pb->image->bm,
x, y, width, height,
length, 0, end, flags);
else

View file

@ -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)

View file

@ -103,9 +103,8 @@ struct progressbar {
short width;
short height;
bool follow_lang_direction;
/*progressbar image*/
struct bitmap bm;
bool have_bitmap_pb;
struct gui_img *image;
bool invert_fill_direction;
bool nofill;
@ -263,7 +262,6 @@ struct wps_data
struct skin_element *tree;
#ifdef HAVE_LCD_BITMAP
struct skin_token_list *images;
struct skin_token_list *progressbars;
#endif
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
struct {

View file

@ -634,7 +634,7 @@ Example:
(\%XX should be replaced with the actual tag).
\begin{tagmap}
\config{\%XX(x, y, width, filename, [options])}
\config{\%XX(x, y, width, height, [options])}
& Draw the specified tag as a bar\newline
\config{x}: x co-ordinate at which to start drawing the bar.\newline
\config{y}: y co-ordinate at which to start drawing the bar.\newline
@ -646,6 +646,8 @@ Example:
\subsection{Options}
\begin{description}
\item[image] -- the next option is either the filename or image label to
use for the fill image.
\item[horizontal] -- force the bar to be drawn horizontally.
\item[vertical] -- force the bar to be drawn vertically.
\item[invert] -- invert the draw direction (i.e. right to left, or top to