summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-21 16:56:01 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-21 16:56:01 +0200
commitbe1140f2d3649663dc2ac5eb3a41612cd0470fa5 (patch)
treeca1d5b6da54bc40cc525f4afd9a919873c2a834f
parent8e3309ccc493b0953b14f86c91d7940b6d74506b (diff)
iOS: Tablet and phone menus
-rw-r--r--src/ui/window.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 3c77b18b..c2e33c89 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -185,8 +185,30 @@ static const iMenuItem navMenuItems_[] = {
185 { "Quit Lagrange", 'q', KMOD_PRIMARY, "quit" } 185 { "Quit Lagrange", 'q', KMOD_PRIMARY, "quit" }
186}; 186};
187#else 187#else
188/* Tablet menu. */
189static const iMenuItem tabletNavMenuItems_[] = {
190 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" },
191 { "Close Tab", 'w', KMOD_PRIMARY, "tabs.close" },
192 { "---", 0, 0, NULL },
193 { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" },
194 { "---", 0, 0, NULL },
195 { "Toggle Left Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" },
196 { "Toggle Right Sidebar", SDLK_p, KMOD_PRIMARY | KMOD_SHIFT, "sidebar2.toggle" },
197 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" },
198 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" },
199 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" },
200 { "---", 0, 0, NULL },
201 { "List All Bookmarks", 0, 0, "!open url:about:bookmarks" },
202 { "List Bookmarks by Tag", 0, 0, "!open url:about:bookmarks?tags" },
203 { "List Feed Entries", 0, 0, "!open url:about:feeds" },
204 { "---", 0, 0, NULL },
205 { "Settings...", SDLK_COMMA, KMOD_PRIMARY, "preferences" },
206 { "Help", SDLK_F1, 0, "!open url:about:help" },
207 { "Release Notes", 0, 0, "!open url:about:version" },
208};
209
188/* Phone menu. */ 210/* Phone menu. */
189static const iMenuItem navMenuItems_[] = { 211static const iMenuItem phoneNavMenuItems_[] = {
190 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" }, 212 { "New Tab", 't', KMOD_PRIMARY, "tabs.new" },
191 { "Close Tab", 'w', KMOD_PRIMARY, "tabs.close" }, 213 { "Close Tab", 'w', KMOD_PRIMARY, "tabs.close" },
192 { "---", 0, 0, NULL }, 214 { "---", 0, 0, NULL },
@@ -434,7 +456,9 @@ static void updatePadding_Window_(iWindow *d) {
434 safeAreaInsets_iOS(&left, &top, &right, &bottom); 456 safeAreaInsets_iOS(&left, &top, &right, &bottom);
435 setPadding_Widget(findChild_Widget(d->root, "navdiv"), left, top, right, 0); 457 setPadding_Widget(findChild_Widget(d->root, "navdiv"), left, top, right, 0);
436 iWidget *toolBar = findChild_Widget(d->root, "toolbar"); 458 iWidget *toolBar = findChild_Widget(d->root, "toolbar");
437 setPadding_Widget(toolBar, left, 0, right, bottom); 459 if (toolBar) {
460 setPadding_Widget(toolBar, left, 0, right, bottom);
461 }
438 } 462 }
439#endif 463#endif
440} 464}
@@ -732,6 +756,7 @@ static int appIconSize_(void) {
732} 756}
733 757
734static void setupUserInterface_Window(iWindow *d) { 758static void setupUserInterface_Window(iWindow *d) {
759 const iBool isPhone = (deviceType_App() == phone_AppDeviceType);
735 /* Children of root cover the entire window. */ 760 /* Children of root cover the entire window. */
736 setFlags_Widget(d->root, resizeChildren_WidgetFlag, iTrue); 761 setFlags_Widget(d->root, resizeChildren_WidgetFlag, iTrue);
737 setCommandHandler_Widget(d->root, handleRootCommands_); 762 setCommandHandler_Widget(d->root, handleRootCommands_);
@@ -817,7 +842,8 @@ static void setupUserInterface_Window(iWindow *d) {
817 iLabelWidget *lock = 842 iLabelWidget *lock =
818 addChildFlags_Widget(navBar, 843 addChildFlags_Widget(navBar,
819 iClob(newIcon_LabelWidget("\U0001f513", SDLK_i, KMOD_PRIMARY, "document.info")), 844 iClob(newIcon_LabelWidget("\U0001f513", SDLK_i, KMOD_PRIMARY, "document.info")),
820 frameless_WidgetFlag | tight_WidgetFlag); 845 frameless_WidgetFlag |
846 (deviceType_App() == desktop_AppDeviceType ? tight_WidgetFlag : 0));
821 setId_Widget(as_Widget(lock), "navbar.lock"); 847 setId_Widget(as_Widget(lock), "navbar.lock");
822 setFont_LabelWidget(lock, defaultSymbols_FontId); 848 setFont_LabelWidget(lock, defaultSymbols_FontId);
823 updateTextCStr_LabelWidget(lock, "\U0001f512"); 849 updateTextCStr_LabelWidget(lock, "\U0001f512");
@@ -856,14 +882,21 @@ static void setupUserInterface_Window(iWindow *d) {
856 setId_Widget(addChild_Widget( 882 setId_Widget(addChild_Widget(
857 navBar, iClob(newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))), 883 navBar, iClob(newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))),
858 "reload"); 884 "reload");
885
859 setId_Widget(addChildFlags_Widget(navBar, 886 setId_Widget(addChildFlags_Widget(navBar,
860 iClob(newIcon_LabelWidget( 887 iClob(newIcon_LabelWidget(
861 "\U0001f3e0", SDLK_h, KMOD_PRIMARY | KMOD_SHIFT, "navigate.home")), 888 "\U0001f3e0", SDLK_h, KMOD_PRIMARY | KMOD_SHIFT, "navigate.home")),
862 collapse_WidgetFlag), 889 collapse_WidgetFlag),
863 "navbar.home"); 890 "navbar.home");
864#if !defined (iHaveNativeMenus) 891#if !defined (iHaveNativeMenus)
892# if defined (iPlatformAppleMobile)
893 iLabelWidget *navMenu =
894 makeMenuButton_LabelWidget("\U0001d362", isPhone ? phoneNavMenuItems_ : tabletNavMenuItems_,
895 isPhone ? iElemCount(phoneNavMenuItems_) : iElemCount(tabletNavMenuItems_));
896# else
865 iLabelWidget *navMenu = 897 iLabelWidget *navMenu =
866 makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_)); 898 makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_));
899# endif
867 setAlignVisually_LabelWidget(navMenu, iTrue); 900 setAlignVisually_LabelWidget(navMenu, iTrue);
868 setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu"); 901 setId_Widget(addChildFlags_Widget(navBar, iClob(navMenu), collapse_WidgetFlag), "navbar.menu");
869#else 902#else
@@ -949,7 +982,8 @@ static void setupUserInterface_Window(iWindow *d) {
949 setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "toolbar.showident")), frameless_WidgetFlag), "toolbar.ident"); 982 setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f464", "toolbar.showident")), frameless_WidgetFlag), "toolbar.ident");
950 setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f588", "toolbar.showview arg:-1")), 983 setId_Widget(addChildFlags_Widget(toolBar, iClob(newLargeIcon_LabelWidget("\U0001f588", "toolbar.showview arg:-1")),
951 frameless_WidgetFlag | commandOnClick_WidgetFlag), "toolbar.view"); 984 frameless_WidgetFlag | commandOnClick_WidgetFlag), "toolbar.view");
952 iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_)); 985 iLabelWidget *menuButton = makeMenuButton_LabelWidget("\U0001d362", phoneNavMenuItems_,
986 iElemCount(phoneNavMenuItems_));
953 setFont_LabelWidget(menuButton, uiLabelLarge_FontId); 987 setFont_LabelWidget(menuButton, uiLabelLarge_FontId);
954 addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); 988 addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag);
955 iForEach(ObjectList, i, children_Widget(toolBar)) { 989 iForEach(ObjectList, i, children_Widget(toolBar)) {
@@ -1410,6 +1444,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1410 //updateRootSize_Window_(d, iTrue); 1444 //updateRootSize_Window_(d, iTrue);
1411 invalidate_Window_(d); 1445 invalidate_Window_(d);
1412 d->isMinimized = iFalse; 1446 d->isMinimized = iFalse;
1447 postRefresh_App();
1413 return iTrue; 1448 return iTrue;
1414 case SDL_WINDOWEVENT_MINIMIZED: 1449 case SDL_WINDOWEVENT_MINIMIZED:
1415 d->isMinimized = iTrue; 1450 d->isMinimized = iTrue;