[draw] Make text_align part of markup format
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
09e166ca1e
commit
5c51759cca
|
@ -431,7 +431,7 @@ redraw(void)
|
|||
|
||||
if(a_strlen(globalconf.prompt))
|
||||
{
|
||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||
draw_text(globalconf.ctx, geometry,
|
||||
MARGIN, globalconf.prompt, globalconf.styles.focus);
|
||||
|
||||
len = MARGIN * 2 + draw_text_extents(globalconf.connection, globalconf.default_screen,
|
||||
|
@ -440,7 +440,7 @@ redraw(void)
|
|||
geometry.width -= len;
|
||||
}
|
||||
|
||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||
draw_text(globalconf.ctx, geometry,
|
||||
MARGIN, globalconf.text, globalconf.styles.normal);
|
||||
|
||||
len = MARGIN * 2 + MAX(draw_text_extents(globalconf.connection, globalconf.default_screen,
|
||||
|
@ -463,8 +463,7 @@ redraw(void)
|
|||
else
|
||||
selected_item_is_drawn = true;
|
||||
}
|
||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||
MARGIN / 2, item->data, style);
|
||||
draw_text(globalconf.ctx, geometry, MARGIN / 2, item->data, style);
|
||||
geometry.x += len;
|
||||
geometry.width -= len;
|
||||
}
|
||||
|
@ -486,8 +485,7 @@ redraw(void)
|
|||
if(geometry.x < prompt_len)
|
||||
break;
|
||||
|
||||
draw_text(globalconf.ctx, geometry, AlignLeft,
|
||||
MARGIN / 2, item->data, style);
|
||||
draw_text(globalconf.ctx, geometry, MARGIN / 2, item->data, style);
|
||||
}
|
||||
|
||||
if(item)
|
||||
|
|
|
@ -211,7 +211,7 @@ main(int argc, char **argv)
|
|||
geometry.width, geometry.height, sw->drawable);
|
||||
|
||||
geometry.x = geometry.y = 0;
|
||||
draw_text(ctx, geometry, AlignRight, 0,argv[optind], globalconf.style);
|
||||
draw_text(ctx, geometry, 0, argv[optind], globalconf.style);
|
||||
|
||||
if(icon_geometry.width > 0 && icon_geometry.height > 0)
|
||||
draw_image(ctx, 0, (geometry.height / 2) - (globalconf.style.font->height / 2),
|
||||
|
|
|
@ -194,8 +194,6 @@ cfg_opt_t titlebar_opts[] =
|
|||
CFG_INT((char *) "width", 0, CFGF_NONE),
|
||||
/** Titlebar height. Set to 0 for auto. */
|
||||
CFG_INT((char *) "height", 0, CFGF_NONE),
|
||||
/** Text alignment. */
|
||||
CFG_ALIGNMENT((char *) "text_align", (char *) "center", CFGF_NONE),
|
||||
/** Titlebar markup string for normal windows. */
|
||||
CFG_STR((char *) "text_normal", (char *) "<bg color=\"#444444\"/><title/>", CFGF_NONE),
|
||||
/** Titlebar markup string for focused windows. */
|
||||
|
@ -315,8 +313,6 @@ cfg_opt_t widget_textbox_opts[] =
|
|||
CFG_INT((char *) "width", 0, CFGF_NONE),
|
||||
/** Default printed text. */
|
||||
CFG_STR((char *) "text", NULL, CFGF_NONE),
|
||||
/** Text alignment. */
|
||||
CFG_ALIGNMENT((char *) "text_align", (char *) "center", CFGF_NONE),
|
||||
CFG_AWESOME_END()
|
||||
};
|
||||
/** This section defines tasklist widget options */
|
||||
|
@ -334,8 +330,6 @@ cfg_opt_t widget_tasklist_opts[] =
|
|||
CFG_STR((char *) "text_focus", (char *) "<bg color=\"#535d6c\"/><title/>", CFGF_NONE),
|
||||
/** Markup title string for urgent windows. */
|
||||
CFG_STR((char *) "text_urgent", (char *) "<bg color=\"#ff4500\"/><title/>", CFGF_NONE),
|
||||
/** Text alignment. */
|
||||
CFG_ALIGNMENT((char *) "text_align", (char *) "left", CFGF_NONE),
|
||||
/** Which windows to show: tags, all or focus. */
|
||||
CFG_STR((char *) "show", (char *) "tags", CFGF_NONE),
|
||||
/** Show icons of windows. */
|
||||
|
|
|
@ -220,6 +220,7 @@ typedef struct
|
|||
xcb_connection_t *connection;
|
||||
int phys_screen;
|
||||
char *text;
|
||||
alignment_t align;
|
||||
bool has_bg_color;
|
||||
xcolor_t bg_color;
|
||||
} draw_parser_data_t;
|
||||
|
@ -228,7 +229,7 @@ static bool
|
|||
draw_text_markup_expand(draw_parser_data_t *data,
|
||||
const char *str, ssize_t slen)
|
||||
{
|
||||
const char *elements[] = { "bg", NULL };
|
||||
const char *elements[] = { "bg", "text", NULL };
|
||||
markup_parser_data_t *p;
|
||||
int i;
|
||||
|
||||
|
@ -244,6 +245,12 @@ draw_text_markup_expand(draw_parser_data_t *data,
|
|||
data->has_bg_color = draw_color_new(data->connection, data->phys_screen,
|
||||
p->attribute_values[0][i], &data->bg_color);
|
||||
|
||||
/* text */
|
||||
if(p->attribute_names[1])
|
||||
for(i = 0; p->attribute_names[1][i]; i++)
|
||||
if(!a_strcmp(p->attribute_names[1][i], "align"))
|
||||
data->align = draw_align_get_from_str(p->attribute_values[1][i]);
|
||||
|
||||
/* stole text */
|
||||
data->text = p->text;
|
||||
p->text = NULL;
|
||||
|
@ -256,7 +263,6 @@ draw_text_markup_expand(draw_parser_data_t *data,
|
|||
/** Draw text into a draw context
|
||||
* \param ctx DrawCtx to draw to
|
||||
* \param area area to draw to
|
||||
* \param align alignment
|
||||
* \param padding padding to add before drawing the text
|
||||
* \param text text to draw
|
||||
* \return area_t with width and height are set to what used
|
||||
|
@ -264,7 +270,6 @@ draw_text_markup_expand(draw_parser_data_t *data,
|
|||
void
|
||||
draw_text(DrawCtx *ctx,
|
||||
area_t area,
|
||||
alignment_t align,
|
||||
int padding,
|
||||
const char *text,
|
||||
style_t style)
|
||||
|
@ -318,7 +323,7 @@ draw_text(DrawCtx *ctx,
|
|||
* face */
|
||||
y = area.y + (ctx->height - style.font->height + 1) / 2;
|
||||
|
||||
switch(align)
|
||||
switch(parser_data.align)
|
||||
{
|
||||
case AlignCenter:
|
||||
x += (area.width - ext.width) / 2;
|
||||
|
|
|
@ -125,7 +125,7 @@ void draw_context_delete(DrawCtx **);
|
|||
font_t *draw_font_new(xcb_connection_t *, int, char *);
|
||||
void draw_font_delete(font_t **);
|
||||
|
||||
void draw_text(DrawCtx *, area_t, alignment_t, int, const char *, style_t);
|
||||
void draw_text(DrawCtx *, area_t, int, const char *, style_t);
|
||||
void draw_rectangle(DrawCtx *, area_t, float, bool, xcolor_t);
|
||||
void draw_rectangle_gradient(DrawCtx *, area_t, float, bool, area_t, xcolor_t *, xcolor_t *, xcolor_t *);
|
||||
|
||||
|
|
1
config.c
1
config.c
|
@ -285,7 +285,6 @@ config_section_titlebar_init(cfg_t *cfg_titlebar, titlebar_t *tb)
|
|||
{
|
||||
tb->position = tb->dposition = cfg_getposition(cfg_titlebar, "position");
|
||||
tb->align = cfg_getalignment(cfg_titlebar, "align");
|
||||
tb->text_align = cfg_getalignment(cfg_titlebar, "text_align");
|
||||
tb->width = cfg_getint(cfg_titlebar, "width");
|
||||
tb->height = cfg_getint(cfg_titlebar, "height");
|
||||
tb->text_normal = a_strdup(cfg_getstr(cfg_titlebar, "text_normal"));
|
||||
|
|
6
mouse.c
6
mouse.c
|
@ -141,11 +141,11 @@ static void
|
|||
mouse_resizebar_draw(DrawCtx *ctx, style_t style, simple_window_t *sw, area_t geometry, int border)
|
||||
{
|
||||
area_t draw_geometry = { 0, 0, ctx->width, ctx->height, NULL, NULL };
|
||||
char size[32];
|
||||
char size[64];
|
||||
|
||||
snprintf(size, sizeof(size), "%dx%d+%d+%d",
|
||||
snprintf(size, sizeof(size), "<text align=\"center\"/>%dx%d+%d+%d",
|
||||
geometry.x, geometry.y, geometry.width, geometry.height);
|
||||
draw_text(ctx, draw_geometry, AlignCenter, style.font->height / 2, size, style);
|
||||
draw_text(ctx, draw_geometry, style.font->height / 2, size, style);
|
||||
simplewindow_move(sw,
|
||||
geometry.x + ((2 * border + geometry.width) - sw->geometry.width) / 2,
|
||||
geometry.y + ((2 * border + geometry.height) - sw->geometry.height) / 2);
|
||||
|
|
|
@ -51,7 +51,6 @@ typedef struct
|
|||
position_t position;
|
||||
position_t dposition;
|
||||
alignment_t align;
|
||||
alignment_t text_align;
|
||||
int width, height;
|
||||
char *text_normal, *text_focus, *text_urgent;
|
||||
} titlebar_t;
|
||||
|
|
|
@ -216,7 +216,7 @@ titlebar_draw(client_t *c)
|
|||
|
||||
text = titlebar_text(c);
|
||||
geometry.x = geometry.y = 0;
|
||||
draw_text(ctx, geometry, c->titlebar.text_align, 0,
|
||||
draw_text(ctx, geometry, 0,
|
||||
text, globalconf.screens[c->screen].styles.normal);
|
||||
p_delete(&text);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ taglist_draw(widget_t *widget,
|
|||
area.y = widget->area.y;
|
||||
area.width = w;
|
||||
area.height = widget->statusbar->height;
|
||||
draw_text(ctx, area, AlignCenter, 0, tag->name, style);
|
||||
draw_text(ctx, area, 0, tag->name, style);
|
||||
|
||||
if(isoccupied(tag))
|
||||
{
|
||||
|
|
|
@ -43,7 +43,6 @@ typedef struct
|
|||
{
|
||||
Showclient_t show;
|
||||
bool show_icons;
|
||||
alignment_t align;
|
||||
char *text_normal, *text_urgent, *text_focus;
|
||||
} Data;
|
||||
|
||||
|
@ -170,9 +169,7 @@ tasklist_draw(widget_t *widget, DrawCtx *ctx, int offset, int used)
|
|||
if(i == n - 1)
|
||||
area.width += box_width_rest;
|
||||
|
||||
draw_text(ctx, area, d->align,
|
||||
style.font->height / 2, text,
|
||||
style);
|
||||
draw_text(ctx, area, style.font->height / 2, text, style);
|
||||
|
||||
p_delete(&text);
|
||||
|
||||
|
@ -283,7 +280,6 @@ tasklist_new(statusbar_t *statusbar, cfg_t *config)
|
|||
d->text_normal = a_strdup(cfg_getstr(config, "text_normal"));
|
||||
d->text_focus = a_strdup(cfg_getstr(config, "text_focus"));
|
||||
d->text_urgent = a_strdup(cfg_getstr(config, "text_urgent"));
|
||||
d->align = cfg_getalignment(config, "text_align");
|
||||
d->show_icons = cfg_getbool(config, "show_icons");
|
||||
|
||||
buf = cfg_getstr(config, "show");
|
||||
|
|
|
@ -30,7 +30,6 @@ typedef struct
|
|||
{
|
||||
char *text;
|
||||
int width;
|
||||
alignment_t align;
|
||||
} Data;
|
||||
|
||||
static int
|
||||
|
@ -57,7 +56,7 @@ textbox_draw(widget_t *widget, DrawCtx *ctx, int offset, int used)
|
|||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
draw_text(ctx, widget->area, d->align, 0, d->text, globalconf.screens[widget->statusbar->screen].styles.normal);
|
||||
draw_text(ctx, widget->area, 0, d->text, globalconf.screens[widget->statusbar->screen].styles.normal);
|
||||
|
||||
return widget->area.width;
|
||||
}
|
||||
|
@ -75,8 +74,6 @@ textbox_tell(widget_t *widget, char *property, char *new_value)
|
|||
}
|
||||
else if(!a_strcmp(property, "width"))
|
||||
d->width = atoi(new_value);
|
||||
else if(!a_strcmp(property, "text_align"))
|
||||
d->align = draw_align_get_from_str(new_value);
|
||||
else
|
||||
return WIDGET_ERROR;
|
||||
|
||||
|
@ -98,7 +95,6 @@ textbox_new(statusbar_t *statusbar, cfg_t *config)
|
|||
w->data = d = p_new(Data, 1);
|
||||
|
||||
d->width = cfg_getint(config, "width");
|
||||
d->align = cfg_getalignment(config, "text_align");
|
||||
|
||||
d->text = a_strdup(cfg_getstr(config, "text"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue