summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-14 13:45:19 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-14 13:45:19 +0300
commit8fcd270e6e74d3b8099c2f7f86d803def9070eb9 (patch)
tree6a6fc901a95debc45a424423f547b4addf62e511
parent8001693820cecae38be4f4829eaed04893016f80 (diff)
Mobile: Landscape panel title layout
-rw-r--r--src/ui/mobile.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index 4c183ffa..459e9ce7 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -88,6 +88,17 @@ static void unselectAllPanelButtons_(iWidget *topPanel) {
88 } 88 }
89} 89}
90 90
91static iWidget *findTitleLabel_(iWidget *panel) {
92 iForEach(ObjectList, i, children_Widget(panel)) {
93 iWidget *child = i.object;
94 if (flags_Widget(child) & collapse_WidgetFlag &&
95 isInstance_Object(child, &Class_LabelWidget)) {
96 return child;
97 }
98 }
99 return NULL;
100}
101
91static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) { 102static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) {
92 if (equal_Command(cmd, "window.resized")) { 103 if (equal_Command(cmd, "window.resized")) {
93 const iBool isPortrait = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); 104 const iBool isPortrait = (deviceType_App() == phone_AppDeviceType && isPortrait_App());
@@ -108,7 +119,7 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd)
108 iAssert(topPanel); 119 iAssert(topPanel);
109 topPanel->rect.size.x = (deviceType_App() == phone_AppDeviceType ? 120 topPanel->rect.size.x = (deviceType_App() == phone_AppDeviceType ?
110 safeRoot.size.x * 2 / 5 : (safeRoot.size.x / 3)); 121 safeRoot.size.x * 2 / 5 : (safeRoot.size.x / 3));
111 } 122 }
112 if (deviceType_App() == tablet_AppDeviceType) { 123 if (deviceType_App() == tablet_AppDeviceType) {
113 setPadding_Widget(topPanel, pad, 0, pad, pad); 124 setPadding_Widget(topPanel, pad, 0, pad, pad);
114 if (numPanels == 0) { 125 if (numPanels == 0) {
@@ -119,8 +130,15 @@ static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd)
119 setFixedSize_Widget(navi, init_I2(sheetWidth, -1)); 130 setFixedSize_Widget(navi, init_I2(sheetWidth, -1));
120 } 131 }
121 } 132 }
133 iWidget *detailTitle = findChild_Widget(navi, "detailtitle"); {
134 setPos_Widget(detailTitle, init_I2(width_Widget(topPanel), 0));
135 setFixedSize_Widget(detailTitle,
136 init_I2(width_Widget(detailStack), height_Widget(navi)));
137 setFlags_Widget(detailTitle, hidden_WidgetFlag, !isSideBySide);
138 }
122 iForEach(ObjectList, i, children_Widget(detailStack)) { 139 iForEach(ObjectList, i, children_Widget(detailStack)) {
123 iWidget *panel = i.object; 140 iWidget *panel = i.object;
141 setFlags_Widget(findTitleLabel_(panel), hidden_WidgetFlag, isSideBySide);
124 setFlags_Widget(panel, leftEdgeDraggable_WidgetFlag, !isSideBySide); 142 setFlags_Widget(panel, leftEdgeDraggable_WidgetFlag, !isSideBySide);
125 if (isSideBySide) { 143 if (isSideBySide) {
126 setVisualOffset_Widget(panel, 0, 0, 0); 144 setVisualOffset_Widget(panel, 0, 0, 0);
@@ -154,6 +172,12 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) {
154 setupSheetTransition_Mobile(panel, iTrue); 172 setupSheetTransition_Mobile(panel, iTrue);
155 } 173 }
156 } 174 }
175 iLabelWidget *detailTitle =
176 findChild_Widget(parent_Widget(parent_Widget(topPanel)), "detailtitle");
177// setFlags_Widget(as_Widget(detailTitle), hidden_WidgetFlag, !isSideBySideLayout_());
178 setFont_LabelWidget(detailTitle, uiLabelLargeBold_FontId);
179 setTextColor_LabelWidget(detailTitle, uiHeading_ColorId);
180 setText_LabelWidget(detailTitle, text_LabelWidget((iLabelWidget *) findTitleLabel_(panel)));
157 setFlags_Widget(button, selected_WidgetFlag, iTrue); 181 setFlags_Widget(button, selected_WidgetFlag, iTrue);
158 return iTrue; 182 return iTrue;
159 } 183 }
@@ -430,7 +454,8 @@ void makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {
430 if (equal_Command(spec, "title")) { 454 if (equal_Command(spec, "title")) {
431 iLabelWidget *title = addChildFlags_Widget(panel, 455 iLabelWidget *title = addChildFlags_Widget(panel,
432 iClob(new_LabelWidget(label, NULL)), 456 iClob(new_LabelWidget(label, NULL)),
433 alignLeft_WidgetFlag | frameless_WidgetFlag); 457 alignLeft_WidgetFlag | frameless_WidgetFlag |
458 collapse_WidgetFlag);
434 setFont_LabelWidget(title, uiLabelLargeBold_FontId); 459 setFont_LabelWidget(title, uiLabelLargeBold_FontId);
435 setTextColor_LabelWidget(title, uiHeading_ColorId); 460 setTextColor_LabelWidget(title, uiHeading_ColorId);
436 setAllCaps_LabelWidget(title, iTrue); 461 setAllCaps_LabelWidget(title, iTrue);
@@ -621,8 +646,9 @@ void initPanels_Mobile(iWidget *panels, iWidget *parentWidget,
621 setFlags_Widget(panels, 646 setFlags_Widget(panels,
622 resizeToParentWidth_WidgetFlag | resizeToParentHeight_WidgetFlag | 647 resizeToParentWidth_WidgetFlag | resizeToParentHeight_WidgetFlag |
623 frameless_WidgetFlag | focusRoot_WidgetFlag | commandOnClick_WidgetFlag | 648 frameless_WidgetFlag | focusRoot_WidgetFlag | commandOnClick_WidgetFlag |
624 overflowScrollable_WidgetFlag | leftEdgeDraggable_WidgetFlag, 649 /*overflowScrollable_WidgetFlag |*/ leftEdgeDraggable_WidgetFlag,
625 iTrue); 650 iTrue);
651 setFlags_Widget(panels, overflowScrollable_WidgetFlag, iFalse);
626 /* The top-level split between main and detail panels. */ 652 /* The top-level split between main and detail panels. */
627 iWidget *mainDetailSplit = makeHDiv_Widget(); { 653 iWidget *mainDetailSplit = makeHDiv_Widget(); {
628 setCommandHandler_Widget(mainDetailSplit, mainDetailSplitHandler_); 654 setCommandHandler_Widget(mainDetailSplit, mainDetailSplitHandler_);
@@ -657,12 +683,16 @@ void initPanels_Mobile(iWidget *panels, iWidget *parentWidget,
657 iWidget *navi = new_Widget(); { 683 iWidget *navi = new_Widget(); {
658 setId_Widget(navi, "panel.navi"); 684 setId_Widget(navi, "panel.navi");
659 setBackgroundColor_Widget(navi, uiBackground_ColorId); 685 setBackgroundColor_Widget(navi, uiBackground_ColorId);
660 addChild_Widget(navi, iClob(makePadding_Widget(0))); 686 setId_Widget(addChildFlags_Widget(navi,
687 iClob(new_LabelWidget("", NULL)),
688 alignLeft_WidgetFlag | fixedPosition_WidgetFlag |
689 fixedSize_WidgetFlag | hidden_WidgetFlag |
690 frameless_WidgetFlag),
691 "detailtitle");
661 naviBack = addChildFlags_Widget( 692 naviBack = addChildFlags_Widget(
662 navi, 693 navi,
663 iClob(newKeyMods_LabelWidget(leftAngle_Icon " ${panel.back}", 694 iClob(newKeyMods_LabelWidget(
664 SDLK_ESCAPE, 0, 695 leftAngle_Icon " ${panel.back}", SDLK_ESCAPE, 0, "panel.close")),
665 "panel.close")),
666 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | 696 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag |
667 extraPadding_WidgetFlag); 697 extraPadding_WidgetFlag);
668 checkIcon_LabelWidget(naviBack); 698 checkIcon_LabelWidget(naviBack);