draw: stop using font as argument, use global
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
26da80f90a
commit
7f3e831221
12
draw.c
12
draw.c
|
@ -213,17 +213,16 @@ draw_context_init(draw_context_t *d, int phys_screen,
|
|||
|
||||
/** Draw text into a draw context.
|
||||
* \param ctx Draw context to draw to.
|
||||
* \param font The font to use.
|
||||
* \param data Draw text context data.
|
||||
* \param elip Ellipsize mode.
|
||||
* \param wrap Wrap mode.
|
||||
* \param align Text alignment.
|
||||
* \param margin Margin to respect when drawing text.
|
||||
* \param area Area to draw to.
|
||||
* \param data Draw text context data.
|
||||
* \param ext Text extents.
|
||||
*/
|
||||
void
|
||||
draw_text(draw_context_t *ctx, draw_text_context_t *data, font_t *font,
|
||||
draw_text(draw_context_t *ctx, draw_text_context_t *data,
|
||||
PangoEllipsizeMode ellip, PangoWrapMode wrap,
|
||||
alignment_t align, padding_t *margin, area_t area, area_t *ext)
|
||||
{
|
||||
|
@ -239,7 +238,7 @@ draw_text(draw_context_t *ctx, draw_text_context_t *data, font_t *font,
|
|||
pango_layout_set_ellipsize(ctx->layout, ellip);
|
||||
pango_layout_set_wrap(ctx->layout, wrap);
|
||||
pango_layout_set_attributes(ctx->layout, data->attr_list);
|
||||
pango_layout_set_font_description(ctx->layout, font->desc);
|
||||
pango_layout_set_font_description(ctx->layout, globalconf.font->desc);
|
||||
|
||||
x = area.x + margin->left;
|
||||
/* + 1 is added for rounding, so that in any case of doubt we rather draw
|
||||
|
@ -640,11 +639,10 @@ draw_rotate(draw_context_t *ctx,
|
|||
|
||||
/** Return the width and height of a text in pixel.
|
||||
* \param data The draw context text data.
|
||||
* \param font Font to use.
|
||||
* \return Text height and width.
|
||||
*/
|
||||
area_t
|
||||
draw_text_extents(draw_text_context_t *data, font_t *font)
|
||||
draw_text_extents(draw_text_context_t *data)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
@ -666,7 +664,7 @@ draw_text_extents(draw_text_context_t *data, font_t *font)
|
|||
layout = pango_cairo_create_layout(cr);
|
||||
pango_layout_set_text(layout, data->text, data->len);
|
||||
pango_layout_set_attributes(layout, data->attr_list);
|
||||
pango_layout_set_font_description(layout, font->desc);
|
||||
pango_layout_set_font_description(layout, globalconf.font->desc);
|
||||
pango_layout_get_pixel_extents(layout, NULL, &ext);
|
||||
g_object_unref(layout);
|
||||
cairo_destroy(cr);
|
||||
|
|
4
draw.h
4
draw.h
|
@ -172,7 +172,7 @@ typedef struct
|
|||
} draw_text_context_t;
|
||||
|
||||
bool draw_text_context_init(draw_text_context_t *, const char *, ssize_t);
|
||||
void draw_text(draw_context_t *, draw_text_context_t *, font_t *, PangoEllipsizeMode, PangoWrapMode, alignment_t, padding_t *, area_t, area_t *);
|
||||
void draw_text(draw_context_t *, draw_text_context_t *, PangoEllipsizeMode, PangoWrapMode, alignment_t, padding_t *, area_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 *);
|
||||
|
@ -184,7 +184,7 @@ void draw_graph_line(draw_context_t *, area_t, int *, int, position_t, vector_t,
|
|||
const xcolor_t *, const xcolor_t *, const xcolor_t *);
|
||||
void draw_image(draw_context_t *, int, int, double, image_t *);
|
||||
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
|
||||
area_t draw_text_extents(draw_text_context_t *, font_t *);
|
||||
area_t draw_text_extents(draw_text_context_t *);
|
||||
alignment_t draw_align_fromstr(const char *, ssize_t);
|
||||
const char *draw_align_tostr(alignment_t);
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
|
|||
}
|
||||
}
|
||||
|
||||
draw_text(ctx, &d->data, globalconf.font, d->ellip, d->wrap, d->align, &d->margin, geometry, &d->extents);
|
||||
draw_text(ctx, &d->data, d->ellip, d->wrap, d->align, &d->margin, geometry, &d->extents);
|
||||
}
|
||||
|
||||
/** Delete a textbox widget.
|
||||
|
@ -314,7 +314,7 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
|
|||
else
|
||||
draw_text_context_init(&d->data, buf, len);
|
||||
|
||||
d->extents = draw_text_extents(&d->data, globalconf.font);
|
||||
d->extents = draw_text_extents(&d->data);
|
||||
}
|
||||
else
|
||||
p_clear(&d->extents, 1);
|
||||
|
|
Loading…
Reference in New Issue