Align vertical centers of widget and active menuitem
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Thu, 31 Oct 2019 09:27:16 +0000 (10:27 +0100)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Thu, 31 Oct 2019 09:29:43 +0000 (10:29 +0100)
libs/gtkmm2ext/utils.cc

index 6f2a17737249b52aaf3118a42c03f57b6a36adb3..6d9e47e80ee2ec359a7c54f23ad88778b4baa3fd 100644 (file)
@@ -416,13 +416,13 @@ _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; /* a) */
+               y += allocation.get_height() / 2 - i->size_request().height / 2 - offset; /* a) */
        } else if (y + allocation.get_height() + menu_req.height <= monitor.get_y() + monitor.get_height()) {
                y += allocation.get_height(); /* b) */
        } else if ((y - menu_req.height) >= monitor.get_y()) {
                y -= menu_req.height; /* c) */
        } else if (i != items.end()) {
-               y -= offset; /* d) */
+               y += allocation.get_height() / 2 - i->size_request().height / 2 - offset; /* d) */
        } else if (monitor.get_height() - allocation.get_height() >= 2*(y - monitor.get_y())) {
                y += allocation.get_height(); /* e), more space below */
        } else {