mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-23 03:43:02 +00:00
clean up background bounds calculation
This commit is contained in:
parent
f3d51570f2
commit
2d2ccfcc96
5 changed files with 25 additions and 19 deletions
|
@ -95,9 +95,11 @@ static bool background_set_yoffset(struct background* background, int offset) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y) {
|
||||
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
background->bounds.origin.x = x;
|
||||
background->bounds.origin.y = y - background->bounds.size.height / 2;
|
||||
background->bounds.size.width = width;
|
||||
background->bounds.size.height = height;
|
||||
|
||||
if (background->image.enabled)
|
||||
image_calculate_bounds(&background->image, x, y);
|
||||
|
|
|
@ -20,7 +20,7 @@ struct background {
|
|||
};
|
||||
|
||||
void background_init(struct background* background);
|
||||
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y);
|
||||
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
||||
|
||||
bool background_set_height(struct background* background, uint32_t height);
|
||||
|
||||
|
|
|
@ -593,15 +593,16 @@ uint32_t bar_item_calculate_bounds(struct bar_item* bar_item, uint32_t bar_heigh
|
|||
}
|
||||
|
||||
if (bar_item->background.enabled) {
|
||||
bar_item->background.bounds.size.height = bar_item->background.overrides_height
|
||||
uint32_t height = bar_item->background.overrides_height
|
||||
? bar_item->background.bounds.size.height
|
||||
: (bar_height
|
||||
- (g_bar_manager.background.border_width + 1));
|
||||
|
||||
bar_item->background.bounds.size.width = bar_item_length;
|
||||
background_calculate_bounds(&bar_item->background,
|
||||
x,
|
||||
content_y + bar_item->y_offset );
|
||||
content_y + bar_item->y_offset,
|
||||
bar_item_length,
|
||||
height );
|
||||
}
|
||||
|
||||
return bar_item_length;
|
||||
|
|
11
src/group.c
11
src/group.c
|
@ -96,12 +96,11 @@ void group_destroy(struct group* group) {
|
|||
}
|
||||
|
||||
void group_calculate_bounds(struct group* group, struct bar* bar, uint32_t x, uint32_t y, bool rtl) {
|
||||
background_calculate_bounds(&group->members[0]->background, x, y);
|
||||
group->members[0]->background.bounds.size.width = group_get_length(group, bar);
|
||||
group->members[0]->background.bounds.origin.x = x;
|
||||
group->members[0]->background.bounds.origin.y = y
|
||||
- group->members[0]->background.bounds.size.height / 2
|
||||
+ group->members[0]->y_offset;
|
||||
background_calculate_bounds(&group->members[0]->background,
|
||||
x,
|
||||
y + group->members[0]->y_offset,
|
||||
group_get_length(group, bar),
|
||||
group->members[0]->background.bounds.size.height);
|
||||
}
|
||||
|
||||
void group_draw(struct group* group, CGContextRef context) {
|
||||
|
|
10
src/text.c
10
src/text.c
|
@ -253,11 +253,15 @@ void text_calculate_bounds(struct text* text, uint32_t x, uint32_t y) {
|
|||
- text->line.descent) / 2));
|
||||
|
||||
if (text->background.enabled) {
|
||||
text->background.bounds.size.width = text_get_length(text, false);
|
||||
text->background.bounds.size.height = text->background.overrides_height
|
||||
uint32_t height = text->background.overrides_height
|
||||
? text->background.bounds.size.height
|
||||
: text->bounds.size.height;
|
||||
background_calculate_bounds(&text->background, x, y);
|
||||
|
||||
background_calculate_bounds(&text->background,
|
||||
x,
|
||||
y,
|
||||
text_get_length(text, false),
|
||||
height );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue