mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-10 05:44:16 +00:00
fix some quirks with images (#428)
This commit is contained in:
parent
ec5d88d9f5
commit
e39c1c0e13
4 changed files with 17 additions and 14 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
15
src/popup.c
15
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));
|
||||
|
|
Loading…
Reference in a new issue