From 8026b29755cde294ed1db34dd254bba4d0d0b381 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 18 May 2021 08:53:28 +0300 Subject: Root: Updating size of navbar buttons/indicators Not all UI elements were appropriate sized when switching between normal and tight layout. --- src/ui/root.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/ui/root.c') diff --git a/src/ui/root.c b/src/ui/root.c index 6cf3f424..8c98bdd3 100644 --- a/src/ui/root.c +++ b/src/ui/root.c @@ -583,20 +583,22 @@ static void updateNavBarSize_(iWidget *navBar) { /* Button sizing. */ if (isNarrow ^ ((flags_Widget(navBar) & tight_WidgetFlag) != 0)) { setFlags_Widget(navBar, tight_WidgetFlag, isNarrow); - iForEach(ObjectList, i, navBar->children) { - iWidget *child = as_Widget(i.object); - setFlags_Widget(child, tight_WidgetFlag, isNarrow); - if (isInstance_Object(i.object, &Class_LabelWidget)) { - iLabelWidget *label = i.object; - updateSize_LabelWidget(label); + iObjectList *lists[] = { + children_Widget(navBar), + children_Widget(findChild_Widget(navBar, "url")), + children_Widget(findChild_Widget(navBar, "url.buttons")), + }; + iForIndices(k, lists) { + iForEach(ObjectList, i, lists[k]) { + iWidget *child = as_Widget(i.object); + setFlags_Widget(child, tight_WidgetFlag, isNarrow); + if (isInstance_Object(i.object, &Class_LabelWidget)) { + iLabelWidget *label = i.object; + updateSize_LabelWidget(label); + } } } updateUrlInputContentPadding_(navBar); - /* Note that InputWidget uses the `tight` flag to adjust its inner padding. */ -// const int embedButtonWidth = width_Widget(findChild_Widget(navBar, "navbar.lock")); -// setContentPadding_InputWidget(findChild_Widget(navBar, "url"), -// embedButtonWidth * 0.75f, -// embedButtonWidth * 0.75f); } if (isPhone) { static const char *buttons[] = { "navbar.back", "navbar.forward", "navbar.sidebar", @@ -620,7 +622,8 @@ static void updateNavBarSize_(iWidget *navBar) { urlBar->rect.size.x = iMini(navBarAvailableSpace_(navBar), 167 * gap_UI); arrange_Widget(navBar); } - refresh_Widget(navBar); + updateMetrics_Root(navBar->root); /* tight flags changed; need to resize URL bar contents */ +// refresh_Widget(navBar); postCommand_Widget(navBar, "layout.changed id:navbar"); } @@ -1086,7 +1089,9 @@ void createUserInterface_Root(iRoot *d) { setNoAutoMinHeight_LabelWidget(pin, iTrue); addChildFlags_Widget(rightEmbed, iClob(pin), - collapse_WidgetFlag | hidden_WidgetFlag | tight_WidgetFlag | frameless_WidgetFlag); + collapse_WidgetFlag | hidden_WidgetFlag | tight_WidgetFlag | + frameless_WidgetFlag); + updateSize_LabelWidget(pin); } iWidget *urlButtons = new_Widget(); setId_Widget(urlButtons, "url.buttons"); -- cgit v1.2.3