From f8b372787562aecb2a4a55b336c196f47b5c1b0c Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Sun, 11 Feb 2024 00:21:05 +0100 Subject: Use updated text in draw There is a caveat: The text should always have the same size and layout as the original one for which the pango layout was calculated --- src/draw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/draw.c') diff --git a/src/draw.c b/src/draw.c index fa59b0e..131b944 100644 --- a/src/draw.c +++ b/src/draw.c @@ -104,6 +104,8 @@ void draw_paint(Drawable *draw, Window *win) cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); cairo_move_to(cr, text_x, text_y); + // NOTE: This works only if the text didn't change in size after the layouting + pango_layout_set_text(layout->pl, CAST(layout->btn, ButtonSimple)->text, -1); pango_cairo_update_layout(cr, layout->pl); pango_cairo_show_layout(cr, layout->pl); } @@ -213,7 +215,7 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) child->btn = btn; child->x = x + btn->padding; - child->y = btn->padding;; + child->y = btn->padding; child->pl = pango_cairo_create_layout(window_get_context(win)); layout_text(child, draw->desc, scale, height, radius); -- cgit v1.2.3