draw: add background alignment
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
9ad5f651fe
commit
9caa9fc96f
|
@ -226,6 +226,8 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
|
||||||
case A_TK_IMAGE:
|
case A_TK_IMAGE:
|
||||||
data->bg_image = draw_image_new(*values);
|
data->bg_image = draw_image_new(*values);
|
||||||
break;
|
break;
|
||||||
|
case A_TK_ALIGN:
|
||||||
|
data->bg_align = draw_align_fromstr(*values, -1);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +340,20 @@ draw_text(draw_context_t *ctx, font_t *font,
|
||||||
|
|
||||||
if(pdata->bg_image)
|
if(pdata->bg_image)
|
||||||
{
|
{
|
||||||
draw_image(ctx, area.x, area.y, 0, pdata->bg_image);
|
x = area.x;
|
||||||
|
y = area.y;
|
||||||
|
switch(pdata->bg_align)
|
||||||
|
{
|
||||||
|
case AlignCenter:
|
||||||
|
x += (area.width - pdata->bg_image->width) / 2;
|
||||||
|
break;
|
||||||
|
case AlignRight:
|
||||||
|
x += area.width- pdata->bg_image->width;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
draw_image(ctx, x, y, 0, pdata->bg_image);
|
||||||
draw_image_delete(&pdata->bg_image);
|
draw_image_delete(&pdata->bg_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ typedef struct
|
||||||
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;
|
||||||
|
alignment_t bg_align;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
|
Loading…
Reference in New Issue