1
0
Fork 0
forked from len0rd/rockbox

improvement for bar tag with slider.

-fix bug the slider is drawn outside of the bounds (FS#11658).
-offset the slider position so that the center of the slider indicates current position.
-add nobar option. if this option is set, the bar isn't drawn at all.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28248 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-10-12 12:17:39 +00:00
parent 69e379a47b
commit 3eb5826c8a
4 changed files with 48 additions and 22 deletions

View file

@ -131,7 +131,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
struct viewport *vp = pb->vp; struct viewport *vp = pb->vp;
struct wps_state *state = skin_get_global_state(); struct wps_state *state = skin_get_global_state();
struct mp3entry *id3 = state->id3; struct mp3entry *id3 = state->id3;
int y = pb->y, height = pb->height; int x = pb->x, y = pb->y, width = pb->width, height = pb->height;
unsigned long length, end; unsigned long length, end;
int flags = HORIZONTAL; int flags = HORIZONTAL;
@ -194,29 +194,48 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
flags |= INNER_NOFILL; flags |= INNER_NOFILL;
} }
if (pb->have_bitmap_pb) if (pb->slider)
gui_bitmap_scrollbar_draw(display, &pb->bm, {
pb->x, y, pb->width, height, struct gui_img *img = pb->slider;
length, 0, end, flags); /* clear the slider */
else screen_clear_area(display, x, y, width, height);
gui_scrollbar_draw(display, pb->x, y, pb->width, height,
length, 0, end, flags); /* shrink the bar so the slider is inside bounds */
if (flags&HORIZONTAL)
{
width -= img->bm.width;
x += img->bm.width / 2;
}
else
{
height -= img->bm.height;
y += img->bm.height / 2;
}
}
if (!pb->nobar)
{
if (pb->have_bitmap_pb)
gui_bitmap_scrollbar_draw(display, &pb->bm,
x, y, width, height,
length, 0, end, flags);
else
gui_scrollbar_draw(display, x, y, width, height,
length, 0, end, flags);
}
if (pb->slider) if (pb->slider)
{ {
int xoff = 0, yoff = 0; int xoff = 0, yoff = 0;
int w = pb->width, h = height; int w = width, h = height;
struct gui_img *img = pb->slider; struct gui_img *img = pb->slider;
if (flags&HORIZONTAL) if (flags&HORIZONTAL)
{ {
w = img->bm.width; w = img->bm.width;
xoff = pb->width * end / length; xoff = width * end / length;
if (flags&INVERTFILL) if (flags&INVERTFILL)
xoff = pb->width - xoff; xoff = width - xoff;
#if 0 /* maybe add this in later, make the slider bmp overlap abit */
xoff -= w / 2; xoff -= w / 2;
#endif
} }
else else
{ {
@ -224,23 +243,21 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
yoff = height * end / length; yoff = height * end / length;
if (flags&INVERTFILL) if (flags&INVERTFILL)
yoff = height - yoff; yoff = height - yoff;
#if 0 /* maybe add this in later, make the slider bmp overlap abit */
yoff -= h / 2; yoff -= h / 2;
#endif
} }
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
if(img->bm.format == FORMAT_MONO) { if(img->bm.format == FORMAT_MONO) {
#endif #endif
display->mono_bitmap_part(img->bm.data, display->mono_bitmap_part(img->bm.data,
0, 0, img->bm.width, 0, 0, img->bm.width,
pb->x + xoff, y + yoff, w, h); x + xoff, y + yoff, w, h);
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
} else { } else {
display->transparent_bitmap_part((fb_data *)img->bm.data, display->transparent_bitmap_part((fb_data *)img->bm.data,
0, 0, 0, 0,
STRIDE(display->screen_type, STRIDE(display->screen_type,
img->bm.width, img->bm.height), img->bm.width, img->bm.height),
pb->x + xoff, y + yoff, w, h); x + xoff, y + yoff, w, h);
} }
#endif #endif
} }
@ -251,18 +268,17 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
{ {
#ifdef AB_REPEAT_ENABLE #ifdef AB_REPEAT_ENABLE
if (ab_repeat_mode_enabled()) if (ab_repeat_mode_enabled())
ab_draw_markers(display, id3->length, ab_draw_markers(display, id3->length, x, y, width, height);
pb->x, y, pb->width, height);
#endif #endif
if (id3->cuesheet) if (id3->cuesheet)
cue_draw_markers(display, id3->cuesheet, id3->length, cue_draw_markers(display, id3->cuesheet, id3->length,
pb->x, y+1, pb->width, height-2); x, y+1, width, height-2);
} }
#if 0 /* disable for now CONFIG_TUNER */ #if 0 /* disable for now CONFIG_TUNER */
else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
{ {
presets_draw_markers(display, pb->x, y, pb->width, height); presets_draw_markers(display, x, y, width, height);
} }
#endif #endif
} }

View file

@ -600,6 +600,7 @@ static int parse_progressbar_tag(struct skin_element* element,
pb->bm.data = NULL; /* no bitmap specified */ pb->bm.data = NULL; /* no bitmap specified */
pb->follow_lang_direction = follow_lang_direction > 0; pb->follow_lang_direction = follow_lang_direction > 0;
pb->nofill = false; pb->nofill = false;
pb->nobar = false;
pb->slider = NULL; pb->slider = NULL;
pb->invert_fill_direction = false; pb->invert_fill_direction = false;
pb->horizontal = true; pb->horizontal = true;
@ -676,6 +677,8 @@ static int parse_progressbar_tag(struct skin_element* element,
pb->invert_fill_direction = true; pb->invert_fill_direction = true;
else if (!strcmp(param->data.text, "nofill")) else if (!strcmp(param->data.text, "nofill"))
pb->nofill = true; pb->nofill = true;
else if (!strcmp(param->data.text, "nobar"))
pb->nobar = true;
else if (!strcmp(param->data.text, "slider")) else if (!strcmp(param->data.text, "slider"))
{ {
if (curr_param+1 < element->params_count) if (curr_param+1 < element->params_count)

View file

@ -109,6 +109,7 @@ struct progressbar {
bool invert_fill_direction; bool invert_fill_direction;
bool nofill; bool nofill;
bool nobar;
struct gui_img *slider; struct gui_img *slider;
bool horizontal; bool horizontal;
}; };

View file

@ -650,16 +650,22 @@ Example:
\item[vertical] -- force the bar to be drawn vertically. \item[vertical] -- force the bar to be drawn vertically.
\item[invert] -- invert the draw direction (i.e. right to left, or top to \item[invert] -- invert the draw direction (i.e. right to left, or top to
bottom). bottom).
\item[slider] -- draw an preloaded image over the top of the bar. This must be \item[slider] -- draw an preloaded image over the top of the bar so that
the centre of the image matches current position. This must be
followed by the label of the desired image. followed by the label of the desired image.
\item[nofill] -- don't draw the fill bar, only the empty image (for the \item[nofill] -- don't draw the fill bar, only the empty image (for the
desired effect use with the ``slider'' option). desired effect use with the ``slider'' option).
\item[nobar] -- don't draw the bar entirely including frame (for use
with the ``slider'' option).
\end{description} \end{description}
Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw Example: \config{\%pb(0,0,-,-,-,nofill, slider, slider\_image, invert)} -- draw
a horizontal progressbar which doesn't fill and draws the image a horizontal progressbar which doesn't fill and draws the image
``slider\_image'' which moves right to left. ``slider\_image'' which moves right to left.
Note: if the slider option is used, the bar will be shrank so that the slider will fit
inside the specified width and height.
\section{Other Tags} \section{Other Tags}
\begin{tagmap} \begin{tagmap}
\config{\%(} & The character `('\\ \config{\%(} & The character `('\\