summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-02 07:42:51 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-02 07:42:51 +0200
commitedd6555da303a6eb6fc6dc4132a5094625ba27e9 (patch)
tree233ab0524a1a0457dfaccfb3a9066b8c4e135ba6 /src
parentffdbd9444fc436c6f85412da45fa76d6147044f3 (diff)
Mobile: Taller portrait phone navbar
The navbar is an important tap target, so it should be the same height as most menu items and the toolbar.
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwidget.c9
-rw-r--r--src/ui/root.c26
-rw-r--r--src/ui/widget.h18
3 files changed, 31 insertions, 22 deletions
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
59static const iChar sensitiveChar_ = 0x25cf; /* black circle */ 59static const iChar sensitiveChar_ = 0x25cf; /* black circle */
60static const char * sensitive_ = "\u25cf"; 60static const char * sensitive_ = "\u25cf";
61 61
62#define extraPaddingHeight_ ((isPortraitPhone_App() ? 3.0f : 1.25f) * gap_UI) /* phone: proper tap target */
63#define minWidth_InputWidget_ (3 * gap_UI)
64
62static void enableEditorKeysInMenus_(iBool enable) { 65static void enableEditorKeysInMenus_(iBool enable) {
63#if defined (iPlatformAppleDesktop) 66#if defined (iPlatformAppleDesktop)
64 enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable); 67 enableMenuItemsByKey_MacOS(SDLK_LEFT, KMOD_PRIMARY, enable);
@@ -228,7 +231,7 @@ struct Impl_InputWidget {
228 size_t maxLen; /* characters */ 231 size_t maxLen; /* characters */
229 iString srcHint; 232 iString srcHint;
230 iString hint; 233 iString hint;
231 int leftPadding; 234 int leftPadding; /* additional padding between frame and content */
232 int rightPadding; 235 int rightPadding;
233 int minWrapLines, maxWrapLines; /* min/max number of visible lines allowed */ 236 int minWrapLines, maxWrapLines; /* min/max number of visible lines allowed */
234 iRangei visWrapLines; /* which wrap lines are current visible */ 237 iRangei visWrapLines; /* which wrap lines are current visible */
@@ -359,8 +362,6 @@ static const iInputLine *line_InputWidget_(const iInputWidget *d, size_t index)
359 362
360#endif /* !LAGRANGE_USE_SYSTEM_TEXT_INPUT */ 363#endif /* !LAGRANGE_USE_SYSTEM_TEXT_INPUT */
361 364
362#define extraPaddingHeight_ (1.25f * gap_UI)
363
364static iRect contentBounds_InputWidget_(const iInputWidget *d) { 365static iRect contentBounds_InputWidget_(const iInputWidget *d) {
365 const iWidget *w = constAs_Widget(d); 366 const iWidget *w = constAs_Widget(d);
366 iRect bounds = adjusted_Rect(bounds_Widget(w), 367 iRect bounds = adjusted_Rect(bounds_Widget(w),
@@ -374,8 +375,6 @@ static iRect contentBounds_InputWidget_(const iInputWidget *d) {
374 return bounds; 375 return bounds;
375} 376}
376 377
377#define minWidth_InputWidget_ (3 * gap_UI)
378
379static iWrapText wrap_InputWidget_(const iInputWidget *d, int y) { 378static iWrapText wrap_InputWidget_(const iInputWidget *d, int y) {
380#if LAGRANGE_USE_SYSTEM_TEXT_INPUT 379#if LAGRANGE_USE_SYSTEM_TEXT_INPUT
381 iUnused(y); /* full text is wrapped always */ 380 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) {
650 650
651void updatePadding_Root(iRoot *d) { 651void updatePadding_Root(iRoot *d) {
652 if (d == NULL) return; 652 if (d == NULL) return;
653 iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
654 float bottom = 0.0f;
655#if defined (iPlatformAppleMobile) 653#if defined (iPlatformAppleMobile)
654 iWidget *toolBar = findChild_Widget(d->widget, "toolbar");
656 float left, top, right; 655 float left, top, right;
656 float bottom = 0.0f;
657 safeAreaInsets_iOS(&left, &top, &right, &bottom); 657 safeAreaInsets_iOS(&left, &top, &right, &bottom);
658 /* Respect the safe area insets. */ { 658 /* Respect the safe area insets. */ {
659 setPadding_Widget(findChild_Widget(d->widget, "navdiv"), left, top, right, 0); 659 setPadding_Widget(findChild_Widget(d->widget, "navdiv"), left, top, right, 0);
@@ -662,15 +662,6 @@ void updatePadding_Root(iRoot *d) {
662 } 662 }
663 } 663 }
664#endif 664#endif
665// if (toolBar) {
666 /* TODO: get this from toolBar height, but it's buggy for some reason */
667// const int sidebarBottomPad = isPortrait_App() ? 11 * gap_UI + bottom : 0;
668// setPadding_Widget(findChild_Widget(d->widget, "sidebar"), 0, 0, 0, sidebarBottomPad);
669 //setPadding_Widget(findChild_Widget(d->widget, "sidebar2"), 0, 0, 0, sidebarBottomPad);
670 /* TODO: There seems to be unrelated layout glitch in the sidebar where its children
671 are not arranged correctly until it's hidden and reshown. */
672// }
673 /* Note that `handleNavBarCommands_` also adjusts padding and spacing. */
674} 665}
675 666
676void updateToolbarColors_Root(iRoot *d) { 667void updateToolbarColors_Root(iRoot *d) {
@@ -773,9 +764,8 @@ static void updateNavBarSize_(iWidget *navBar) {
773 const iBool isPhone = deviceType_App() == phone_AppDeviceType; 764 const iBool isPhone = deviceType_App() == phone_AppDeviceType;
774 const iBool isNarrow = !isPhone && isNarrow_Root(navBar->root); 765 const iBool isNarrow = !isPhone && isNarrow_Root(navBar->root);
775 /* Adjust navbar padding. */ { 766 /* Adjust navbar padding. */ {
776 int hPad = isPhone && isPortrait_App() ? 0 : (isPhone || isNarrow) ? gap_UI / 2 767 int hPad = isPortraitPhone_App() ? 0 : isPhone || isNarrow ? gap_UI / 2 : (gap_UI * 3 / 2);
777 : gap_UI * 3 / 2; 768 int vPad = gap_UI * 3 / 2;
778 int vPad = gap_UI * 3 / 2;
779 int topPad = !findWidget_Root("winbar") ? gap_UI / 2 : 0; 769 int topPad = !findWidget_Root("winbar") ? gap_UI / 2 : 0;
780 setPadding_Widget(navBar, hPad, vPad / 3 + topPad, hPad, vPad / 2); 770 setPadding_Widget(navBar, hPad, vPad / 3 + topPad, hPad, vPad / 2);
781 } 771 }
@@ -1162,7 +1152,7 @@ void updateMetrics_Root(iRoot *d) {
1162 iWidget *urlButtons = findChild_Widget(navBar, "url.buttons"); 1152 iWidget *urlButtons = findChild_Widget(navBar, "url.buttons");
1163 iLabelWidget *idName = findChild_Widget(d->widget, "toolbar.name"); 1153 iLabelWidget *idName = findChild_Widget(d->widget, "toolbar.name");
1164 setPadding_Widget(as_Widget(url), 0, gap_UI, 0, gap_UI); 1154 setPadding_Widget(as_Widget(url), 0, gap_UI, 0, gap_UI);
1165 navBar->rect.size.y = 0; /* recalculate height based on children (FIXME: shouldn't be needed) */ 1155// navBar->rect.size.y = 0; /* recalculate height based on children (FIXME: shouldn't be needed) */
1166 setFixedSize_Widget(embedPad, init_I2(width_Widget(urlButtons) + gap_UI / 2, 1)); 1156 setFixedSize_Widget(embedPad, init_I2(width_Widget(urlButtons) + gap_UI / 2, 1));
1167 rightEmbed->rect.pos.y = gap_UI; 1157 rightEmbed->rect.pos.y = gap_UI;
1168 updatePadding_Root(d); 1158 updatePadding_Root(d);
@@ -1403,13 +1393,15 @@ void createUserInterface_Root(iRoot *d) {
1403 setFont_LabelWidget(pageMenuButton, uiContentBold_FontId); 1393 setFont_LabelWidget(pageMenuButton, uiContentBold_FontId);
1404 setAlignVisually_LabelWidget(pageMenuButton, iTrue); 1394 setAlignVisually_LabelWidget(pageMenuButton, iTrue);
1405 addChildFlags_Widget(urlButtons, iClob(pageMenuButton), 1395 addChildFlags_Widget(urlButtons, iClob(pageMenuButton),
1406 embedFlags | tight_WidgetFlag | collapse_WidgetFlag); 1396 embedFlags | tight_WidgetFlag | collapse_WidgetFlag |
1397 resizeToParentHeight_WidgetFlag);
1407 updateSize_LabelWidget(pageMenuButton); 1398 updateSize_LabelWidget(pageMenuButton);
1408 } 1399 }
1409 /* Reload button. */ { 1400 /* Reload button. */ {
1410 iLabelWidget *reload = newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"); 1401 iLabelWidget *reload = newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload");
1411 setId_Widget(as_Widget(reload), "reload"); 1402 setId_Widget(as_Widget(reload), "reload");
1412 addChildFlags_Widget(urlButtons, iClob(reload), embedFlags | collapse_WidgetFlag); 1403 addChildFlags_Widget(urlButtons, iClob(reload), embedFlags | collapse_WidgetFlag |
1404 resizeToParentHeight_WidgetFlag);
1413 updateSize_LabelWidget(reload); 1405 updateSize_LabelWidget(reload);
1414 } 1406 }
1415 addChildFlags_Widget(as_Widget(url), iClob(urlButtons), moveToParentRightEdge_WidgetFlag); 1407 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) {
237 } 237 }
238 return 0; 238 return 0;
239} 239}
240iLocalDef int leftPad_Widget(const iWidget *d) {
241 return d->padding[0];
242}
243iLocalDef int topPad_Widget(const iWidget *d) {
244 return d->padding[1];
245}
246iLocalDef int rightPad_Widget(const iWidget *d) {
247 return d->padding[2];
248}
249iLocalDef int bottomPad_Widget(const iWidget *d) {
250 return d->padding[3];
251}
252iLocalDef iInt2 tlPad_Widget(const iWidget *d) {
253 return init_I2(leftPad_Widget(d), topPad_Widget(d));
254}
255iLocalDef iInt2 brPad_Widget(const iWidget *d) {
256 return init_I2(rightPad_Widget(d), bottomPad_Widget(d));
257}
240iLocalDef iObjectList *children_Widget(iAnyObject *d) { 258iLocalDef iObjectList *children_Widget(iAnyObject *d) {
241 if (d == NULL) return NULL; 259 if (d == NULL) return NULL;
242 iAssert(isInstance_Object(d, &Class_Widget)); 260 iAssert(isInstance_Object(d, &Class_Widget));