draw: remove border markup, move it to textbox
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
29702799dc
commit
68f31f0629
|
@ -49,9 +49,6 @@ List of *awesome* markup elements and their attributes:
|
|||
- image: path to a background image
|
||||
- align: background image alignment
|
||||
- resize: resize background image to text size
|
||||
* border
|
||||
- color: border color
|
||||
- width: border width
|
||||
* margin
|
||||
- left: left margin in pixel
|
||||
- right: right margin in pixel
|
||||
|
|
24
draw.c
24
draw.c
|
@ -164,8 +164,6 @@ 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[2] == '_') /* bg_margin */
|
||||
for(; *names; names++, values++)
|
||||
switch(a_tokenize(*names, -1))
|
||||
|
@ -202,23 +200,6 @@ 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))
|
||||
{
|
||||
case A_TK_COLOR:
|
||||
reqs[++reqs_nbr] = xcolor_init_unchecked(&data->border.color,
|
||||
*values,
|
||||
a_strlen(*values));
|
||||
break;
|
||||
case A_TK_WIDTH:
|
||||
data->border.width = atoi(*values);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 't': /* text */
|
||||
for(; *names; names++, values++)
|
||||
|
@ -268,7 +249,7 @@ static bool
|
|||
draw_text_markup_expand(draw_parser_data_t *data,
|
||||
const char *str, ssize_t slen)
|
||||
{
|
||||
static char const * const elements[] = { "bg", "bg_margin", "text", "margin", "border", NULL };
|
||||
static char const * const elements[] = { "bg", "bg_margin", "text", "margin", NULL };
|
||||
markup_parser_data_t p =
|
||||
{
|
||||
.elements = elements,
|
||||
|
@ -366,9 +347,6 @@ draw_text(draw_context_t *ctx, font_t *font, PangoEllipsizeMode ellip, PangoWrap
|
|||
if(pdata->has_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)
|
||||
{
|
||||
x = area.x;
|
||||
|
|
5
draw.h
5
draw.h
|
@ -170,11 +170,6 @@ typedef struct
|
|||
int offset;
|
||||
xcolor_t color;
|
||||
} shadow;
|
||||
struct
|
||||
{
|
||||
int width;
|
||||
xcolor_t color;
|
||||
} border;
|
||||
} draw_parser_data_t;
|
||||
|
||||
void draw_text(draw_context_t *, font_t *, PangoEllipsizeMode, PangoWrapMode, area_t, const char *, ssize_t len, draw_parser_data_t *, area_t *);
|
||||
|
|
|
@ -39,6 +39,12 @@ typedef struct
|
|||
PangoWrapMode wrap;
|
||||
/** Draw parser data */
|
||||
draw_parser_data_t pdata;
|
||||
/** Border */
|
||||
struct
|
||||
{
|
||||
int width;
|
||||
xcolor_t color;
|
||||
} border;
|
||||
} textbox_data_t;
|
||||
|
||||
static area_t
|
||||
|
@ -76,6 +82,10 @@ textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
|
|||
int screen, wibox_t *p)
|
||||
{
|
||||
textbox_data_t *d = widget->data;
|
||||
|
||||
if(d->border.width > 0)
|
||||
draw_rectangle(ctx, geometry, d->border.width, false, &d->border.color);
|
||||
|
||||
draw_text(ctx, globalconf.font, d->ellip, d->wrap, geometry, d->text, d->len, &d->pdata, &d->extents);
|
||||
}
|
||||
|
||||
|
@ -100,6 +110,8 @@ textbox_destructor(widget_t *w)
|
|||
* \lfield width The width of the textbox. Set to 0 for auto.
|
||||
* \lfield wrap The wrap mode: word, char, word_char.
|
||||
* \lfield ellipsize The ellipsize mode: start, middle or end.
|
||||
* \lfield border_width The border width to draw around.
|
||||
* \lfield border_color The border color.
|
||||
*/
|
||||
static int
|
||||
luaA_textbox_index(lua_State *L, awesome_token_t token)
|
||||
|
@ -109,6 +121,12 @@ luaA_textbox_index(lua_State *L, awesome_token_t token)
|
|||
|
||||
switch(token)
|
||||
{
|
||||
case A_TK_BORDER_WIDTH:
|
||||
lua_pushnumber(L, d->border.width);
|
||||
return 1;
|
||||
case A_TK_BORDER_COLOR:
|
||||
luaA_pushcolor(L, &d->border.color);
|
||||
return 1;
|
||||
case A_TK_TEXT:
|
||||
lua_pushstring(L, d->text);
|
||||
return 1;
|
||||
|
@ -163,6 +181,13 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
|
|||
|
||||
switch(token)
|
||||
{
|
||||
case A_TK_BORDER_COLOR:
|
||||
if((buf = luaL_checklstring(L, 3, &len)))
|
||||
xcolor_init_reply(xcolor_init_unchecked(&d->border.color, buf, len));
|
||||
break;
|
||||
case A_TK_BORDER_WIDTH:
|
||||
d->border.width = luaL_checknumber(L, 3);
|
||||
break;
|
||||
case A_TK_TEXT:
|
||||
if(lua_isnil(L, 3)
|
||||
|| (buf = luaL_checklstring(L, 3, &len)))
|
||||
|
|
Loading…
Reference in New Issue