diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/mobile.c | 70 | ||||
-rw-r--r-- | src/ui/mobile.h | 5 |
2 files changed, 68 insertions, 7 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c index ae503f77..1c7cad8e 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c | |||
@@ -56,16 +56,53 @@ static iWidget *findDetailStack_(iWidget *topPanel) { | |||
56 | return findChild_Widget(parent_Widget(topPanel), "detailstack"); | 56 | return findChild_Widget(parent_Widget(topPanel), "detailstack"); |
57 | } | 57 | } |
58 | 58 | ||
59 | static void unselectAllPanelButtons_(iWidget *topPanel) { | ||
60 | iForEach(ObjectList, i, children_Widget(topPanel)) { | ||
61 | if (isInstance_Object(i.object, &Class_LabelWidget)) { | ||
62 | iLabelWidget *label = i.object; | ||
63 | if (!cmp_String(command_LabelWidget(label), "panel.open")) { | ||
64 | setFlags_Widget(i.object, selected_WidgetFlag, iFalse); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | |||
70 | static iBool mainDetailSplitHandler_(iWidget *mainDetailSplit, const char *cmd) { | ||
71 | if (equal_Command(cmd, "window.resized")) { | ||
72 | const iBool isPortrait = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); | ||
73 | const iRect safeRoot = safeRect_Root(mainDetailSplit->root); | ||
74 | setPos_Widget(mainDetailSplit, topLeft_Rect(safeRoot)); | ||
75 | setFixedSize_Widget(mainDetailSplit, safeRoot.size); | ||
76 | setFlags_Widget(mainDetailSplit, arrangeHorizontal_WidgetFlag, !isPortrait); | ||
77 | iForEach(ObjectList, i, children_Widget(findChild_Widget(mainDetailSplit, "detailstack"))) { | ||
78 | iWidget *panel = i.object; | ||
79 | setFlags_Widget(panel, edgeDraggable_WidgetFlag, isPortrait); | ||
80 | if (!isPortrait) { | ||
81 | setVisualOffset_Widget(panel, 0, 0, 0); | ||
82 | } | ||
83 | } | ||
84 | arrange_Widget(mainDetailSplit); | ||
85 | } | ||
86 | return iFalse; | ||
87 | } | ||
88 | |||
59 | static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | 89 | static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { |
90 | const iBool isPortrait = deviceType_App() == phone_AppDeviceType && isPortrait_App(); | ||
60 | if (equal_Command(cmd, "panel.open")) { | 91 | if (equal_Command(cmd, "panel.open")) { |
61 | iWidget *button = pointer_Command(cmd); | 92 | iWidget *button = pointer_Command(cmd); |
62 | iWidget *panel = userData_Object(button); | 93 | iWidget *panel = userData_Object(button); |
63 | // openMenu_Widget(panel, innerToWindow_Widget(panel, zero_I2())); | 94 | // openMenu_Widget(panel, innerToWindow_Widget(panel, zero_I2())); |
64 | // setFlags_Widget(panel, hidden_WidgetFlag, iFalse); | 95 | // setFlags_Widget(panel, hidden_WidgetFlag, iFalse); |
96 | unselectAllPanelButtons_(topPanel); | ||
65 | iForEach(ObjectList, i, children_Widget(findDetailStack_(topPanel))) { | 97 | iForEach(ObjectList, i, children_Widget(findDetailStack_(topPanel))) { |
66 | iWidget *child = i.object; | 98 | iWidget *child = i.object; |
67 | setFlags_Widget(child, hidden_WidgetFlag | disabled_WidgetFlag, child != panel); | 99 | setFlags_Widget(child, hidden_WidgetFlag | disabled_WidgetFlag, child != panel); |
100 | /* Animate the current panel in. */ | ||
101 | if (child == panel && isPortrait) { | ||
102 | setupSheetTransition_Mobile(panel, iTrue); | ||
103 | } | ||
68 | } | 104 | } |
105 | setFlags_Widget(button, selected_WidgetFlag, iTrue); | ||
69 | return iTrue; | 106 | return iTrue; |
70 | } | 107 | } |
71 | if (equal_Command(cmd, "mouse.clicked") && arg_Command(cmd) && | 108 | if (equal_Command(cmd, "mouse.clicked") && arg_Command(cmd) && |
@@ -76,10 +113,11 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | |||
76 | if (equal_Command(cmd, "panel.close")) { | 113 | if (equal_Command(cmd, "panel.close")) { |
77 | iBool wasClosed = iFalse; | 114 | iBool wasClosed = iFalse; |
78 | if (isPortrait_App()) { | 115 | if (isPortrait_App()) { |
79 | iForEach(ObjectList, i, children_Widget(parent_Widget(topPanel))) { | 116 | iForEach(ObjectList, i, children_Widget(findDetailStack_(topPanel))) { |
80 | iWidget *child = i.object; | 117 | iWidget *child = i.object; |
81 | if (!cmp_String(id_Widget(child), "panel") && isVisible_Widget(child)) { | 118 | if (!cmp_String(id_Widget(child), "panel") && isVisible_Widget(child)) { |
82 | // closeMenu_Widget(child); | 119 | // closeMenu_Widget(child); |
120 | setupSheetTransition_Mobile(child, iFalse); | ||
83 | setFlags_Widget(child, hidden_WidgetFlag | disabled_WidgetFlag, iTrue); | 121 | setFlags_Widget(child, hidden_WidgetFlag | disabled_WidgetFlag, iTrue); |
84 | setFocus_Widget(NULL); | 122 | setFocus_Widget(NULL); |
85 | updateTextCStr_LabelWidget(findWidget_App("panel.back"), "Back"); | 123 | updateTextCStr_LabelWidget(findWidget_App("panel.back"), "Back"); |
@@ -87,6 +125,7 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) { | |||
87 | } | 125 | } |
88 | } | 126 | } |
89 | } | 127 | } |
128 | unselectAllPanelButtons_(topPanel); | ||
90 | if (!wasClosed) { | 129 | if (!wasClosed) { |
91 | postCommand_App("prefs.dismiss"); | 130 | postCommand_App("prefs.dismiss"); |
92 | } | 131 | } |
@@ -271,8 +310,8 @@ static iWidget *addChildPanel_(iWidget *parent, iLabelWidget *panelButton, | |||
271 | focusRoot_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag | | 310 | focusRoot_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag | |
272 | arrangeVertical_WidgetFlag | resizeWidthOfChildren_WidgetFlag | | 311 | arrangeVertical_WidgetFlag | resizeWidthOfChildren_WidgetFlag | |
273 | arrangeHeight_WidgetFlag | overflowScrollable_WidgetFlag | | 312 | arrangeHeight_WidgetFlag | overflowScrollable_WidgetFlag | |
274 | //horizontalOffset_WidgetFlag | edgeDraggable_WidgetFlag | | 313 | drawBackgroundToBottom_WidgetFlag | |
275 | commandOnClick_WidgetFlag); | 314 | horizontalOffset_WidgetFlag | commandOnClick_WidgetFlag); |
276 | return panel; | 315 | return panel; |
277 | } | 316 | } |
278 | 317 | ||
@@ -321,7 +360,7 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
321 | iFalse); | 360 | iFalse); |
322 | setFlags_Widget(sheet, | 361 | setFlags_Widget(sheet, |
323 | frameless_WidgetFlag | | 362 | frameless_WidgetFlag | |
324 | resizeWidthOfChildren_WidgetFlag | | 363 | //resizeWidthOfChildren_WidgetFlag | |
325 | edgeDraggable_WidgetFlag | | 364 | edgeDraggable_WidgetFlag | |
326 | commandOnClick_WidgetFlag, | 365 | commandOnClick_WidgetFlag, |
327 | iTrue); | 366 | iTrue); |
@@ -333,6 +372,7 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
333 | const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag | | 372 | const int64_t panelButtonFlags = borderBottom_WidgetFlag | alignLeft_WidgetFlag | |
334 | frameless_WidgetFlag | extraPadding_WidgetFlag; | 373 | frameless_WidgetFlag | extraPadding_WidgetFlag; |
335 | iWidget *mainDetailSplit = makeHDiv_Widget(); | 374 | iWidget *mainDetailSplit = makeHDiv_Widget(); |
375 | setCommandHandler_Widget(mainDetailSplit, mainDetailSplitHandler_); | ||
336 | setFlags_Widget(mainDetailSplit, resizeHeightOfChildren_WidgetFlag, iFalse); | 376 | setFlags_Widget(mainDetailSplit, resizeHeightOfChildren_WidgetFlag, iFalse); |
337 | setId_Widget(mainDetailSplit, "mdsplit"); | 377 | setId_Widget(mainDetailSplit, "mdsplit"); |
338 | iWidget *topPanel = new_Widget(); { | 378 | iWidget *topPanel = new_Widget(); { |
@@ -521,7 +561,7 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
521 | } | 561 | } |
522 | addPanelChild_(owner, NULL, 0, 0, prevElement); | 562 | addPanelChild_(owner, NULL, 0, 0, prevElement); |
523 | destroy_Widget(pageContent); | 563 | destroy_Widget(pageContent); |
524 | setFlags_Widget(owner, drawBackgroundToBottom_WidgetFlag, iTrue); | 564 | // setFlags_Widget(owner, drawBackgroundToBottom_WidgetFlag, iTrue); |
525 | } | 565 | } |
526 | destroyPending_Root(sheet->root); | 566 | destroyPending_Root(sheet->root); |
527 | /* Additional elements for preferences. */ | 567 | /* Additional elements for preferences. */ |
@@ -653,6 +693,11 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
653 | arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | | 693 | arrangeHeight_WidgetFlag | resizeWidthOfChildren_WidgetFlag | |
654 | resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag); | 694 | resizeToParentWidth_WidgetFlag | arrangeVertical_WidgetFlag); |
655 | } | 695 | } |
696 | if (isPrefs && isLandscape_App()) { | ||
697 | /* Show the General panel. */ | ||
698 | postCommand_Widget(at_PtrArray(panelButtons, 0), "panel.open"); | ||
699 | } | ||
700 | mainDetailSplitHandler_(mainDetailSplit, "window.resized"); /* make it resize the split */ | ||
656 | updatePanelSheetMetrics_(sheet); | 701 | updatePanelSheetMetrics_(sheet); |
657 | iAssert(sheet->parent); | 702 | iAssert(sheet->parent); |
658 | arrange_Widget(sheet->parent); | 703 | arrange_Widget(sheet->parent); |
@@ -664,6 +709,21 @@ void finalizeSheet_Mobile(iWidget *sheet) { | |||
664 | postRefresh_App(); | 709 | postRefresh_App(); |
665 | } | 710 | } |
666 | 711 | ||
712 | #if 0 | ||
713 | void setupDetailPanelTransition_Mobile(iWidget *panel, iBool isIncoming) { | ||
714 | if (isIncoming || deviceType_App() != phone_AppDeviceType) { | ||
715 | setVisualOffset_Widget(panel, 0, 200, easeOut_AnimFlag | softer_AnimFlag); | ||
716 | } | ||
717 | else { | ||
718 | const iBool wasDragged = iAbs(value_Anim(&panel->visualOffset)) > -width_Widget(panel); | ||
719 | setVisualOffset_Widget(panel, | ||
720 | -width_Widget(panel), | ||
721 | wasDragged ? 100 : 200, | ||
722 | wasDragged ? 0 : easeOut_AnimFlag | softer_AnimFlag); | ||
723 | } | ||
724 | } | ||
725 | #endif | ||
726 | |||
667 | void setupMenuTransition_Mobile(iWidget *sheet, iBool isIncoming) { | 727 | void setupMenuTransition_Mobile(iWidget *sheet, iBool isIncoming) { |
668 | if (deviceType_App() != phone_AppDeviceType) { | 728 | if (deviceType_App() != phone_AppDeviceType) { |
669 | return; | 729 | return; |
diff --git a/src/ui/mobile.h b/src/ui/mobile.h index 92b2280a..209b41b8 100644 --- a/src/ui/mobile.h +++ b/src/ui/mobile.h | |||
@@ -26,7 +26,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
26 | 26 | ||
27 | iDeclareType(Widget) | 27 | iDeclareType(Widget) |
28 | 28 | ||
29 | void setupMenuTransition_Mobile (iWidget *menu, iBool isIncoming); | 29 | void setupMenuTransition_Mobile (iWidget *menu, iBool isIncoming); |
30 | void setupSheetTransition_Mobile (iWidget *sheet, iBool isIncoming); | ||
31 | //void setupDetailPanelTransition_Mobile (iWidget *Panel, iBool isIncoming); | ||
30 | 32 | ||
31 | void finalizeSheet_Mobile (iWidget *sheet); | 33 | void finalizeSheet_Mobile (iWidget *sheet); |
32 | void setupSheetTransition_Mobile (iWidget *sheet, iBool isIncoming); | ||