draw: add support for top and left bg_margin
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
3b895d84ed
commit
4c76b5a1d5
|
@ -207,7 +207,21 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
|
|||
/* hack: markup.c validates tags so we can avoid strcmps here */
|
||||
switch (*elem) {
|
||||
case 'b':
|
||||
if(elem[1] == 'g') /* bg */
|
||||
if(elem[1] == 'g') /* bg? */
|
||||
{
|
||||
if(elem[2] == '_') /* bg_margin */
|
||||
for(; *names; names++, values++)
|
||||
switch(a_tokenize(*names, -1))
|
||||
{
|
||||
case A_TK_LEFT:
|
||||
data->bg_margin.left = atoi(*values);
|
||||
break;
|
||||
case A_TK_TOP:
|
||||
data->bg_margin.top = atoi(*values);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else /* bg */
|
||||
for(; *names; names++, values++)
|
||||
switch(a_tokenize(*names, -1))
|
||||
{
|
||||
|
@ -233,6 +247,8 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else /* border */
|
||||
for(; *names; names++, values++)
|
||||
switch(a_tokenize(*names, -1))
|
||||
|
@ -301,7 +317,7 @@ bool
|
|||
draw_text_markup_expand(draw_parser_data_t *data,
|
||||
const char *str, ssize_t slen)
|
||||
{
|
||||
static char const * const elements[] = { "bg", "text", "margin", "border", NULL };
|
||||
static char const * const elements[] = { "bg", "bg_margin", "text", "margin", "border", NULL };
|
||||
markup_parser_data_t p =
|
||||
{
|
||||
.elements = elements,
|
||||
|
@ -387,7 +403,10 @@ draw_text(draw_context_t *ctx, font_t *font,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
draw_image(ctx, x, y, pdata->bg_resize ? area.height : 0, pdata->bg_image);
|
||||
draw_image(ctx,
|
||||
x + pdata->bg_margin.left,
|
||||
y + pdata->bg_margin.top,
|
||||
pdata->bg_resize ? area.height : 0, pdata->bg_image);
|
||||
}
|
||||
|
||||
pango_layout_set_text(ctx->layout, pdata->text, pdata->len);
|
||||
|
|
|
@ -181,6 +181,10 @@ typedef struct
|
|||
{
|
||||
int left, right, top;
|
||||
} margin;
|
||||
struct
|
||||
{
|
||||
int top, left;
|
||||
} bg_margin;
|
||||
bool has_bg_color;
|
||||
xcolor_t bg_color;
|
||||
draw_image_t *bg_image;
|
||||
|
|
Loading…
Reference in New Issue