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 */
|
/* hack: markup.c validates tags so we can avoid strcmps here */
|
||||||
switch (*elem) {
|
switch (*elem) {
|
||||||
case 'b':
|
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++)
|
for(; *names; names++, values++)
|
||||||
switch(a_tokenize(*names, -1))
|
switch(a_tokenize(*names, -1))
|
||||||
{
|
{
|
||||||
|
@ -233,6 +247,8 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else /* border */
|
else /* border */
|
||||||
for(; *names; names++, values++)
|
for(; *names; names++, values++)
|
||||||
switch(a_tokenize(*names, -1))
|
switch(a_tokenize(*names, -1))
|
||||||
|
@ -301,7 +317,7 @@ bool
|
||||||
draw_text_markup_expand(draw_parser_data_t *data,
|
draw_text_markup_expand(draw_parser_data_t *data,
|
||||||
const char *str, ssize_t slen)
|
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 =
|
markup_parser_data_t p =
|
||||||
{
|
{
|
||||||
.elements = elements,
|
.elements = elements,
|
||||||
|
@ -387,7 +403,10 @@ draw_text(draw_context_t *ctx, font_t *font,
|
||||||
default:
|
default:
|
||||||
break;
|
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);
|
pango_layout_set_text(ctx->layout, pdata->text, pdata->len);
|
||||||
|
|
|
@ -181,6 +181,10 @@ typedef struct
|
||||||
{
|
{
|
||||||
int left, right, top;
|
int left, right, top;
|
||||||
} margin;
|
} margin;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int top, left;
|
||||||
|
} bg_margin;
|
||||||
bool has_bg_color;
|
bool has_bg_color;
|
||||||
xcolor_t bg_color;
|
xcolor_t bg_color;
|
||||||
draw_image_t *bg_image;
|
draw_image_t *bg_image;
|
||||||
|
|
Loading…
Reference in New Issue