Lagrange [work/v1.12]

Mobile: Fixing phone toolbar glitches

=> 1cd4c78086ab921f13393942ab06fadda196c6c9

diff --git a/src/app.h b/src/app.h
index 003b8d37..f2f1fb0d 100644
--- a/src/app.h
+++ b/src/app.h
@@ -88,6 +88,7 @@ iBool               isLandscape_App     (void);
 iLocalDef iBool     isPortrait_App      (void) { return !isLandscape_App(); }
 enum iAppDeviceType deviceType_App      (void);
 iLocalDef iBool     isPortraitPhone_App (void) { return isPortrait_App() && deviceType_App() == phone_AppDeviceType; }
+iLocalDef iBool     isLandscapePhone_App(void) { return isLandscape_App() && deviceType_App() == phone_AppDeviceType; }
 iBool               isRunningUnderWindowSystem_App  (void);
 
 iGmCerts *          certs_App           (void);
diff --git a/src/ui/root.c b/src/ui/root.c
index ca73f3a5..da90a796 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -523,7 +523,6 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
             addChildPos_Widget(findChild_Widget(root, "tabs.content"), iClob(sidebar), front_WidgetAddPos);            
             setWidth_SidebarWidget(sidebar, 73.0f);
             setFlags_Widget(as_Widget(sidebar), fixedHeight_WidgetFlag | fixedPosition_WidgetFlag, iFalse);
-            showToolbar_Root(root->root, iFalse);
         }
         else {
             addChild_Widget(root, iClob(sidebar));
@@ -535,8 +534,8 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
             setMidHeight_SidebarWidget(sidebar, midHeight);
             setFixedSize_Widget(as_Widget(sidebar), init_I2(-1, midHeight));
             setPos_Widget(as_Widget(sidebar), init_I2(0, height_Widget(root) - midHeight));
-            showToolbar_Root(root->root, iTrue);
         }
+        showToolbar_Root(root->root, isPortrait_App() || prefs_App()->bottomNavBar);
         return iFalse;
     }
     else if (equal_Command(cmd, "root.arrange")) {
@@ -849,8 +848,8 @@ static void updateNavBarSize_(iWidget *navBar) {
         static const char *buttons[] = { "navbar.action1", "navbar.action2", "navbar.action3",
                                          "navbar.action4", "navbar.ident",   "navbar.menu" };
         iWidget *toolBar = findWidget_Root("toolbar");
-        setVisualOffset_Widget(toolBar, 0, 0, 0);
-        setFlags_Widget(toolBar, hidden_WidgetFlag, isLandscape_App());
+//        setVisualOffset_Widget(toolBar, 0, 0, 0);
+//        setFlags_Widget(toolBar, hidden_WidgetFlag, isLandscape_App());
         iForIndices(i, buttons) {
             iLabelWidget *btn = findChild_Widget(navBar, buttons[i]);
             setFlags_Widget(as_Widget(btn), hidden_WidgetFlag, isPortrait_App());
@@ -1685,6 +1684,7 @@ void createUserInterface_Root(iRoot *d) {
                              moveToParentBottomEdge_WidgetFlag |
                                  parentCannotResizeHeight_WidgetFlag | arrangeVertical_WidgetFlag |
                                  arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag |
+                                 drawBackgroundToHorizontalSafeArea_WidgetFlag |
                                  drawBackgroundToBottom_WidgetFlag);
         iWidget *toolBar = new_Widget();
         addChild_Widget(bottomBar, iClob(toolBar));
@@ -1908,7 +1908,6 @@ static void setBottomBarPosition_(iWidget *bottomBar, iBool show, iBool animate)
     iWidget *docTabs = findChild_Widget(root->widget, "doctabs");
     iWidget *toolBar = findChild_Widget(bottomBar, "toolbar");
     iWidget *navBar = findChild_Widget(root->widget, "navbar");
-    const int height = height_Widget(bottomBar);
     size_t numPages = 0;
     iBool bottomTabBar = prefs->bottomTabBar;
     if (prefs->bottomTabBar || prefs->bottomNavBar) {
@@ -1927,6 +1926,7 @@ static void setBottomBarPosition_(iWidget *bottomBar, iBool show, iBool animate)
     }
 #endif
     showCollapsed_Widget(toolBar, isPortrait_App());
+    const int height = height_Widget(bottomBar);
     if (show) {
         if (flags_Widget(bottomBar) & hidden_WidgetFlag) {
             setFlags_Widget(bottomBar, hidden_WidgetFlag, iFalse);
@@ -1938,7 +1938,12 @@ static void setBottomBarPosition_(iWidget *bottomBar, iBool show, iBool animate)
         }
         if (bottomTabBar) {
             /* Tab bar needs to stay visible, too. */
-            setVisualOffset_Widget(tabBar, -bottomBar->rect.size.y, 200 * animate, easeOut_AnimFlag);
+            if (prefs->bottomNavBar || isPortrait_App()) {
+                setVisualOffset_Widget(tabBar, -height, 200 * animate, easeOut_AnimFlag);
+            }
+            else {
+                setVisualOffset_Widget(tabBar, -bottomSafe, 200 * animate, easeOut_AnimFlag);
+            }
             //tabBar->flags2 |= permanentVisualOffset_WidgetFlag2;
         }
     }
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 3536d2fc..2a2ce30a 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1365,12 +1365,18 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                             isPortrait_App());
             setBackgroundColor_Widget(w, isPortrait_App() ? uiBackgroundSidebar_ColorId : none_ColorId);
         }
-        if (!isPortraitPhone_App() && !prefs_App()->bottomTabBar && !prefs_App()->bottomNavBar) {
+        if (isPortrait_App()) {
             /* In sliding sheet mode, sidebar is resized to fit in the safe area. */
+            setPadding_Widget(d->actions, 0, 0, 0, 0);
+        }
+        else if (isLandscape_App() && !prefs_App()->bottomTabBar && !prefs_App()->bottomNavBar) {
             setPadding_Widget(d->actions, 0, 0, 0, bottomSafeInset_Mobile());
         }
         else {
-            setPadding_Widget(d->actions, 0, 0, 0, 0);
+            setPadding_Widget(d->actions, 0, 0, 0,
+                              (prefs_App()->bottomNavBar && !prefs_App()->hideToolbarOnScroll ?
+                                 height_Widget(findChild_Widget(root_Widget(w), "navbar")) : 0) +
+                               bottomSafeInset_Mobile());
         }
         return iFalse;
     }
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 61c8a37e..632e3900 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1518,18 +1518,16 @@ void drawLayerEffects_Widget(const iWidget *d) {
         }
         if (top < 0) {
             fillRect_Paint(&p, (iRect){ init_I2(left_Rect(rect), 0),
-                                        init_I2(width_Rect(rect), top_Rect(rect)) },
-                           d->bgColor);
+                                        init_I2(width_Rect(rect), top_Rect(rect)) }, d->bgColor);
         }
         if (left < 0) {
             fillRect_Paint(&p, (iRect){ init_I2(0, top_Rect(rect)),
-                init_I2(left_Rect(rect), height_Rect(rect)) }, d->bgColor);
+                                        init_I2(left_Rect(rect), rootSize.y) }, d->bgColor);
         }
         if (right > 0) {
             fillRect_Paint(&p, (iRect){ init_I2(right_Rect(rect), top_Rect(rect)),
-                init_I2(right, height_Rect(rect)) }, d->bgColor);
+                                        init_I2(right, rootSize.y) }, d->bgColor);
         }
