diff options
author | Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr> | 2019-10-30 23:53:49 +0100 |
---|---|---|
committer | Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr> | 2019-10-30 23:56:36 +0100 |
commit | 3a16b892190ed6989a843de9dcf35a32d1b95441 (patch) | |
tree | 94d36d1e4d07f896c9f49c2dff5137cd15744f0c /libs/gtkmm2ext | |
parent | 27a3b93152fe8cdadffcc1f8dc514bc107d70381 (diff) |
Try harder to put the active item under the mouse (ArdourDropdown)
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index 8765d2b98b..d1b45d7030 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -394,8 +394,13 @@ _position_menu_anchored (int& x, int& y, bool& push_in, * enough room below the button; * c) align the bottom of the menu with the top of the button if there is * enough room above the button; - * d) align the bottom of the menu with the bottom of the monitor if there - * is enough room, but avoid moving the menu to another monitor */ + * d) try aligning the selected menu item again, this time with scrollbars; + * e) if there is no selected menu item, align the menu above the button or + * below the button, depending on where there is more space. + * For the d) and e) cases, the menu contents will be aligned as told, but + * the menu itself will be bigger than that to accomodate the menu items + * that are scrolled out of view, thanks to |push_in = true|. + * */ const MenuList& items = menu->items (); int offset = 0; @@ -411,16 +416,20 @@ _position_menu_anchored (int& x, int& y, bool& push_in, if (i != items.end() && y - offset >= monitor.get_y() && y - offset + menu_req.height <= monitor.get_y() + monitor.get_height()) { - y -= offset; + y -= offset; /* a) */ } else if (y + allocation.get_height() + menu_req.height <= monitor.get_y() + monitor.get_height()) { - y += allocation.get_height(); /* a) */ + y += allocation.get_height(); /* b) */ } else if ((y - menu_req.height) >= monitor.get_y()) { - y -= menu_req.height; /* b) */ + y -= menu_req.height; /* c) */ + } else if (i != items.end()) { + y -= offset; /* d) */ + } else if (monitor.get_height() - allocation.get_height() >= 2*(y - monitor.get_y())) { + y += allocation.get_height(); /* e), more space below */ } else { - y = monitor.get_y() + max(0, monitor.get_height() - menu_req.height); + y -= menu_req.height; /* e), more space above */ } - push_in = false; + push_in = true; } void |