From 1b716d38a4d7355ded5e495fcfb9a0e45e5fc83f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Mon, 28 Mar 2022 14:31:39 +0300
Subject: [PATCH 1/1] Mobile: Fixed layout issues
The top URL bar should never be animated.
Centered widgets shouldn't be placed outside the root area, if they can fit inside.
src/ui/inputwidget.c | 2 +-
src/ui/root.c | 2 +-
src/ui/widget.c | 31 +++++++++++++++++++++++++++----
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 49918152..de09db47 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -2302,7 +2302,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
else if (isCommand_UserEvent(ev, "keyboard.changed")) {
const iBool isKeyboardVisible = (arg_Command(command_UserEvent(ev)) != 0);
/* Scroll to keep widget visible when keyboard appears. */
if (isFocused_Widget(d)) {
if (isFocused_Widget(d) && findOverflowScrollable_Widget(parent_Widget(d))) {
if (isKeyboardVisible) {
d->lastOverflowScrollTime = SDL_GetTicks();
overflowScrollToKeepVisible_InputWidget_(d);
diff --git a/src/ui/root.c b/src/ui/root.c
index 9bbfe0d9..5d3e436d 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -1120,7 +1120,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
}
else if (deviceType_App() == tablet_AppDeviceType && equal_Command(cmd, "keyboard.changed")) {
const int keyboardHeight = arg_Command(cmd);
if (focus_Widget() == findChild_Widget(navBar, "url")) {
if (focus_Widget() == findChild_Widget(navBar, "url") && prefs_App()->bottomNavBar) {
setVisualOffset_Widget(navBar, -keyboardHeight + bottomSafeInset_Mobile(),
400, easeOut_AnimFlag | softer_AnimFlag);
}
diff --git a/src/ui/widget.c b/src/ui/widget.c
index dbf992aa..d1e139e6 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -519,10 +519,10 @@ static size_t numArrangedChildren_Widget_(const iWidget *d) {
}
static void centerHorizontal_Widget_(iWidget *d) {
: size_Root(d->root).x) -
width_Rect(d->rect)) /
2;
: size_Root(d->root).x;
TRACE(d, "center horizontally: %d", d->rect.pos.x);
}
@@ -922,6 +922,28 @@ static void notifySizeChanged_Widget_(iWidget *d) {
}
}
+static void clampCenteredInRoot_Widget_(iWidget *d) {
area, because the parent sizes and positions may change. */
iRect rootRect = safeRect_Root(d->root);
iRect bounds = boundsWithoutVisualOffset_Widget(d);
if (width_Rect(bounds) <= width_Rect(rootRect)) {
int excess = left_Rect(rootRect) - left_Rect(bounds);
if (excess > 0) {
d->rect.pos.x += excess;
}
excess = right_Rect(bounds) - right_Rect(rootRect);
if (excess > 0) {
d->rect.pos.x -= excess;
}
}
clampCenteredInRoot_Widget_(i.object);
+}
void arrange_Widget(iWidget *d) {
if (d) {
#if !defined (NDEBUG)
@@ -931,6 +953,7 @@ void arrange_Widget(iWidget *d) {
#endif
resetArrangement_Widget_(d); /* back to initial default sizes */
arrange_Widget_(d);
clampCenteredInRoot_Widget_(d);
notifySizeChanged_Widget_(d);
d->root->didChangeArrangement = iTrue;
}
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).