diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-10 10:06:46 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-10 10:06:46 +0200 |
commit | 680b72de4185527baea76ee8ce3cc4c2145069a5 (patch) | |
tree | 4389d2103f1e20dffdf816cddadebae9a916e28d | |
parent | 9741611c08d0f481a3f0583419b68b36d8711d1d (diff) |
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.
-rw-r--r-- | src/ui/mobile.c | 13 |
1 files changed, 11 insertions, 2 deletions
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) { | |||
41 | return deviceType_App() != desktop_AppDeviceType; | 41 | return deviceType_App() != desktop_AppDeviceType; |
42 | } | 42 | } |
43 | 43 | ||
44 | #define sidebarMinWidth_Mobile (80 * gap_UI) | ||
45 | |||
44 | static iBool isSideBySideLayout_(void) { | 46 | static iBool isSideBySideLayout_(void) { |
47 | /* Minimum is an even split. */ | ||
48 | const int safeWidth = safeRect_Root(get_Root()).size.x; | ||
49 | if (safeWidth / 2 < sidebarMinWidth_Mobile) { | ||
50 | return iFalse; | ||
51 | } | ||
45 | if (deviceType_App() == phone_AppDeviceType) { | 52 | if (deviceType_App() == phone_AppDeviceType) { |
46 | return isLandscape_App(); | 53 | return isLandscape_App(); |
47 | } | 54 | } |
55 | /* Tablet may still be too narrow. */ | ||
48 | return numRoots_Window(get_Window()) == 1; | 56 | return numRoots_Window(get_Window()) == 1; |
49 | } | 57 | } |
50 | 58 | ||
@@ -128,8 +136,9 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) | |||
128 | const int pad = isPortrait ? 0 : 3 * gap_UI; | 136 | const int pad = isPortrait ? 0 : 3 * gap_UI; |
129 | if (isSideBySide) { | 137 | if (isSideBySide) { |
130 | iAssert(topPanel); | 138 | iAssert(topPanel); |
131 | topPanel->rect.size.x = (deviceType_App() == phone_AppDeviceType ? | 139 | topPanel->rect.size.x = iMax(sidebarMinWidth_Mobile, |
132 | safeRoot.size.x * 2 / 5 : (safeRoot.size.x / 3)); | 140 | (deviceType_App() == phone_AppDeviceType ? |
141 | safeRoot.size.x * 2 / 5 : safeRoot.size.x / 3)); | ||
133 | } | 142 | } |
134 | if (deviceType_App() == tablet_AppDeviceType) { | 143 | if (deviceType_App() == tablet_AppDeviceType) { |
135 | setPadding_Widget(topPanel, pad, 0, pad, pad); | 144 | setPadding_Widget(topPanel, pad, 0, pad, pad); |