popup: refine the input panel
This commit is contained in:
21
font.c
21
font.c
@@ -117,12 +117,13 @@ textwidth(Str *s)
|
||||
}
|
||||
|
||||
static void
|
||||
drawtext(u32int *buf, int w, int h, int x, int y, int fit, Str *s)
|
||||
drawtext(u32int *buf, int w, int h, int x, int y, int fit, u32int color,
|
||||
Str *s)
|
||||
{
|
||||
PangoRectangle r;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
int stride;
|
||||
int b, g, red, stride;
|
||||
|
||||
if(layout == nil)
|
||||
return;
|
||||
@@ -156,7 +157,10 @@ drawtext(u32int *buf, int w, int h, int x, int y, int fit, Str *s)
|
||||
cairo_rectangle(cr, 0, y, w, Fontsz);
|
||||
cairo_clip(cr);
|
||||
cairo_move_to(cr, x - r.x, y + (Fontsz - r.height) / 2 - r.y);
|
||||
cairo_set_source_rgb(cr, 0, 0, 0);
|
||||
red = color >> 16 & 0xff;
|
||||
g = color >> 8 & 0xff;
|
||||
b = color & 0xff;
|
||||
cairo_set_source_rgb(cr, red / 255.0, g / 255.0, b / 255.0);
|
||||
pango_cairo_show_layout(cr, layout);
|
||||
}
|
||||
cairo_destroy(cr);
|
||||
@@ -167,11 +171,18 @@ drawtext(u32int *buf, int w, int h, int x, int y, int fit, Str *s)
|
||||
void
|
||||
textdraw(u32int *buf, int w, int h, int x, int y, Str *s)
|
||||
{
|
||||
drawtext(buf, w, h, x, y, -1, s);
|
||||
drawtext(buf, w, h, x, y, -1, Colfg, s);
|
||||
}
|
||||
|
||||
void
|
||||
textdrawfit(u32int *buf, int w, int h, int x, int y, int fit, Str *s)
|
||||
{
|
||||
drawtext(buf, w, h, x, y, fit, s);
|
||||
drawtext(buf, w, h, x, y, fit, Colfg, s);
|
||||
}
|
||||
|
||||
void
|
||||
textdrawfitcolor(u32int *buf, int w, int h, int x, int y, int fit,
|
||||
u32int color, Str *s)
|
||||
{
|
||||
drawtext(buf, w, h, x, y, fit, color, s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user