diff --git a/src/background.c b/src/background.c index 74a1cbb..70f1ff7 100644 --- a/src/background.c +++ b/src/background.c @@ -199,15 +199,16 @@ void background_draw(struct background* background, CGContextRef context) { &background->shadow.color); } - if (background->image.enabled) - image_draw(&background->image, context); - draw_rect(context, background_bounds, &background->color, background->corner_radius, background->border_width, &background->border_color); + + if (background->image.enabled) + image_draw(&background->image, context); + } void background_clear_pointers(struct background* background) { diff --git a/src/bar_item.c b/src/bar_item.c index 4486ed0..e10da4e 100644 --- a/src/bar_item.c +++ b/src/bar_item.c @@ -495,16 +495,14 @@ uint32_t bar_item_get_height(struct bar_item* bar_item) { uint32_t background_height = 0; if (bar_item->background.enabled) { uint32_t image_height = bar_item->background.image.enabled - ? bar_item->background.image.bounds.size.height + ? image_get_size(&bar_item->background.image).height : 0; background_height = max(image_height, bar_item->background.bounds.size.height); } - uint32_t height = max(item_height, background_height); - - return height; + return max(item_height, background_height); } struct window* bar_item_get_window(struct bar_item* bar_item, uint32_t adid) { diff --git a/src/image.c b/src/image.c index 51d3270..73cff39 100644 --- a/src/image.c +++ b/src/image.c @@ -207,7 +207,8 @@ CGSize image_get_size(struct image* image) { + image->padding_right + (image->shadow.enabled ? image->shadow.offset.x : 0), - .height = image->bounds.size.height }; + .height = image->bounds.size.height + + 2*abs(image->y_offset) }; } void image_calculate_bounds(struct image* image, uint32_t x, uint32_t y) { diff --git a/src/popup.c b/src/popup.c index 235cdcd..da08489 100644 --- a/src/popup.c +++ b/src/popup.c @@ -117,8 +117,8 @@ void popup_calculate_bounds(struct popup* popup, struct bar* bar) { if (popup->background.enabled && popup->background.image.enabled) { - width = popup->background.image.bounds.size.width - + 2*popup->background.border_width; + uint32_t image_width = image_get_size(&popup->background.image).width; + width = image_width + 2*popup->background.border_width; } if (popup->horizontal) { @@ -138,8 +138,8 @@ void popup_calculate_bounds(struct popup* popup, struct bar* bar) { if (popup->background.enabled && popup->background.image.enabled) { - if (popup->background.image.bounds.size.height > height) - height = popup->background.image.bounds.size.height; + uint32_t image_height = image_get_size(&popup->background.image).height; + if (image_height > height) height = image_height; x = (width - total_item_width) / 2; } @@ -220,8 +220,11 @@ void popup_calculate_bounds(struct popup* popup, struct bar* bar) { popup->background.bounds.size.width = width; popup->background.bounds.size.height = y; - popup->background.image.bounds.origin.x = popup->background.border_width; - popup->background.image.bounds.origin.y = popup->background.border_width; + + image_calculate_bounds(&popup->background.image, + popup->background.border_width, + popup->background.border_width + + popup->background.image.bounds.size.height / 2); if (popup->adid > 0) window_set_frame(&popup->window, popup_get_frame(popup));