summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-03-15 22:50:17 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2012-03-15 22:52:53 +1100
commit014a08cabb856b2360419aac404744029ee4748c (patch)
tree1bd05c47281446eec2568a96a0e32e16439f1262 /apps
parentdcc78cb86764e5f02bc89693f64dc38c82f776ad (diff)
downloadrockbox-014a08cabb856b2360419aac404744029ee4748c.tar.gz
rockbox-014a08cabb856b2360419aac404744029ee4748c.tar.bz2
rockbox-014a08cabb856b2360419aac404744029ee4748c.zip
skin_engine: New tag to draw a rectangle (optionally with a gradient)
%dr(x, y, width, height, [colour1[, colour2]]): x,y - viewport relative pixel coordinates to start the rectangle. width, height - obvious. can be '-' to fill the viewport if both colours are left out the viewports foreground colour will be used if one colour is specified it will fill the rectangle that colour. if both colours are specified it will gradient fill the rectangle. Change-Id: Iad451e99ded663bc7c5d182443659db7d909b388
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/skin_engine/skin_parser.c48
-rw-r--r--apps/gui/skin_engine/skin_render.c23
-rw-r--r--apps/gui/skin_engine/wps_internals.h9
-rw-r--r--apps/screen_access.c3
-rw-r--r--apps/screen_access.h4
5 files changed, 86 insertions, 1 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 2d9d7cd807..49373eca32 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -638,6 +638,51 @@ static int parse_viewporttextstyle(struct skin_element *element,
return 0;
}
+static int parse_drawrectangle( struct skin_element *element,
+ struct wps_token *token,
+ struct wps_data *wps_data)
+{
+ (void)wps_data;
+ struct draw_rectangle *rect =
+ (struct draw_rectangle *)skin_buffer_alloc(sizeof(struct draw_rectangle));
+
+ if (!rect)
+ return -1;
+
+ rect->x = get_param(element, 0)->data.number;
+ rect->y = get_param(element, 1)->data.number;
+
+ if (isdefault(get_param(element, 2)))
+ rect->width = curr_vp->vp.width - rect->x;
+ else
+ rect->width = get_param(element, 2)->data.number;
+
+ if (isdefault(get_param(element, 3)))
+ rect->height = curr_vp->vp.height - rect->y;
+ else
+ rect->height = get_param(element, 3)->data.number;
+
+ rect->start_colour = curr_vp->vp.fg_pattern;
+ rect->end_colour = curr_vp->vp.fg_pattern;
+
+ if (element->params_count > 4)
+ {
+ if (!parse_color(curr_screen, get_param_text(element, 4),
+ &rect->start_colour))
+ return -1;
+ rect->end_colour = rect->start_colour;
+ }
+ if (element->params_count > 5)
+ {
+ if (!parse_color(curr_screen, get_param_text(element, 5),
+ &rect->end_colour))
+ return -1;
+ }
+ token->value.data = PTRTOSKINOFFSET(skin_buffer, rect);
+
+ return 0;
+}
+
static int parse_viewportcolour(struct skin_element *element,
struct wps_token *token,
struct wps_data *wps_data)
@@ -2013,6 +2058,9 @@ static int skin_element_callback(struct skin_element* element, void* data)
sb_skin_has_title(curr_screen);
#endif
break;
+ case SKIN_TOKEN_DRAWRECTANGLE:
+ function = parse_drawrectangle;
+ break;
#endif
case SKIN_TOKEN_FILE_DIRECTORY:
token->value.i = get_param(element, 0)->data.number;
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index 80d8c83d27..7ceb0bce17 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -176,8 +176,29 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
if (do_refresh)
draw_peakmeters(gwps, info->line_number, vp);
break;
+ case SKIN_TOKEN_DRAWRECTANGLE:
+ if (do_refresh)
+ {
+ struct draw_rectangle *rect =
+ SKINOFFSETTOPTR(skin_buffer, token->value.data);
+#ifdef HAVE_LCD_COLOR
+ if (rect->start_colour != rect->end_colour &&
+ gwps->display->screen_type == SCREEN_MAIN)
+ {
+ gwps->display->gradient_fillrect(rect->x, rect->y, rect->width,
+ rect->height, rect->start_colour, rect->end_colour);
+ }
+ else
#endif
-#ifdef HAVE_LCD_BITMAP
+ {
+ unsigned backup = vp->fg_pattern;
+ vp->fg_pattern = rect->start_colour;
+ gwps->display->fillrect(rect->x, rect->y, rect->width,
+ rect->height);
+ vp->fg_pattern = backup;
+ }
+ }
+ break;
case SKIN_TOKEN_PEAKMETER_LEFTBAR:
case SKIN_TOKEN_PEAKMETER_RIGHTBAR:
data->peak_meter_enabled = true;
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 3b1d7cf054..3788712c9d 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -113,6 +113,15 @@ struct progressbar {
bool horizontal;
OFFSETTYPE(struct gui_img *) backdrop;
};
+
+struct draw_rectangle {
+ int x;
+ int y;
+ int width;
+ int height;
+ unsigned start_colour;
+ unsigned end_colour;
+};
#endif
diff --git a/apps/screen_access.c b/apps/screen_access.c
index 43000e1360..fc92210981 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -264,6 +264,9 @@ struct screen screens[NB_SCREENS] =
#endif
#if defined(HAVE_LCD_BITMAP)
.set_framebuffer = (void*)lcd_set_framebuffer,
+#if defined(HAVE_LCD_COLOR)
+ .gradient_fillrect = lcd_gradient_fillrect,
+#endif
#endif
},
#if NB_SCREENS == 2
diff --git a/apps/screen_access.h b/apps/screen_access.h
index 343829b915..ab2ef4f14d 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -162,6 +162,10 @@ struct screen
#endif
#if defined(HAVE_LCD_BITMAP)
void (*set_framebuffer)(void *framebuffer);
+#if defined(HAVE_LCD_COLOR)
+ void (*gradient_fillrect)(int x, int y, int width, int height,
+ unsigned start, unsigned end);
+#endif
#endif
};