Make drawtext interface more general.
This commit is contained in:
parent
4723ab3627
commit
21fe1add9e
7
draw.c
7
draw.c
|
@ -52,7 +52,7 @@ draw_free_context(DrawCtx *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawtext(DrawCtx *ctx, int x, int y, int w, int h, XftFont *font, const char *text, XColor color[ColLast])
|
drawtext(DrawCtx *ctx, int x, int y, int w, int h, XftFont *font, const char *text, XColor fg, XColor bg)
|
||||||
{
|
{
|
||||||
int nw = 0;
|
int nw = 0;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
|
@ -61,7 +61,7 @@ drawtext(DrawCtx *ctx, int x, int y, int w, int h, XftFont *font, const char *te
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
drawrectangle(ctx, x, y, w, h, True, color[ColBG]);
|
drawrectangle(ctx, x, y, w, h, True, bg);
|
||||||
if(!a_strlen(text))
|
if(!a_strlen(text))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ drawtext(DrawCtx *ctx, int x, int y, int w, int h, XftFont *font, const char *te
|
||||||
font_face = cairo_ft_font_face_create_for_pattern(font->pattern);
|
font_face = cairo_ft_font_face_create_for_pattern(font->pattern);
|
||||||
cairo_set_font_face(cr, font_face);
|
cairo_set_font_face(cr, font_face);
|
||||||
cairo_set_font_size(cr, font->height);
|
cairo_set_font_size(cr, font->height);
|
||||||
cairo_set_source_rgb(cr, color[ColFG].red / 65535.0, color[ColFG].green / 65535.0, color[ColFG].blue / 65535.0);
|
cairo_set_source_rgb(cr, fg.red / 65535.0, fg.green / 65535.0, fg.blue / 65535.0);
|
||||||
|
|
||||||
olen = len = a_strlen(text);
|
olen = len = a_strlen(text);
|
||||||
if(len >= sizeof(buf))
|
if(len >= sizeof(buf))
|
||||||
|
@ -177,7 +177,6 @@ draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty)
|
||||||
return newdrawable;
|
return newdrawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned short
|
unsigned short
|
||||||
textwidth_primitive(Display *display, XftFont *font, char *text)
|
textwidth_primitive(Display *display, XftFont *font, char *text)
|
||||||
{
|
{
|
||||||
|
|
2
draw.h
2
draw.h
|
@ -38,7 +38,7 @@ struct DrawCtx
|
||||||
|
|
||||||
DrawCtx *draw_get_context(Display*, int, int, int);
|
DrawCtx *draw_get_context(Display*, int, int, int);
|
||||||
void draw_free_context(DrawCtx*);
|
void draw_free_context(DrawCtx*);
|
||||||
void drawtext(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor []);
|
void drawtext(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg, XColor bg);
|
||||||
void drawrectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
void drawrectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
||||||
void drawcircle(DrawCtx *, int, int, int, Bool, XColor);
|
void drawcircle(DrawCtx *, int, int, int, Bool, XColor);
|
||||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||||
|
|
|
@ -22,7 +22,8 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
{
|
{
|
||||||
drawtext(ctx, location, 0, vscreen.statusbar.width - used,
|
drawtext(ctx, location, 0, vscreen.statusbar.width - used,
|
||||||
vscreen.statusbar.height, vscreen.font, sel->name,
|
vscreen.statusbar.height, vscreen.font, sel->name,
|
||||||
vscreen.colors_selected);
|
vscreen.colors_selected[ColFG],
|
||||||
|
vscreen.colors_selected[ColBG]);
|
||||||
if(sel->isfloating)
|
if(sel->isfloating)
|
||||||
drawcircle(ctx, location, 0,
|
drawcircle(ctx, location, 0,
|
||||||
(vscreen.font->height + 2) / 4,
|
(vscreen.font->height + 2) / 4,
|
||||||
|
@ -32,7 +33,8 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
else
|
else
|
||||||
drawtext(ctx, location, 0, vscreen.statusbar.width - used,
|
drawtext(ctx, location, 0, vscreen.statusbar.width - used,
|
||||||
vscreen.statusbar.height, vscreen.font, NULL,
|
vscreen.statusbar.height, vscreen.font, NULL,
|
||||||
vscreen.colors_normal);
|
vscreen.colors_normal[ColFG],
|
||||||
|
vscreen.colors_normal[ColBG]);
|
||||||
return vscreen.statusbar.width - used;
|
return vscreen.statusbar.width - used;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ layoutinfo_draw(Widget *widget,
|
||||||
vscreen.statusbar.height,
|
vscreen.statusbar.height,
|
||||||
vscreen.font,
|
vscreen.font,
|
||||||
get_current_layout(widget->statusbar->screen)->symbol,
|
get_current_layout(widget->statusbar->screen)->symbol,
|
||||||
vscreen.colors_normal);
|
vscreen.colors_normal[ColFG],
|
||||||
|
vscreen.colors_normal[ColBG]);
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,11 @@ taglist_draw(Widget *widget,
|
||||||
else
|
else
|
||||||
colors = vscreen.colors_normal;
|
colors = vscreen.colors_normal;
|
||||||
drawtext(ctx, location + width, 0, w,
|
drawtext(ctx, location + width, 0, w,
|
||||||
vscreen.statusbar.height, vscreen.font, tag->name, colors);
|
vscreen.statusbar.height,
|
||||||
|
vscreen.font,
|
||||||
|
tag->name,
|
||||||
|
colors[ColFG],
|
||||||
|
colors[ColBG]);
|
||||||
if(isoccupied(widget->statusbar->screen, tag))
|
if(isoccupied(widget->statusbar->screen, tag))
|
||||||
drawrectangle(ctx, location + width, 0, flagsize, flagsize,
|
drawrectangle(ctx, location + width, 0, flagsize, flagsize,
|
||||||
sel && is_client_tagged(sel,
|
sel && is_client_tagged(sel,
|
||||||
|
|
|
@ -36,7 +36,9 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
offset,
|
offset,
|
||||||
widget->alignment);
|
widget->alignment);
|
||||||
drawtext(ctx, location, 0, width, vscreen.statusbar.height,
|
drawtext(ctx, location, 0, width, vscreen.statusbar.height,
|
||||||
vscreen.font, d->text, vscreen.colors_normal);
|
vscreen.font, d->text,
|
||||||
|
vscreen.colors_normal[ColFG],
|
||||||
|
vscreen.colors_normal[ColBG]);
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue