Theme Engine: Fix progress bar slider (FS#12823)

Fix the need to resize progress bar when using a slider.
Slider stays in bounds. Progress bar is not resized.
Works well with square sliders that should not overlap
edge of progress bar. also works with rounded sliders.

You can also make progress bar the full width of screen
while using a slider. Before if you would make the
progress bar the full width of the screen and add a slider
the progress bar would look like it was padded on both ends.

This fixes FS#12823

Change-Id: I60345efc5cd0f46286f2591ed032f0d9320d1c3e
Reviewed-on: http://gerrit.rockbox.org/402
Reviewed-by: Hayden Pearce <saint.lascivious@gmail.com>
Tested-by: Hayden Pearce <saint.lascivious@gmail.com>
Reviewed-by: Jonathan Gordon <rockbox@jdgordon.info>
This commit is contained in:
Alex Mayer 2013-01-22 20:44:18 -05:00 committed by Jonathan Gordon
parent bc05242517
commit ee758c5a97

8
apps/gui/skin_engine/skin_display.c Normal file → Executable file
View file

@ -207,16 +207,14 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
/* clear the slider */ /* clear the slider */
screen_clear_area(display, x, y, width, height); screen_clear_area(display, x, y, width, height);
/* shrink the bar so the slider is inside bounds */ /* account for the sliders width in the progressbar */
if (flags&HORIZONTAL) if (flags&HORIZONTAL)
{ {
width -= img->bm.width; width -= img->bm.width;
x += img->bm.width / 2;
} }
else else
{ {
height -= img->bm.height; height -= img->bm.height;
y += img->bm.height / 2;
} }
} }
@ -224,7 +222,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
{ {
struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->backdrop); struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->backdrop);
img->bm.data = core_get_data(img->buflib_handle); img->bm.data = core_get_data(img->buflib_handle);
display->bmp_part(&img->bm, 0, 0, x, y, width, height); display->bmp_part(&img->bm, 0, 0, x, y, pb->width, height);
flags |= DONT_CLEAR_EXCESS; flags |= DONT_CLEAR_EXCESS;
} }
@ -257,7 +255,6 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
xoff = width * end / length; xoff = width * end / length;
if (flags&INVERTFILL) if (flags&INVERTFILL)
xoff = width - xoff; xoff = width - xoff;
xoff -= w / 2;
} }
else else
{ {
@ -265,7 +262,6 @@ 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;
yoff -= h / 2;
} }
display->bmp_part(&img->bm, 0, 0, x + xoff, y + yoff, w, h); display->bmp_part(&img->bm, 0, 0, x + xoff, y + yoff, w, h);
} }