enable popups for left/right bars

This commit is contained in:
Felix Kratz 2022-10-07 22:13:49 +02:00
parent ac9f35edea
commit 7675f87222
2 changed files with 40 additions and 17 deletions

View file

@ -35,25 +35,47 @@ static inline void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, stru
if (bar->adid != g_bar_manager.active_adid) return;
struct window* window = bar_item_get_window(bar_item, bar->adid);
if (!bar_item->popup.overrides_cell_size)
bar_item->popup.cell_size = window->frame.size.height;
if (!bar_item->popup.overrides_cell_size) {
if (g_bar_manager.position == POSITION_LEFT
|| g_bar_manager.position == POSITION_RIGHT) {
bar_item->popup.cell_size = window->frame.size.width;
} else {
bar_item->popup.cell_size = window->frame.size.height;
}
}
popup_calculate_bounds(&bar_item->popup, bar);
CGPoint anchor = window->origin;
if (bar_item->popup.align == POSITION_CENTER) {
anchor.x += (window->frame.size.width
- bar_item->popup.background.bounds.size.width) / 2;
} else if (bar_item->popup.align == POSITION_LEFT) {
anchor.x -= bar_item->background.padding_left;
} else {
anchor.x += window->frame.size.width
- bar_item->popup.background.bounds.size.width;
}
anchor.y += (g_bar_manager.position == POSITION_BOTTOM
? (- bar_item->popup.background.bounds.size.height)
: window->frame.size.height);
if (g_bar_manager.position == POSITION_LEFT
|| g_bar_manager.position == POSITION_RIGHT) {
if (bar_item->popup.align == POSITION_CENTER) {
anchor.y += (window->frame.size.height
- bar_item->popup.background.bounds.size.height) / 2;
} else if (bar_item->popup.align == POSITION_LEFT) {
anchor.y -= bar_item->background.padding_left;
} else {
anchor.y += window->frame.size.height
- bar_item->popup.background.bounds.size.height;
}
anchor.x += (g_bar_manager.position == POSITION_RIGHT
? (- bar_item->popup.background.bounds.size.width)
: window->frame.size.width);
} else {
if (bar_item->popup.align == POSITION_CENTER) {
anchor.x += (window->frame.size.width
- bar_item->popup.background.bounds.size.width) / 2;
} else if (bar_item->popup.align == POSITION_LEFT) {
anchor.x -= bar_item->background.padding_left;
} else {
anchor.x += window->frame.size.width
- bar_item->popup.background.bounds.size.width;
}
anchor.y += (g_bar_manager.position == POSITION_BOTTOM
? (- bar_item->popup.background.bounds.size.height)
: window->frame.size.height);
}
popup_set_anchor(&bar_item->popup, anchor, bar->adid);
popup_calculate_bounds(&bar_item->popup, bar);
}
@ -388,9 +410,9 @@ static inline void bar_calculate_bounds_left_right(struct bar* bar) {
// bar->adid ),
// group_frame );
// }
//
// if (bar_item->popup.drawing)
// bar_calculate_popup_anchor_for_bar_item(bar, bar_item);
if (bar_item->popup.drawing)
bar_calculate_popup_anchor_for_bar_item(bar, bar_item);
if (bar_item->position == POSITION_RIGHT
|| bar_item->position == POSITION_CENTER_LEFT) {

View file

@ -103,6 +103,7 @@ void text_prepare_line(struct text* text) {
text->bounds.size.width = (uint32_t) (text->bounds.size.width + 1.5);
text->bounds.size.height = (uint32_t) (text->bounds.size.height + 1.5);
text->bounds.origin.x = (uint32_t) (text->bounds.origin.x + 0.5);
text->bounds.origin.y = (uint32_t) (text->bounds.origin.y + 0.5);
text->line.color = text->highlight ? text->highlight_color : text->color;
CFRelease(string);