mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-12-04 17:19:11 +00:00
enable popups for left/right bars
This commit is contained in:
parent
ac9f35edea
commit
7675f87222
2 changed files with 40 additions and 17 deletions
32
src/bar.c
32
src/bar.c
|
@ -35,12 +35,34 @@ static inline void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, stru
|
||||||
if (bar->adid != g_bar_manager.active_adid) return;
|
if (bar->adid != g_bar_manager.active_adid) return;
|
||||||
struct window* window = bar_item_get_window(bar_item, bar->adid);
|
struct window* window = bar_item_get_window(bar_item, bar->adid);
|
||||||
|
|
||||||
if (!bar_item->popup.overrides_cell_size)
|
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;
|
bar_item->popup.cell_size = window->frame.size.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
popup_calculate_bounds(&bar_item->popup, bar);
|
popup_calculate_bounds(&bar_item->popup, bar);
|
||||||
|
|
||||||
CGPoint anchor = window->origin;
|
CGPoint anchor = window->origin;
|
||||||
|
|
||||||
|
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) {
|
if (bar_item->popup.align == POSITION_CENTER) {
|
||||||
anchor.x += (window->frame.size.width
|
anchor.x += (window->frame.size.width
|
||||||
- bar_item->popup.background.bounds.size.width) / 2;
|
- bar_item->popup.background.bounds.size.width) / 2;
|
||||||
|
@ -53,7 +75,7 @@ static inline void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, stru
|
||||||
anchor.y += (g_bar_manager.position == POSITION_BOTTOM
|
anchor.y += (g_bar_manager.position == POSITION_BOTTOM
|
||||||
? (- bar_item->popup.background.bounds.size.height)
|
? (- bar_item->popup.background.bounds.size.height)
|
||||||
: window->frame.size.height);
|
: window->frame.size.height);
|
||||||
|
}
|
||||||
popup_set_anchor(&bar_item->popup, anchor, bar->adid);
|
popup_set_anchor(&bar_item->popup, anchor, bar->adid);
|
||||||
popup_calculate_bounds(&bar_item->popup, bar);
|
popup_calculate_bounds(&bar_item->popup, bar);
|
||||||
}
|
}
|
||||||
|
@ -388,9 +410,9 @@ static inline void bar_calculate_bounds_left_right(struct bar* bar) {
|
||||||
// bar->adid ),
|
// bar->adid ),
|
||||||
// group_frame );
|
// group_frame );
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// if (bar_item->popup.drawing)
|
if (bar_item->popup.drawing)
|
||||||
// bar_calculate_popup_anchor_for_bar_item(bar, bar_item);
|
bar_calculate_popup_anchor_for_bar_item(bar, bar_item);
|
||||||
|
|
||||||
if (bar_item->position == POSITION_RIGHT
|
if (bar_item->position == POSITION_RIGHT
|
||||||
|| bar_item->position == POSITION_CENTER_LEFT) {
|
|| bar_item->position == POSITION_CENTER_LEFT) {
|
||||||
|
|
|
@ -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.width = (uint32_t) (text->bounds.size.width + 1.5);
|
||||||
text->bounds.size.height = (uint32_t) (text->bounds.size.height + 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.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;
|
text->line.color = text->highlight ? text->highlight_color : text->color;
|
||||||
|
|
||||||
CFRelease(string);
|
CFRelease(string);
|
||||||
|
|
Loading…
Reference in a new issue