Lagrange [work/v1.10]

Mobile: Taller portrait phone navbar

=> edd6555da303a6eb6fc6dc4132a5094625ba27e9

diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 2de16e6e..5d74f855 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -59,6 +59,9 @@ static const int    unlimitedWidth_InputWidget_  = 1000000; /* TODO: WrapText di
 static const iChar  sensitiveChar_ = 0x25cf;   /* black circle */
 static const char * sensitive_     = "\u25cf";
 
+#define extraPaddingHeight_     ((isPortraitPhone_App() ? 3.0f : 1.25f) * gap_UI) /* phone: proper tap target */
+#define minWidth_InputWidget_   (3 * gap_UI)
+
 static void enableEditorKeysInMenus_(iBool enable) {
 #if defined (iPlatformAppleDesktop)
     enableMenuItemsByKey_MacOS(SDLK_LEFT,  KMOD_PRIMARY, enable);
@@ -228,7 +231,7 @@ struct Impl_InputWidget {
     size_t          maxLen;  /* characters */
     iString         srcHint;
     iString         hint;
-    int             leftPadding;
+    int             leftPadding; /* additional padding between frame and content */
     int             rightPadding;
     int             minWrapLines, maxWrapLines; /* min/max number of visible lines allowed */
     iRangei         visWrapLines; /* which wrap lines are current visible */
@@ -359,8 +362,6 @@ static const iInputLine *line_InputWidget_(const iInputWidget *d, size_t index)
 
 #endif /* !LAGRANGE_USE_SYSTEM_TEXT_INPUT */
 
-#define extraPaddingHeight_ (1.25f * gap_UI)
-
 static iRect contentBounds_InputWidget_(const iInputWidget *d) {
     const iWidget *w      = constAs_Widget(d);
     iRect          bounds = adjusted_Rect(bounds_Widget(w),
@@ -374,8 +375,6 @@ static iRect contentBounds_InputWidget_(const iInputWidget *d) {
     return bounds;
 }
 
-#define minWidth_InputWidget_   (3 * gap_UI)
-
 static iWrapText wrap_InputWidget_(const iInputWidget *d, int y) {
 #if LAGRANGE_USE_SYSTEM_TEXT_INPUT
     iUnused(y); /* full text is wrapped always */
diff --git a/src/ui/root.c b/src/ui/root.c
index 5ec63e91..d5148056 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -650,10 +650,10 @@ static void checkLoadAnimation_Root_(iRoot *d) {
 
 void updatePadding_Root(iRoot *d) {
     if (d == NULL) return;
-    iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
-    float bottom = 0.0f;
 #if defined (iPlatformAppleMobile)
+    iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
     float left, top, right;
+    float bottom = 0.0f;
     safeAreaInsets_iOS(&left, &top, &right, &bottom);
     /* Respect the safe area insets. */ {
         setPadding_Widget(findChild_Widget(d->widget, "navdiv"), left, top, right, 0);
@@ -662,15 +662,6 @@ void updatePadding_Root(iRoot *d) {
         }
     }
 #endif
-//    if (toolBar) {
-        /* TODO: get this from toolBar height, but it's buggy for some reason */
-//        const int sidebarBottomPad = isPortrait_App() ? 11 * gap_UI + bottom : 0;
-//        setPadding_Widget(findChild_Widget(d->widget, "sidebar"), 0, 0, 0, sidebarBottomPad);
-        //setPadding_Widget(findChild_Widget(d->widget, "sidebar2"), 0, 0, 0, sidebarBottomPad);
-        /* TODO: There seems to be unrelated layout glitch in the sidebar where its children
-           are not arranged correctly until it's hidden and reshown. */
-//    }
-    /* Note that `handleNavBarCommands_` also adjusts padding and spacing. */
 }
 
 void updateToolbarColors_Root(iRoot *d) {
@@ -773,9 +764,8 @@ static void updateNavBarSize_(iWidget *navBar) {
     const iBool isPhone = deviceType_App() == phone_AppDeviceType;
     const iBool isNarrow = !isPhone && isNarrow_Root(navBar->root);
     /* Adjust navbar padding. */ {
-        int hPad = isPhone && isPortrait_App() ? 0 : (isPhone || isNarrow) ? gap_UI / 2
-                                                                             : gap_UI * 3 / 2;
-        int vPad = gap_UI * 3 / 2;
+        int hPad = isPortraitPhone_App() ? 0 : isPhone || isNarrow ? gap_UI / 2 : (gap_UI * 3 / 2);
+        int vPad   = gap_UI * 3 / 2;
         int topPad = !findWidget_Root("winbar") ? gap_UI / 2 : 0;
         setPadding_Widget(navBar, hPad, vPad / 3 + topPad, hPad, vPad / 2);
     }
@@ -1162,7 +1152,7 @@ void updateMetrics_Root(iRoot *d) {
     iWidget      *urlButtons = findChild_Widget(navBar, "url.buttons");
     iLabelWidget *idName     = findChild_Widget(d->widget, "toolbar.name");
     setPadding_Widget(as_Widget(url), 0, gap_UI, 0, gap_UI);
-    navBar->rect.size.y = 0; /* recalculate height based on children (FIXME: shouldn't be needed) */
+//    navBar->rect.size.y = 0; /* recalculate height based on children (FIXME: shouldn't be needed) */
     setFixedSize_Widget(embedPad, init_I2(width_Widget(urlButtons) + gap_UI / 2, 1));
     rightEmbed->rect.pos.y = gap_UI;
     updatePadding_Root(d);
@@ -1403,13 +1393,15 @@ void createUserInterface_Root(iRoot *d) {
                 setFont_LabelWidget(pageMenuButton, uiContentBold_FontId);
                 setAlignVisually_LabelWidget(pageMenuButton, iTrue);
                 addChildFlags_Widget(urlButtons, iClob(pageMenuButton),
-                                     embedFlags | tight_WidgetFlag | collapse_WidgetFlag);
+                                     embedFlags | tight_WidgetFlag | collapse_WidgetFlag |
+                                     resizeToParentHeight_WidgetFlag);
                 updateSize_LabelWidget(pageMenuButton);
             }
             /* Reload button. */ {
                 iLabelWidget *reload = newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload");
                 setId_Widget(as_Widget(reload), "reload");
-                addChildFlags_Widget(urlButtons, iClob(reload), embedFlags | collapse_WidgetFlag);
+                addChildFlags_Widget(urlButtons, iClob(reload), embedFlags | collapse_WidgetFlag |
+                                     resizeToParentHeight_WidgetFlag);
                 updateSize_LabelWidget(reload);
             }
             addChildFlags_Widget(as_Widget(url), iClob(urlButtons), moveToParentRightEdge_WidgetFlag);
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 4ab8d602..eb3004dc 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -237,6 +237,24 @@ iLocalDef int height_Widget(const iAnyObject *d) {
     }
     return 0;
 }
+iLocalDef int leftPad_Widget(const iWidget *d) {
+    return d->padding[0];
+}
+iLocalDef int topPad_Widget(const iWidget *d) {
+    return d->padding[1];
+}
+iLocalDef int rightPad_Widget(const iWidget *d) {
+    return d->padding[2];
+}
+iLocalDef int bottomPad_Widget(const iWidget *d) {
+    return d->padding[3];
+}
+iLocalDef iInt2 tlPad_Widget(const iWidget *d) {
+    return init_I2(leftPad_Widget(d), topPad_Widget(d));
+}
+iLocalDef iInt2 brPad_Widget(const iWidget *d) {
+    return init_I2(rightPad_Widget(d), bottomPad_Widget(d));
+}
 iLocalDef iObjectList *children_Widget(iAnyObject *d) {
     if (d == NULL) return NULL;
     iAssert(isInstance_Object(d, &Class_Widget));
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/edd6555da303a6eb6fc6dc4132a5094625ba27e9
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
57.184346 milliseconds
Gemini-to-HTML Time
0.255011 milliseconds

This content has been proxied by September (ba2dc).