diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-09 21:41:46 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-10 06:29:31 +0300 |
commit | d5249e99515c1a10db34bd9cd730b315c35fecc8 (patch) | |
tree | e8621b3926d679de02cc70f5b18a7bd9e539942a /src | |
parent | c9da3639e436f0f5d6a6f181a16c82cdb41aaf77 (diff) |
Mobile: Close menus when toolbar hidden
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/util.c | 3 | ||||
-rw-r--r-- | src/ui/window.c | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 9713d55f..e6edb119 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -704,6 +704,9 @@ void openMenuFlags_Widget(iWidget *d, iInt2 coord, iBool postCommands) { | |||
704 | } | 704 | } |
705 | 705 | ||
706 | void closeMenu_Widget(iWidget *d) { | 706 | void closeMenu_Widget(iWidget *d) { |
707 | if (d == NULL || flags_Widget(d) & hidden_WidgetFlag) { | ||
708 | return; /* Already closed. */ | ||
709 | } | ||
707 | setFlags_Widget(d, hidden_WidgetFlag, iTrue); | 710 | setFlags_Widget(d, hidden_WidgetFlag, iTrue); |
708 | setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iTrue); | 711 | setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iTrue); |
709 | postRefresh_App(); | 712 | postRefresh_App(); |
diff --git a/src/ui/window.c b/src/ui/window.c index 715f5d5f..3ea45695 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -1164,6 +1164,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1164 | iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", phoneNavMenuItems_, | 1164 | iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", phoneNavMenuItems_, |
1165 | iElemCount(phoneNavMenuItems_)); | 1165 | iElemCount(phoneNavMenuItems_)); |
1166 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); | 1166 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); |
1167 | setId_Widget(as_Widget(menuButton), "toolbar.navmenu"); | ||
1167 | addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); | 1168 | addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); |
1168 | iForEach(ObjectList, i, children_Widget(toolBar)) { | 1169 | iForEach(ObjectList, i, children_Widget(toolBar)) { |
1169 | iLabelWidget *btn = i.object; | 1170 | iLabelWidget *btn = i.object; |
@@ -1179,7 +1180,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1179 | }; | 1180 | }; |
1180 | iWidget *menu = makeMenu_Widget(findChild_Widget(toolBar, "toolbar.view"), | 1181 | iWidget *menu = makeMenu_Widget(findChild_Widget(toolBar, "toolbar.view"), |
1181 | items, iElemCount(items)); | 1182 | items, iElemCount(items)); |
1182 | setId_Widget(menu, "toolbar.menu"); | 1183 | setId_Widget(menu, "toolbar.menu"); /* view menu */ |
1183 | } | 1184 | } |
1184 | #endif | 1185 | #endif |
1185 | updatePadding_Window_(d); | 1186 | updatePadding_Window_(d); |
@@ -1232,6 +1233,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1232 | } | 1233 | } |
1233 | 1234 | ||
1234 | void showToolbars_Window(iWindow *d, iBool show) { | 1235 | void showToolbars_Window(iWindow *d, iBool show) { |
1236 | /* The toolbar is only used on phone portrait layout. */ | ||
1235 | if (isLandscape_App()) return; | 1237 | if (isLandscape_App()) return; |
1236 | iWidget *toolBar = findChild_Widget(d->root, "toolbar"); | 1238 | iWidget *toolBar = findChild_Widget(d->root, "toolbar"); |
1237 | if (!toolBar) return; | 1239 | if (!toolBar) return; |
@@ -1241,6 +1243,9 @@ void showToolbars_Window(iWindow *d, iBool show) { | |||
1241 | setVisualOffset_Widget(toolBar, 0, 200, easeOut_AnimFlag); | 1243 | setVisualOffset_Widget(toolBar, 0, 200, easeOut_AnimFlag); |
1242 | } | 1244 | } |
1243 | else if (!show && isVisible_Widget(toolBar)) { | 1245 | else if (!show && isVisible_Widget(toolBar)) { |
1246 | /* Close any menus that open via the toolbar. */ | ||
1247 | closeMenu_Widget(findChild_Widget(findWidget_App("toolbar.navmenu"), "menu")); | ||
1248 | closeMenu_Widget(findChild_Widget(toolBar, "toolbar.menu")); | ||
1244 | setFlags_Widget(toolBar, hidden_WidgetFlag, iTrue); | 1249 | setFlags_Widget(toolBar, hidden_WidgetFlag, iTrue); |
1245 | setVisualOffset_Widget(toolBar, height, 200, easeOut_AnimFlag); | 1250 | setVisualOffset_Widget(toolBar, height, 200, easeOut_AnimFlag); |
1246 | } | 1251 | } |