draw: remove alignment markup

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-12-02 17:29:19 +01:00
parent 4918614d44
commit 3c304bca07
4 changed files with 17 additions and 10 deletions

View File

@ -54,7 +54,6 @@ List of *awesome* markup elements and their attributes:
- right: right margin in pixel - right: right margin in pixel
- top: top margin in pixel - top: top margin in pixel
* text * text
- align: text alignment
- shadow: shadow color - shadow: shadow color
- shadow_offset: shadow color offset in pixel - shadow_offset: shadow color offset in pixel

10
draw.c
View File

@ -205,9 +205,6 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
for(; *names; names++, values++) for(; *names; names++, values++)
switch(a_tokenize(*names, -1)) switch(a_tokenize(*names, -1))
{ {
case A_TK_ALIGN:
data->align = draw_align_fromstr(*values, -1);
break;
case A_TK_SHADOW: case A_TK_SHADOW:
reqs[++reqs_nbr] = xcolor_init_unchecked(&data->shadow.color, reqs[++reqs_nbr] = xcolor_init_unchecked(&data->shadow.color,
*values, *values,
@ -314,6 +311,7 @@ draw_context_init(draw_context_t *d, int phys_screen,
* \param font The font to use. * \param font The font to use.
* \param elip Ellipsize mode. * \param elip Ellipsize mode.
* \param wrap Wrap mode. * \param wrap Wrap mode.
* \param align Text alignment.
* \param area Area to draw to. * \param area Area to draw to.
* \param text Text to draw. * \param text Text to draw.
* \param len Text to draw length. * \param len Text to draw length.
@ -322,8 +320,8 @@ draw_context_init(draw_context_t *d, int phys_screen,
*/ */
void void
draw_text(draw_context_t *ctx, font_t *font, PangoEllipsizeMode ellip, PangoWrapMode wrap, 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, alignment_t align, area_t area, const char *text, ssize_t len,
area_t *ext) draw_parser_data_t *pdata, area_t *ext)
{ {
int x, y; int x, y;
draw_parser_data_t parser_data; 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 */ /* only honors alignment if enough space */
if(ext->width < area.width) if(ext->width < area.width)
switch(pdata->align) switch(align)
{ {
case AlignCenter: case AlignCenter:
x += (area.width - ext->width) / 2; x += (area.width - ext->width) / 2;

3
draw.h
View File

@ -148,7 +148,6 @@ typedef struct
PangoAttrList *attr_list; PangoAttrList *attr_list;
char *text; char *text;
ssize_t len; ssize_t len;
alignment_t align;
struct struct
{ {
int left, right, top; int left, right, top;
@ -169,7 +168,7 @@ typedef struct
} shadow; } shadow;
} draw_parser_data_t; } 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(draw_context_t *, area_t, float, bool, const xcolor_t *);
void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, vector_t, void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, vector_t,
const xcolor_t *, const xcolor_t *, const xcolor_t *); const xcolor_t *, const xcolor_t *, const xcolor_t *);

View File

@ -45,6 +45,8 @@ typedef struct
int width; int width;
xcolor_t color; xcolor_t color;
} border; } border;
/** Text alignment */
alignment_t align;
} textbox_data_t; } textbox_data_t;
static area_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) if(d->border.width > 0)
draw_rectangle(ctx, geometry, d->border.width, false, &d->border.color); 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. /** Delete a textbox widget.
@ -112,6 +115,7 @@ textbox_destructor(widget_t *w)
* \lfield ellipsize The ellipsize mode: start, middle or end. * \lfield ellipsize The ellipsize mode: start, middle or end.
* \lfield border_width The border width to draw around. * \lfield border_width The border width to draw around.
* \lfield border_color The border color. * \lfield border_color The border color.
* \lfield align Text alignment, left, center or right.
*/ */
static int static int
luaA_textbox_index(lua_State *L, awesome_token_t token) 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) switch(token)
{ {
case A_TK_ALIGN:
lua_pushstring(L, draw_align_tostr(d->align));
return 1;
case A_TK_BORDER_WIDTH: case A_TK_BORDER_WIDTH:
lua_pushnumber(L, d->border.width); lua_pushnumber(L, d->border.width);
return 1; return 1;
@ -181,6 +188,10 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
switch(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: case A_TK_BORDER_COLOR:
if((buf = luaL_checklstring(L, 3, &len))) if((buf = luaL_checklstring(L, 3, &len)))
xcolor_init_reply(xcolor_init_unchecked(&d->border.color, buf, len)); xcolor_init_reply(xcolor_init_unchecked(&d->border.color, buf, len));