summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-26 19:21:45 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-26 19:21:45 +0300
commit144a8877bb43fce3cabfe4416b09400b1889f5a1 (patch)
tree982b1470e8df4be0f7ee286eff501e8ebdf37e10
parent2e401c3cfa4462f83e280bd9820e0f41c734bbbc (diff)
Popup menus are positioned on selected item
-rw-r--r--src/ui/util.c10
-rw-r--r--src/ui/window.c1
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 72a973a6..adee2ee5 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1023,6 +1023,14 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1023 setFlags_Widget(d, commandOnMouseMiss_WidgetFlag, iTrue); 1023 setFlags_Widget(d, commandOnMouseMiss_WidgetFlag, iTrue);
1024 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse); 1024 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse);
1025 arrange_Widget(d); /* need to know the height */ 1025 arrange_Widget(d); /* need to know the height */
1026 /* A vertical offset determined by a possible selected label in the menu. */ {
1027 iConstForEach(ObjectList, child, children_Widget(d)) {
1028 const iWidget *item = constAs_Widget(child.object);
1029 if (flags_Widget(item) & selected_WidgetFlag) {
1030 windowCoord.y -= item->rect.pos.y;
1031 }
1032 }
1033 }
1026#if defined (LAGRANGE_ENABLE_POPUP_MENUS) 1034#if defined (LAGRANGE_ENABLE_POPUP_MENUS)
1027 /* Determine total display bounds where the popup may appear. */ 1035 /* Determine total display bounds where the popup may appear. */
1028 iRect displayRect = zero_Rect(); 1036 iRect displayRect = zero_Rect();
@@ -1045,7 +1053,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1045 addv_I2(&winRect.pos, winPos); 1053 addv_I2(&winRect.pos, winPos);
1046 iRect visibleWinRect = intersect_Rect(winRect, displayRect); 1054 iRect visibleWinRect = intersect_Rect(winRect, displayRect);
1047 /* Only use a popup window if the menu can't fit inside the main window. */ 1055 /* Only use a popup window if the menu can't fit inside the main window. */
1048 if (height_Widget(d) * pixelRatio > visibleWinRect.size.y && isUsingMenuPopupWindows_()) { 1056 if (height_Widget(d) / pixelRatio > visibleWinRect.size.y && isUsingMenuPopupWindows_()) {
1049 if (postCommands) { 1057 if (postCommands) {
1050 postCommand_Widget(d, "menu.opened"); 1058 postCommand_Widget(d, "menu.opened");
1051 } 1059 }
diff --git a/src/ui/window.c b/src/ui/window.c
index bdac441a..164c2478 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1659,6 +1659,7 @@ iWindow *newPopup_Window(iInt2 screenPos, iWidget *rootWidget) {
1659 win->keyRoot = root; 1659 win->keyRoot = root;
1660 root->widget = rootWidget; 1660 root->widget = rootWidget;
1661 root->window = win; 1661 root->window = win;
1662 rootWidget->rect.pos = zero_I2();
1662 setRoot_Widget(rootWidget, root); 1663 setRoot_Widget(rootWidget, root);
1663 setForceSoftwareRender_App(oldSw); 1664 setForceSoftwareRender_App(oldSw);
1664 stop_PerfTimer(newPopup_Window); 1665 stop_PerfTimer(newPopup_Window);