Lagrange [work/v1.10]

Android: Fixed root sizing; clip menu not showing; toolbar buttons

=> 3e371f7ea70b1c2e06e1af50c3b41efdecbd072b

diff --git a/src/prefs.c b/src/prefs.c
index 426b7212..3aa05f01 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -44,7 +44,12 @@ void init_Prefs(iPrefs *d) {
     d->uiAnimations      = iTrue;
     d->uiScale           = 1.0f; /* default set elsewhere */
     d->zoomPercent       = 100;
+#if defined (iPlatformAndroidMobile)
+    /* Android has a system-wide back button so no need to have a duplicate. */
+    d->toolbarActions[0] = closeTab_ToolbarAction;
+#else
     d->toolbarActions[0] = back_ToolbarAction;
+#endif
     d->toolbarActions[1] = forward_ToolbarAction;
     d->sideIcon          = iTrue;
     d->hideToolbarOnScroll = iTrue;
diff --git a/src/ui/root.c b/src/ui/root.c
index 31176115..5ec63e91 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -1534,19 +1534,10 @@ void createUserInterface_Root(iRoot *d) {
                                      arrangeHeight_WidgetFlag | arrangeHorizontal_WidgetFlag |
                                      commandOnClick_WidgetFlag |
                                      drawBackgroundToBottom_WidgetFlag, iTrue);
-#if defined (iPlatformAndroidMobile)
-        /* Android has a system-provided back button (or gesture?), or in the toolbar we can have
-           a different in the place of Back. */
-        setId_Widget(addChildFlags_Widget(toolBar,
-                                          iClob(newLargeIcon_LabelWidget(close_Icon, "tabs.close")),
-                                          frameless_WidgetFlag),
-                     "toolbar.close");
-#else
         setId_Widget(addChildFlags_Widget(toolBar,
                                           iClob(newLargeIcon_LabelWidget("", "...")),
                                           frameless_WidgetFlag),
                      "toolbar.action1");
-#endif
         setId_Widget(addChildFlags_Widget(toolBar,
                                           iClob(newLargeIcon_LabelWidget("", "...")),
                                           frameless_WidgetFlag),
@@ -1638,6 +1629,12 @@ void createUserInterface_Root(iRoot *d) {
                 { select_Icon " ${menu.selectall}", 0, 0, "input.selectall" },
             }, 8);
 #endif
+        if (deviceType_App() == phone_AppDeviceType) {
+            /* Small screen; conserve space by removing the Cancel item. */
+            iRelease(removeChild_Widget(clipMenu, lastChild_Widget(clipMenu)));
+            iRelease(removeChild_Widget(clipMenu, lastChild_Widget(clipMenu)));
+            iRelease(removeChild_Widget(clipMenu, lastChild_Widget(clipMenu)));
+        }
         iWidget *splitMenu = makeMenu_Widget(root, (iMenuItem[]){
             { "${menu.split.merge}", '1', 0, "ui.split arg:0" },
             { "${menu.split.swap}", SDLK_x, 0, "ui.split swap:1" },
diff --git a/src/ui/util.c b/src/ui/util.c
index 6add5c89..c590caa9 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1204,6 +1204,9 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
         leftExcess   += l;
         rightExcess  += r;
     }
+#elif defined (iPlatformMobile)
+    /* Reserve space for the keyboard. */
+    bottomExcess += get_MainWindow()->keyboardHeight;
 #endif
     if (!allowOverflow) {
         if (bottomExcess > 0 && (!isPortraitPhone || !isSlidePanel)) {
@@ -2495,8 +2498,9 @@ iWidget *makePreferences_Widget(void) {
         };
         const iMenuItem colorPanelItems[] = {
             { "title id:heading.prefs.colors" },
-            //{ "heading id:heading.prefs.uitheme" },
+#if !defined (iPlatformAndroidMobile)
             { "toggle id:prefs.ostheme" },
+#endif
             { "radio id:prefs.theme", 0, 0, (const void *) themeItems },
             { "radio id:prefs.accent", 0, 0, (const void *) accentItems },
             { "heading id:heading.prefs.pagecontent" },
diff --git a/src/ui/window.c b/src/ui/window.c
index 953d5ea4..ef941798 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -606,6 +606,7 @@ void init_MainWindow(iMainWindow *d, iRect rect) {
 #endif
     setCurrent_Text(d->base.text);
     SDL_GetRendererOutputSize(d->base.render, &d->base.size.x, &d->base.size.y);
+    d->maxDrawableHeight = d->base.size.y;
     setupUserInterface_MainWindow(d);
     postCommand_App("~bindings.changed"); /* update from bindings */
     /* Load the border shadow texture. */ {
@@ -1011,8 +1012,19 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) {
             if (event.type == SDL_USEREVENT && isCommand_UserEvent(ev, "window.sysframe") && mw) {
                 /* This command is sent on Android to update the keyboard height. */
                 const char *cmd = command_UserEvent(ev);
-                setKeyboardHeight_MainWindow(mw, argLabel_Command(cmd, "fullheight") -
-                                                 argLabel_Command(cmd, "bottom"));
+                /*
+                    0
+                    |
+                 top
+                 |  |
+                 | bottom (top of keyboard)   :
+                 |  |                         : keyboardHeight
+                 maxDrawableHeight            :
+                    |
+                   fullheight
+                 */
+                setKeyboardHeight_MainWindow(mw, argLabel_Command(cmd, "top") +
+                    mw->maxDrawableHeight - argLabel_Command(cmd, "bottom"));
                 return iTrue;
             }
             if (processEvent_Touch(&event)) {
@@ -1245,11 +1257,15 @@ void draw_MainWindow(iMainWindow *d) {
     isDrawing_ = iTrue;
     setCurrent_Text(d->base.text);
     /* Check if root needs resizing. */ {
+        const iBool wasPortrait = isPortrait_App();
         iInt2 renderSize;
         SDL_GetRendererOutputSize(w->render, &renderSize.x, &renderSize.y);
         if (!isEqual_I2(renderSize, w->size)) {
             updateSize_MainWindow_(d, iTrue);
             processEvents_App(postedEventsOnly_AppEventMode);
+            if (isPortrait_App() != wasPortrait) {
+                d->maxDrawableHeight = renderSize.y;
+            }
         }
     }
     const int   winFlags = SDL_GetWindowFlags(d->base.win);
diff --git a/src/ui/window.h b/src/ui/window.h
index ae111f4c..b4e348d2 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -116,7 +116,8 @@ struct Impl_MainWindow {
     iString *     pendingSplitUrl; /* URL to open in a newly opened split */
     iString *     pendingSplitOrigin; /* tab from where split was initiated, if any */
     SDL_Texture * appIcon;
-    int           keyboardHeight; /* mobile software keyboards */    
+    int           keyboardHeight; /* mobile software keyboards */
+    int           maxDrawableHeight;
 };
 
 iLocalDef enum iWindowType type_Window(const iAnyWindow *d) {
@@ -187,10 +188,10 @@ void        setKeyboardHeight_MainWindow    (iMainWindow *, int height);
 void        setSplitMode_MainWindow         (iMainWindow *, int splitMode);
 void        checkPendingSplit_MainWindow    (iMainWindow *);
 void        swapRoots_MainWindow            (iMainWindow *);
-void        showToolbars_MainWindow         (iMainWindow *, iBool show);
+//void        showToolbars_MainWindow         (iMainWindow *, iBool show);
 void        resize_MainWindow               (iMainWindow *, int w, int h);
 
-iBool       processEvent_MainWindow         (iMainWindow *, const SDL_Event *);
+//iBool       processEvent_MainWindow         (iMainWindow *, const SDL_Event *);
 void        draw_MainWindow                 (iMainWindow *);
 void        drawWhileResizing_MainWindow    (iMainWindow *, int w, int h); /* workaround for SDL bug */
 
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/3e371f7ea70b1c2e06e1af50c3b41efdecbd072b
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
69.334645 milliseconds
Gemini-to-HTML Time
0.650737 milliseconds

This content has been proxied by September (3851b).