-//        adjustEdges_Rect(&rect, iMin(0, top), iMax(0, right), iMax(0, bottom), iMin(0, left));
     }
 #endif
 }
@@ -1545,38 +1543,11 @@ void drawBackground_Widget(const iWidget *d) {
     if (d->bgColor >= 0 || d->frameColor >= 0) {
         iRect rect = bounds_Widget(d);
         if (d->flags & drawBackgroundToBottom_WidgetFlag) {
-            rect.size.y += size_Root(d->root).y; // = iMax(rect.size.y, size_Root(d->root).y - top_Rect(rect));
+            rect.size.y += size_Root(d->root).y;
         }
         iPaint p;
         init_Paint(&p);
         if (d->bgColor >= 0) {
-#if 0 && defined (iPlatformAppleMobile)
-            /* TODO: This is part of the unbuffered draw (layer effects). */
-            if (d->flags & (drawBackgroundToHorizontalSafeArea_WidgetFlag |
-                            drawBackgroundToVerticalSafeArea_WidgetFlag)) {
-                const iInt2 rootSize = size_Root(d->root);
-                const iInt2 center = divi_I2(rootSize, 2);
-                int top = 0, right = 0, bottom = 0, left = 0;
-                if (d->flags & drawBackgroundToHorizontalSafeArea_WidgetFlag) {
-                    const iBool isWide = width_Rect(rect) > rootSize.x * 9 / 10;
-                    if (isWide || mid_Rect(rect).x < center.x) {
-                        left = -left_Rect(rect);
-                    }
-                    if (isWide || mid_Rect(rect).x > center.x) {
-                        right = rootSize.x - right_Rect(rect);
-                    }
-                }
-                if (d->flags & drawBackgroundToVerticalSafeArea_WidgetFlag) {
-                    if (top_Rect(rect) > center.y) {
-                        bottom = rootSize.y - bottom_Rect(rect);
-                    }
-                    if (bottom_Rect(rect) < center.y) {
-                        top = -top_Rect(rect);
-                    }
-                }
-                adjustEdges_Rect(&rect, iMin(0, top), iMax(0, right), iMax(0, bottom), iMin(0, left));
-            }
-#endif
             fillRect_Paint(&p, rect, d->bgColor);
         }
         if (d->frameColor >= 0 && ~d->flags & frameless_WidgetFlag) {
@@ -1625,7 +1596,7 @@ static void addToPotentiallyVisible_Widget_(const iWidget *d, iPtrArray *pvs, iR
     if (isDrawn_Widget_(d)) {
         iRect bounds = bounds_Widget(d);
         if (d->flags & drawBackgroundToBottom_WidgetFlag) {
-            bounds.size.y += size_Root(d->root).y; // iMax(bounds.size.y, size_Root(d->root).y - top_Rect(bounds));
+            bounds.size.y += size_Root(d->root).y;
         }
         if (isFullyContainedByOther_Rect(bounds, *fullyMasked)) {
             return; /* can't be seen */
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.12/cdiff/1cd4c78086ab921f13393942ab06fadda196c6c9
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
74.499956 milliseconds
Gemini-to-HTML Time
0.79686 milliseconds

This content has been proxied by September (ba2dc).