draw: support for top margin

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-08-19 11:38:57 +02:00
parent d96bcdc2a4
commit a56997aefb
3 changed files with 5 additions and 2 deletions

View File

@ -55,6 +55,7 @@ List of awesome markup and their attribute:
* margin * margin
- left: left margin in pixel - left: left margin in pixel
- right: right margin in pixel - right: right margin in pixel
- top: top margin in pixel
* text * text
- align: text alignment - align: text alignment
- shadow: shadow color - shadow: shadow color

View File

@ -296,6 +296,8 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
case A_TK_RIGHT: case A_TK_RIGHT:
data->margin.right = atoi(*values); data->margin.right = atoi(*values);
break; break;
case A_TK_TOP:
data->margin.top = atoi(*values);
default: default:
break; break;
} }
@ -419,7 +421,7 @@ draw_text(draw_context_t *ctx, font_t *font,
/* + 1 is added for rounding, so that in any case of doubt we rather draw /* + 1 is added for rounding, so that in any case of doubt we rather draw
* the text 1px lower than too high which usually results in a better type * the text 1px lower than too high which usually results in a better type
* face */ * face */
y = area.y + (ctx->height - font->height + 1) / 2; y = area.y + (ctx->height - font->height + 1) / 2 + pdata->margin.top;
switch(pdata->align) switch(pdata->align)
{ {

View File

@ -179,7 +179,7 @@ typedef struct
alignment_t align; alignment_t align;
struct struct
{ {
int left, right; int left, right, top;
} margin; } margin;
bool has_bg_color; bool has_bg_color;
xcolor_t bg_color; xcolor_t bg_color;