From 1ca51e31e39c812e3967738a820c6617836ab84e Mon Sep 17 00:00:00 2001 From: FelixKratz Date: Sun, 5 Sep 2021 12:44:43 +0200 Subject: [PATCH] background colors working, but more precision needed --- src/bar.c | 4 ++-- src/bar_item.c | 1 + src/bar_item.h | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bar.c b/src/bar.c index 753ee16..629303e 100644 --- a/src/bar.c +++ b/src/bar.c @@ -183,7 +183,7 @@ void bar_draw_background(struct bar* bar) { void bar_draw_item_background(struct bar* bar, struct bar_item* bar_item, uint32_t sid) { CGRect draw_region = {{bar_item->bounding_rects[sid - 1]->origin.x, bar->frame.origin.y}, {bar_item->bounding_rects[sid - 1]->size.width, bar->frame.size.height}}; CGContextClearRect(bar->context, draw_region); - CGContextSetRGBFillColor(bar->context, bar_item->icon_color.r, bar_item->icon_color.g, bar_item->icon_color.b, bar_item->icon_color.a); + CGContextSetRGBFillColor(bar->context, bar_item->background_color.r, bar_item->background_color.g, bar_item->background_color.b, bar_item->background_color.a); CGMutablePathRef path = CGPathCreateMutable(); CGPathAddRect(path, NULL, draw_region); @@ -261,7 +261,7 @@ void bar_refresh(struct bar* bar) { bar_item_set_bounding_rect_for_space(bar_item, sid, bar->origin); // Actual drawing - //bar_draw_item_background(bar, bar_item, sid); + bar_draw_item_background(bar, bar_item, sid); bar_draw_line(bar, *icon, icon_position.x, icon_position.y); bar_draw_line(bar, *label, label_position.x, label_position.y); bar_draw_graph(bar, bar_item, graph_x, graph_rtl); diff --git a/src/bar_item.c b/src/bar_item.c index db0e063..d29f5bb 100644 --- a/src/bar_item.c +++ b/src/bar_item.c @@ -40,6 +40,7 @@ void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) { bar_item->label_highlight_color = rgba_color_from_hex(0xffffffff); bar_item->has_graph = false; bar_item->num_rects = 0; + bar_item->background_color = rgba_color_from_hex(0x44ff0000); bar_item->bounding_rects = NULL; if (default_item) { diff --git a/src/bar_item.h b/src/bar_item.h index 7b8b42d..03969eb 100644 --- a/src/bar_item.h +++ b/src/bar_item.h @@ -37,6 +37,9 @@ struct bar_item { // The position in the bar: l,r,c char position; + // Background + struct rgba_color background_color; + // Icon properties bool icon_highlight; struct bar_line icon_line;