draw: add support for border around text
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
9c495c0dee
commit
ddae6f76b2
|
@ -216,7 +216,8 @@ 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': /* bg */
|
case 'b':
|
||||||
|
if(elem[1] == 'g') /* bg */
|
||||||
for(; *names; names++, values++)
|
for(; *names; names++, values++)
|
||||||
switch(a_tokenize(*names, -1))
|
switch(a_tokenize(*names, -1))
|
||||||
{
|
{
|
||||||
|
@ -235,6 +236,19 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else /* border */
|
||||||
|
for(; *names; names++, values++)
|
||||||
|
switch(a_tokenize(*names, -1))
|
||||||
|
{
|
||||||
|
case A_TK_COLOR:
|
||||||
|
xcolor_init(&data->border.color, data->connection, data->phys_screen, *values);
|
||||||
|
break;
|
||||||
|
case A_TK_WIDTH:
|
||||||
|
data->border.width = atoi(*values);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 't': /* text */
|
case 't': /* text */
|
||||||
for(; *names; names++, values++)
|
for(; *names; names++, values++)
|
||||||
|
@ -275,7 +289,7 @@ static 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", NULL };
|
static char const * const elements[] = { "bg", "text", "margin", "border", NULL };
|
||||||
markup_parser_data_t p =
|
markup_parser_data_t p =
|
||||||
{
|
{
|
||||||
.elements = elements,
|
.elements = elements,
|
||||||
|
@ -342,6 +356,9 @@ draw_text(draw_context_t *ctx, font_t *font,
|
||||||
if(pdata->has_bg_color)
|
if(pdata->has_bg_color)
|
||||||
draw_rectangle(ctx, area, 1.0, true, &pdata->bg_color);
|
draw_rectangle(ctx, area, 1.0, true, &pdata->bg_color);
|
||||||
|
|
||||||
|
if(pdata->border.width > 0)
|
||||||
|
draw_rectangle(ctx, area, pdata->border.width, false, &pdata->border.color);
|
||||||
|
|
||||||
if(pdata->bg_image)
|
if(pdata->bg_image)
|
||||||
{
|
{
|
||||||
x = area.x;
|
x = area.x;
|
||||||
|
|
|
@ -189,6 +189,11 @@ typedef struct
|
||||||
int offset;
|
int offset;
|
||||||
xcolor_t color;
|
xcolor_t color;
|
||||||
} shadow;
|
} shadow;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
xcolor_t color;
|
||||||
|
} border;
|
||||||
} draw_parser_data_t;
|
} draw_parser_data_t;
|
||||||
|
|
||||||
void draw_parser_data_init(draw_parser_data_t *);
|
void draw_parser_data_init(draw_parser_data_t *);
|
||||||
|
|
Loading…
Reference in New Issue