diff options
| author | Federico Angelilli <code@fedang.net> | 2023-11-26 20:18:08 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2023-11-26 20:18:08 +0100 |
| commit | 00bd74159e2f7d209a10d11e8cbecb894c3d0ef0 (patch) | |
| tree | 01ea73f9635c282ec8b0fcb4c5e775448dda9502 /src/draw.c | |
| parent | f9ec9bb88ae2b1423d30da21c76a7e131cb383cc (diff) | |
Generalize button struct
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -90,7 +90,7 @@ void draw_paint(Drawable *draw, Window *win) int text_x = layout->x + (layout->width / 2) - (layout->text_w / 2); int text_y = layout->y + (layout->height / 2) - (layout->text_h / 2); - Color color = layout->btn->background; + Color color = layout->btn->color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); cairo_new_sub_path(cr); cairo_arc(cr, layout->x + radius, layout->y + radius, radius, 90 * degree, 270 * degree); @@ -98,7 +98,7 @@ void draw_paint(Drawable *draw, Window *win) cairo_close_path(cr); cairo_fill(cr); - color = layout->btn->stroke; + color = layout->btn->line_color; cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); cairo_new_sub_path(cr); cairo_arc(cr, layout->x + radius, layout->y + radius, radius - line_w , 90 * degree, 270 * degree); @@ -106,12 +106,14 @@ void draw_paint(Drawable *draw, Window *win) cairo_close_path(cr); cairo_stroke(cr); - color = layout->btn->foreground; - cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); - cairo_move_to(cr, text_x, text_y); + if (layout->btn->simple) { + color = ((ButtonSimple *)layout->btn)->text_color; + cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a); + cairo_move_to(cr, text_x, text_y); - pango_cairo_update_layout(cr, layout->pl); - pango_cairo_show_layout(cr, layout->pl); + pango_cairo_update_layout(cr, layout->pl); + pango_cairo_show_layout(cr, layout->pl); + } } cairo_destroy(cr); @@ -169,9 +171,12 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) layout->x = x; layout->y = 0; + //FIXME + const char *text = btn->simple ? ((ButtonSimple *)btn)->text : "x"; + layout->pl = pango_cairo_create_layout(window_get_context(win)); pango_layout_set_font_description(layout->pl, draw->desc); - pango_layout_set_text(layout->pl, btn->text, -1); + pango_layout_set_text(layout->pl, text, -1); pango_layout_set_alignment(layout->pl, PANGO_ALIGN_CENTER); int text_w, text_h; @@ -181,7 +186,7 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) layout->text_h = ceil(text_h / scale); // If there is only one glyph the button should be round - size_t text_l = g_utf8_strlen(btn->text, -1); + size_t text_l = g_utf8_strlen(text, -1); layout->width = text_l == 1 ? height : layout->text_w + 2 * radius; layout->height = height; |
