diff options
| author | Federico Angelilli <code@fedang.net> | 2023-11-19 14:28:18 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2023-11-19 14:28:18 +0100 |
| commit | 89b205f3138b94325458ab121d5adb4a00091860 (patch) | |
| tree | b536773d235ec6ce8be37b2cce781c70441aa523 /src/draw.c | |
| parent | e774c39c76379738e383e23938f3762b1a57e3b2 (diff) | |
Add custom bar color
Diffstat (limited to 'src/draw.c')
| -rw-r--r-- | src/draw.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -18,7 +18,7 @@ static void layout_destroy(Layout *layout) g_free(layout); } -Drawable *draw_create(const char *font, int height, int left_pad, int right_pad, int top_pad, double alpha, int line_w) +Drawable *draw_create(const char *font, int height, int left_pad, int right_pad, int top_pad, int line_w) { Drawable *draw = g_malloc(sizeof(Drawable)); g_assert_nonnull(draw); @@ -31,13 +31,11 @@ Drawable *draw_create(const char *font, int height, int left_pad, int right_pad, draw->left_pad = left_pad; draw->right_pad = right_pad; draw->top_pad = top_pad; - draw->alpha = alpha; - g_assert(alpha >= 0 && alpha <= 1); draw->line_w = line_w; draw->layouts = NULL; - log_debug("Draw context created [height=%d, left_pad=%d, right_pad=%d, top_pad=%d, alpha=%.2lf]", height, left_pad, right_pad, top_pad, alpha); + log_debug("Draw context created [height=%d, left_pad=%d, right_pad=%d, top_pad=%d, line_w=%d]", height, left_pad, right_pad, top_pad, line_w); return draw; } @@ -73,7 +71,7 @@ void draw_paint(Drawable *draw, Window *win) int radius = height / 2; double degree = M_PI / 180.0; - cairo_set_source_rgba(cr, 0.3, 0.3, 0.3, draw->alpha); + cairo_set_source_rgba(cr, draw->background.r, draw->background.g, draw->background.b, draw->background.a); // TODO: Here we should paint the shape of the bar, however there is a problem with the surface // painted in the pixmap to mask the window shape in window_paint_corners. @@ -252,6 +250,11 @@ void draw_compute_layout(Drawable *draw, Window *win, GList *btns) g_list_free(btns); } +void draw_set_background(Drawable *draw, Color background) +{ + draw->background = background; +} + void draw_destroy(Drawable *draw) { g_list_free_full(draw->layouts, (GDestroyNotify)layout_destroy); |
