From 680b72de4185527baea76ee8ce3cc4c2145069a5 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 10 Dec 2021 10:06:46 +0200 Subject: Mobile: Minimum width for the top dialog panel The top panel should not be too narrow, and if it doesn't fit, fall back to a layered page view. --- src/ui/mobile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/ui/mobile.c') diff --git a/src/ui/mobile.c b/src/ui/mobile.c index 64a5a7cc..9bb55132 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c @@ -41,10 +41,18 @@ iBool isUsingPanelLayout_Mobile(void) { return deviceType_App() != desktop_AppDeviceType; } +#define sidebarMinWidth_Mobile (80 * gap_UI) + static iBool isSideBySideLayout_(void) { + /* Minimum is an even split. */ + const int safeWidth = safeRect_Root(get_Root()).size.x; + if (safeWidth / 2 < sidebarMinWidth_Mobile) { + return iFalse; + } if (deviceType_App() == phone_AppDeviceType) { return isLandscape_App(); } + /* Tablet may still be too narrow. */ return numRoots_Window(get_Window()) == 1; } @@ -128,8 +136,9 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) const int pad = isPortrait ? 0 : 3 * gap_UI; if (isSideBySide) { iAssert(topPanel); - topPanel->rect.size.x = (deviceType_App() == phone_AppDeviceType ? - safeRoot.size.x * 2 / 5 : (safeRoot.size.x / 3)); + topPanel->rect.size.x = iMax(sidebarMinWidth_Mobile, + (deviceType_App() == phone_AppDeviceType ? + safeRoot.size.x * 2 / 5 : safeRoot.size.x / 3)); } if (deviceType_App() == tablet_AppDeviceType) { setPadding_Widget(topPanel, pad, 0, pad, pad); -- cgit v1.2.3