keep right popup menus always on screen

This commit is contained in:
Felix Kratz 2021-12-19 18:00:41 +01:00
parent 98756c9d5c
commit b3146aecf4
2 changed files with 11 additions and 8 deletions

View file

@ -89,9 +89,14 @@ void bar_redraw(struct bar* bar) {
CGPoint anchor = bar->origin;
anchor.x += bar_item->icon.bounds.origin.x - bar_item->background.padding_left;
anchor.y += bar_item->icon.bounds.origin.y + bar->frame.size.height / 2;
popup_set_anchor(&bar_item->popup, anchor, bar->adid);
bar_item->popup.cell_size = bar->frame.size.height;
popup_calculate_bounds(&bar_item->popup);
if (anchor.x + bar_item->popup.background.bounds.size.width > bar->frame.size.width) {
anchor.x = bar->frame.size.width - bar_item->popup.background.bounds.size.width;
popup_calculate_bounds(&bar_item->popup);
}
popup_set_anchor(&bar_item->popup, anchor, bar->adid);
popup_calculate_bounds(&bar_item->popup);
if (bar_item->position == POSITION_RIGHT || bar_item->position == POSITION_CENTER_LEFT) {
*next_position += bar_item->has_const_width ? bar_item_display_length

View file

@ -104,14 +104,12 @@ void popup_add_item(struct popup* popup, struct bar_item* bar_item) {
}
void popup_set_anchor(struct popup* popup, CGPoint anchor, uint32_t adid) {
popup->anchor = anchor;
popup->anchor.y += popup->y_offset;
popup->adid = adid;
if (popup->drawing) {
//popup_close_window(popup);
//popup_create_window(popup);
if (popup->anchor.x != anchor.x || popup->anchor.y != anchor.y + popup->y_offset) {
popup->anchor = anchor;
popup->anchor.y += popup->y_offset;
if (popup->drawing) popup_resize(popup);
}
popup->adid = adid;
}
void popup_set_drawing(struct popup* popup, bool drawing) {