1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jonathan Gordon 2012-03-15 22:50:17 +11:00
parent dcc78cb867
commit 014a08cabb
9 changed files with 105 additions and 6 deletions

View file

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