diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-17 22:00:22 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-17 22:00:22 +0300 |
commit | bf76c112bc5aaacdc52c13743d6624cb79c74e9b (patch) | |
tree | d122f3b6e37f2936b0d1614ba45484d69b0b6b08 /src/ui | |
parent | 65b05dd2633a962fad1e858fc8c0379d55960753 (diff) |
Mobile: Tablet layout improvements
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/mobile.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c index 423e8cb5..1f5e9758 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c | |||
@@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
30 | #include "root.h" | 30 | #include "root.h" |
31 | #include "text.h" | 31 | #include "text.h" |
32 | #include "widget.h" | 32 | #include "widget.h" |
33 | #include "window.h" | ||
33 | 34 | ||
34 | #if defined (iPlatformAppleMobile) | 35 | #if defined (iPlatformAppleMobile) |
35 | # include "ios.h" | 36 | # include "ios.h" |
@@ -39,6 +40,13 @@ static iBool useMobileSheetLayout_(void) { | |||
39 | return deviceType_App() != desktop_AppDeviceType; | 40 | return deviceType_App() != desktop_AppDeviceType; |
40 | } | 41 | } |
41 | 42 | ||
43 | static iBool isSideBySideLayout_(void) { | ||
44 | if (deviceType_App() == phone_AppDeviceType) { | ||
45 | return isLandscape_App(); | ||
46 | } | ||
47 | return numRoots_Window(get_Window()) == 1; | ||
48 | } | ||
49 | |||
42 | static enum iFontId labelFont_(void) { | 50 | static enum iFontId labelFont_(void) { |
43 | return deviceType_App() == phone_AppDeviceType ? defaultBig_FontId : defaultMedium_FontId; | 51 | return deviceType_App() == phone_AppDeviceType ? defaultBig_FontId : defaultMedium_FontId; |
44 | } | 52 | } |
@@ -89,7 +97,7 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) | |||
89 | iWidget * navi = findChild_Widget(sheet, "panel.navi"); | 97 | iWidget * navi = findChild_Widget(sheet, "panel.navi"); |
90 | iWidget * detailStack = findChild_Widget(mainDetailSplit, "detailstack"); | 98 | iWidget * detailStack = findChild_Widget(mainDetailSplit, "detailstack"); |
91 | const size_t numPanels = childCount_Widget(detailStack); | 99 | const size_t numPanels = childCount_Widget(detailStack); |
92 | const iBool isSideBySide = !isPortrait && numPanels > 0; | 100 | const iBool isSideBySide = isSideBySideLayout_() && numPanels > 0; |
93 | setFlags_Widget(mainDetailSplit, arrangeHorizontal_WidgetFlag, isSideBySide); | 101 | setFlags_Widget(mainDetailSplit, arrangeHorizontal_WidgetFlag, isSideBySide); |
94 | setFlags_Widget(detailStack, expand_WidgetFlag, isSideBySide); | 102 | setFlags_Widget(detailStack, expand_WidgetFlag, isSideBySide); |
95 | setFlags_Widget(detailStack, hidden_WidgetFlag, numPanels == 0); | 103 | setFlags_Widget(detailStack, hidden_WidgetFlag, numPanels == 0); |
@@ -112,8 +120,8 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) | |||
112 | } | 120 | } |
113 | iForEach(ObjectList, i, children_Widget(detailStack)) { | 121 | iForEach(ObjectList, i, children_Widget(detailStack)) { |
114 | iWidget *panel = i.object; | 122 | iWidget *panel = i.object; |
115 | setFlags_Widget(panel, edgeDraggable_WidgetFlag, isPortrait); | 123 | setFlags_Widget(panel, edgeDraggable_WidgetFlag, !isSideBySide); |
116 | if (!isPortrait) { | 124 | if (isSideBySide) { |
117 | setVisualOffset_Widget(panel, 0, 0, 0); | 125 | setVisualOffset_Widget(panel, 0, 0, 0); |
118 | } | 126 | } |
119 | setPadding_Widget(panel, pad, 0, pad, pad); | 127 | setPadding_Widget(panel, pad, 0, pad, pad); |
@@ -124,7 +132,7 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) | |||
124 | } | 132 | } |
125 | 133 | ||
126 | static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | 134 | static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { |
127 | const iBool isPortrait = useMobileSheetLayout_() && isPortrait_App(); | 135 | const iBool isPortrait = !isSideBySideLayout_(); |
128 | if (equal_Command(cmd, "panel.open")) { | 136 | if (equal_Command(cmd, "panel.open")) { |
129 | iWidget *button = pointer_Command(cmd); | 137 | iWidget *button = pointer_Command(cmd); |
130 | iWidget *panel = userData_Object(button); | 138 | iWidget *panel = userData_Object(button); |
@@ -149,7 +157,7 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | |||
149 | } | 157 | } |
150 | if (equal_Command(cmd, "panel.close")) { | 158 | if (equal_Command(cmd, "panel.close")) { |
151 | iBool wasClosed = iFalse; | 159 | iBool wasClosed = iFalse; |
152 | if (isPortrait_App()) { | 160 | if (isPortrait) { |
153 | iForEach(ObjectList, i, children_Widget(findDetailStack_(topPanel))) { | 161 | iForEach(ObjectList, i, children_Widget(findDetailStack_(topPanel))) { |
154 | iWidget *child = i.object; | 162 | iWidget *child = i.object; |
155 | if (!cmp_String(id_Widget(child), "panel") && isVisible_Widget(child)) { | 163 | if (!cmp_String(id_Widget(child), "panel") && isVisible_Widget(child)) { |
@@ -366,22 +374,22 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
366 | postRefresh_App(); | 374 | postRefresh_App(); |
367 | return; | 375 | return; |
368 | } | 376 | } |
369 | /* Landscape Layout Portrait Layout | 377 | /* Landscape Layout Portrait Layout |
370 | 378 | ||
371 | ┌─────────┬──────Detail─Stack─────┐ ┌─────────┬ ─ ─ ─ ─ ┐ | 379 | ┌─────────┬──────Detail─Stack─────┐ ┌─────────┬ ─ ─ ─ ─ ┐ |
372 | │ │┌───────────────────┐ │ │ │Detail | 380 | │ │┌───────────────────┐ │ │ │Detail |
373 | │ ││┌──────────────────┴┐ │ │ │Stack │ | 381 | │ ││┌──────────────────┴┐ │ │ │Stack │ |
374 | │ │││┌──────────────────┴┐│ │ │┌──────┐ | 382 | │ │││┌──────────────────┴┐│ │ │┌──────┐ |
375 | │ ││││ ││ │ ││┌─────┴┐│ | 383 | │ ││││ ││ │ ││┌─────┴┐│ |
376 | │ ││││ ││ │ │││ │ | 384 | │ ││││ ││ │ │││ │ |
377 | │Top Panel││││ ││ │Top Panel│││ ││ | 385 | │Top Panel││││ ││ │Top Panel│││ ││ |
378 | │ ││││ Panels ││ │ │││Panels│ | 386 | │ ││││ Panels ││ │ │││Panels│ |
379 | │ ││││ ││ │ │││ ││ | 387 | │ ││││ ││ │ │││ ││ |
380 | │ │└┤│ ││ │ │││ │ | 388 | │ │└┤│ ││ │ │││ │ |
381 | │ │ └┤ ││ │ │└┤ ││ | 389 | │ │ └┤ ││ │ │└┤ ││ |
382 | │ │ └───────────────────┘│ │ │ └──────┘ | 390 | │ │ └───────────────────┘│ │ │ └──────┘ |
383 | └─────────┴───────────────────────┘ └─────────┴ ─ ─ ─ ─ ┘ | 391 | └─────────┴───────────────────────┘ └─────────┴ ─ ─ ─ ─ ┘ |
384 | offscreen | 392 | offscreen |
385 | */ | 393 | */ |
386 | /* Modify the top sheet to act as a fullscreen background. */ | 394 | /* Modify the top sheet to act as a fullscreen background. */ |
387 | setPadding1_Widget(sheet, 0); | 395 | setPadding1_Widget(sheet, 0); |
@@ -732,7 +740,7 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
732 | arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | | 740 | arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | |
733 | resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag); | 741 | resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag); |
734 | } | 742 | } |
735 | if (isPrefs && isLandscape_App()) { | 743 | if (isPrefs && isSideBySideLayout_()) { |
736 | /* Show the General panel. */ | 744 | /* Show the General panel. */ |
737 | postCommand_Widget(at_PtrArray(panelButtons, 0), "panel.open"); | 745 | postCommand_Widget(at_PtrArray(panelButtons, 0), "panel.open"); |
738 | } | 746 | } |
@@ -770,7 +778,7 @@ void setupMenuTransition_Mobile(iWidget *sheet, iBool isIncoming) { | |||
770 | } | 778 | } |
771 | 779 | ||
772 | void setupSheetTransition_Mobile(iWidget *sheet, iBool isIncoming) { | 780 | void setupSheetTransition_Mobile(iWidget *sheet, iBool isIncoming) { |
773 | if (deviceType_App() != phone_AppDeviceType || isLandscape_App()) { | 781 | if (isSideBySideLayout_()) { |
774 | return; | 782 | return; |
775 | } | 783 | } |
776 | if (isIncoming) { | 784 | if (isIncoming) { |