draw: remove alignment markup
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4918614d44
commit
3c304bca07
|
@ -54,7 +54,6 @@ List of *awesome* markup elements and their attributes:
|
|||
- right: right margin in pixel
|
||||
- top: top margin in pixel
|
||||
* text
|
||||
- align: text alignment
|
||||
- shadow: shadow color
|
||||
- shadow_offset: shadow color offset in pixel
|
||||
|
||||
|
|
10
draw.c
10
draw.c
|
@ -205,9 +205,6 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
|
|||
for(; *names; names++, values++)
|
||||
switch(a_tokenize(*names, -1))
|
||||
{
|
||||
case A_TK_ALIGN:
|
||||
data->align = draw_align_fromstr(*values, -1);
|
||||
break;
|
||||
case A_TK_SHADOW:
|
||||
reqs[++reqs_nbr] = xcolor_init_unchecked(&data->shadow.color,
|
||||
*values,
|
||||
|
@ -314,6 +311,7 @@ draw_context_init(draw_context_t *d, int phys_screen,
|
|||
* \param font The font to use.
|
||||
* \param elip Ellipsize mode.
|
||||
* \param wrap Wrap mode.
|
||||
* \param align Text alignment.
|
||||
* \param area Area to draw to.
|
||||
* \param text Text to draw.
|
||||
* \param len Text to draw length.
|
||||
|
@ -322,8 +320,8 @@ draw_context_init(draw_context_t *d, int phys_screen,
|
|||
*/
|
||||
void
|
||||
draw_text(draw_context_t *ctx, font_t *font, PangoEllipsizeMode ellip, PangoWrapMode wrap,
|
||||
area_t area, const char *text, ssize_t len, draw_parser_data_t *pdata,
|
||||
area_t *ext)
|
||||
alignment_t align, area_t area, const char *text, ssize_t len,
|
||||
draw_parser_data_t *pdata, area_t *ext)
|
||||
{
|
||||
int x, y;
|
||||
draw_parser_data_t parser_data;
|
||||
|
@ -387,7 +385,7 @@ draw_text(draw_context_t *ctx, font_t *font, PangoEllipsizeMode ellip, PangoWrap
|
|||
|
||||
/* only honors alignment if enough space */
|
||||
if(ext->width < area.width)
|
||||
switch(pdata->align)
|
||||
switch(align)
|
||||
{
|
||||
case AlignCenter:
|
||||
x += (area.width - ext->width) / 2;
|
||||
|
|
3
draw.h
3
draw.h
|
@ -148,7 +148,6 @@ typedef struct
|
|||
PangoAttrList *attr_list;
|
||||
char *text;
|
||||
ssize_t len;
|
||||
alignment_t align;
|
||||
struct
|
||||
{
|
||||
int left, right, top;
|
||||
|
@ -169,7 +168,7 @@ typedef struct
|
|||
} shadow;
|
||||
} 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 *);
|
||||
void draw_text(draw_context_t *, font_t *, PangoEllipsizeMode, PangoWrapMode, alignment_t, area_t, const char *, ssize_t len, draw_parser_data_t *, area_t *);
|
||||
void draw_rectangle(draw_context_t *, area_t, float, bool, const xcolor_t *);
|
||||
void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, vector_t,
|
||||
const xcolor_t *, const xcolor_t *, const xcolor_t *);
|
||||
|
|
|
@ -45,6 +45,8 @@ typedef struct
|
|||
int width;
|
||||
xcolor_t color;
|
||||
} border;
|
||||
/** Text alignment */
|
||||
alignment_t align;
|
||||
} textbox_data_t;
|
||||
|
||||
static area_t
|
||||
|
@ -86,7 +88,8 @@ textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
|
|||
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);
|
||||
draw_text(ctx, globalconf.font, d->ellip, d->wrap, d->align,
|
||||
geometry, d->text, d->len, &d->pdata, &d->extents);
|
||||
}
|
||||
|
||||
/** Delete a textbox widget.
|
||||
|
@ -112,6 +115,7 @@ textbox_destructor(widget_t *w)
|
|||
* \lfield ellipsize The ellipsize mode: start, middle or end.
|
||||
* \lfield border_width The border width to draw around.
|
||||
* \lfield border_color The border color.
|
||||
* \lfield align Text alignment, left, center or right.
|
||||
*/
|
||||
static int
|
||||
luaA_textbox_index(lua_State *L, awesome_token_t token)
|
||||
|
@ -121,6 +125,9 @@ luaA_textbox_index(lua_State *L, awesome_token_t token)
|
|||
|
||||
switch(token)
|
||||
{
|
||||
case A_TK_ALIGN:
|
||||
lua_pushstring(L, draw_align_tostr(d->align));
|
||||
return 1;
|
||||
case A_TK_BORDER_WIDTH:
|
||||
lua_pushnumber(L, d->border.width);
|
||||
return 1;
|
||||
|
@ -181,6 +188,10 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
|
|||
|
||||
switch(token)
|
||||
{
|
||||
case A_TK_ALIGN:
|
||||
if((buf = luaL_checklstring(L, 3, &len)))
|
||||
d->align = draw_align_fromstr(buf, len);
|
||||
break;
|
||||
case A_TK_BORDER_COLOR:
|
||||
if((buf = luaL_checklstring(L, 3, &len)))
|
||||
xcolor_init_reply(xcolor_init_unchecked(&d->border.color, buf, len));
|
||||
|
|
Loading…
Reference in New Issue