summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-20 11:40:44 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-20 11:40:44 +0300
commit709329cef2fe3cd88d6a4e27389b64431f5936f6 (patch)
treef12cafbdb00325030760e2f2d89b5fce4c0177f7
parent3bbe6b3c73f8c512279b1dd8d164d302d5e96752 (diff)
Dialog show/hide animations
Use the animations introduced for mobile on desktop as well. Adding a preference for this might be prudent.
-rw-r--r--src/ui/mobile.c51
-rw-r--r--src/ui/root.c3
-rw-r--r--src/ui/sidebarwidget.c3
-rw-r--r--src/ui/translation.c2
-rw-r--r--src/ui/util.c7
-rw-r--r--src/ui/widget.c10
6 files changed, 51 insertions, 25 deletions
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index 6c3a0b32..d678f3e1 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -381,22 +381,22 @@ void finalizeSheet_Mobile(iWidget *sheet) {
381 } 381 }
382 /* TODO: In portrait, top panel and detail stack are all stacked together. 382 /* TODO: In portrait, top panel and detail stack are all stacked together.
383 383
384 Landscape Layout    Portrait Layout 384 Landscape Layout Portrait Layout
385    385
386 ┌─────────┬──────Detail─Stack─────┐    ┌─────────┬ ─ ─ ─ ─ ┐ 386 ┌─────────┬──────Detail─Stack─────┐ ┌─────────┬ ─ ─ ─ ─ ┐
387 │ │┌───────────────────┐ │    │ │Detail 387 │ │┌───────────────────┐ │ │ │Detail
388 │ ││┌──────────────────┴┐ │    │ │Stack │ 388 │ ││┌──────────────────┴┐ │ │ │Stack │
389 │ │││┌──────────────────┴┐│    │ │┌──────┐ 389 │ │││┌──────────────────┴┐│ │ │┌──────┐
390 │ ││││ ││    │ ││┌─────┴┐│ 390 │ ││││ ││ │ ││┌─────┴┐│
391 │ ││││ ││    │ │││ │ 391 │ ││││ ││ │ │││ │
392 │Top Panel││││ ││    │Top Panel│││ ││ 392 │Top Panel││││ ││ │Top Panel│││ ││
393 │ ││││ Panels ││    │ │││Panels│ 393 │ ││││ Panels ││ │ │││Panels│
394 │ ││││ ││    │ │││ ││ 394 │ ││││ ││ │ │││ ││
395 │ │└┤│ ││    │ │││ │ 395 │ │└┤│ ││ │ │││ │
396 │ │ └┤ ││    │ │└┤ ││ 396 │ │ └┤ ││ │ │└┤ ││
397 │ │ └───────────────────┘│    │ │ └──────┘ 397 │ │ └───────────────────┘│ │ │ └──────┘
398 └─────────┴───────────────────────┘    └─────────┴ ─ ─ ─ ─ ┘ 398 └─────────┴───────────────────────┘ └─────────┴ ─ ─ ─ ─ ┘
399    offscreen 399 offscreen
400 */ 400 */
401 /* Modify the top sheet to act as a fullscreen background. */ 401 /* Modify the top sheet to act as a fullscreen background. */
402 setPadding1_Widget(sheet, 0); 402 setPadding1_Widget(sheet, 0);
@@ -759,6 +759,9 @@ void finalizeSheet_Mobile(iWidget *sheet) {
759 else { 759 else {
760 arrange_Widget(sheet); 760 arrange_Widget(sheet);
761 } 761 }
762 if (!useMobileSheetLayout_()) {
763 setupSheetTransition_Mobile(sheet, iTrue);
764 }
762 postRefresh_App(); 765 postRefresh_App();
763} 766}
764 767
@@ -784,16 +787,26 @@ void setupMenuTransition_Mobile(iWidget *sheet, iBool isIncoming) {
784} 787}
785 788
786void setupSheetTransition_Mobile(iWidget *sheet, iBool isIncoming) { 789void setupSheetTransition_Mobile(iWidget *sheet, iBool isIncoming) {
787 if (isSideBySideLayout_()) { 790 if (!useMobileSheetLayout_()) {
791 setFlags_Widget(sheet, horizontalOffset_WidgetFlag, iFalse);
792 if (isIncoming) {
793 setVisualOffset_Widget(sheet, -height_Widget(sheet), 0, 0);
794 setVisualOffset_Widget(sheet, 0, 200, easeOut_AnimFlag | softer_AnimFlag);
795 }
796 else {
797 setVisualOffset_Widget(sheet, -height_Widget(sheet), 200, easeIn_AnimFlag);
798 }
799 return;
800 }
801 if(isSideBySideLayout_()) {
788 return; 802 return;
789 } 803 }
804 setFlags_Widget(sheet, horizontalOffset_WidgetFlag, iTrue);
790 if (isIncoming) { 805 if (isIncoming) {
791 setFlags_Widget(sheet, horizontalOffset_WidgetFlag, iTrue);
792 setVisualOffset_Widget(sheet, size_Root(sheet->root).x, 0, 0); 806 setVisualOffset_Widget(sheet, size_Root(sheet->root).x, 0, 0);
793 setVisualOffset_Widget(sheet, 0, 200, easeOut_AnimFlag); 807 setVisualOffset_Widget(sheet, 0, 200, easeOut_AnimFlag);
794 } 808 }
795 else { 809 else {
796 setFlags_Widget(sheet, horizontalOffset_WidgetFlag, iTrue);
797 const iBool wasDragged = iAbs(value_Anim(&sheet->visualOffset)) > 0; 810 const iBool wasDragged = iAbs(value_Anim(&sheet->visualOffset)) > 0;
798 setVisualOffset_Widget(sheet, size_Root(sheet->root).x, wasDragged ? 100 : 200, 811 setVisualOffset_Widget(sheet, size_Root(sheet->root).x, wasDragged ? 100 : 200,
799 wasDragged ? 0 : easeIn_AnimFlag); 812 wasDragged ? 0 : easeIn_AnimFlag);
diff --git a/src/ui/root.c b/src/ui/root.c
index 9ed62711..6c65d18f 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -276,6 +276,9 @@ void destroyPending_Root(iRoot *d) {
276 if (!isFinished_Anim(&widget->visualOffset)) { 276 if (!isFinished_Anim(&widget->visualOffset)) {
277 continue; 277 continue;
278 } 278 }
279 if (widget->flags & keepOnTop_WidgetFlag) {
280 removeOne_PtrArray(onTop_Root(widget->root), widget);
281 }
279 if (widget->parent) { 282 if (widget->parent) {
280 removeChild_Widget(widget->parent, widget); 283 removeChild_Widget(widget->parent, widget);
281 } 284 }
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 86410d11..ac2d147e 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1460,7 +1460,8 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) {
1460 const iRect bounds = bounds_Widget(w); 1460 const iRect bounds = bounds_Widget(w);
1461 iPaint p; 1461 iPaint p;
1462 init_Paint(&p); 1462 init_Paint(&p);
1463 if (flags_Widget(w) & visualOffset_WidgetFlag && isVisible_Widget(w)) { 1463 if (flags_Widget(w) & visualOffset_WidgetFlag &&
1464 flags_Widget(w) & horizontalOffset_WidgetFlag && isVisible_Widget(w)) {
1464 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId); 1465 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId);
1465 } 1466 }
1466 draw_Widget(w); 1467 draw_Widget(w);
diff --git a/src/ui/translation.c b/src/ui/translation.c
index 4102fcb9..ed7e5baa 100644
--- a/src/ui/translation.c
+++ b/src/ui/translation.c
@@ -460,6 +460,7 @@ iBool handleCommand_Translation(iTranslation *d, const char *cmd) {
460 if (equalWidget_Command(cmd, w, "translation.finished")) { 460 if (equalWidget_Command(cmd, w, "translation.finished")) {
461 if (!isFinished_Translation(d)) { 461 if (!isFinished_Translation(d)) {
462 if (processResult_Translation_(d)) { 462 if (processResult_Translation_(d)) {
463 setupSheetTransition_Mobile(d->dlg, iFalse);
463 destroy_Widget(d->dlg); 464 destroy_Widget(d->dlg);
464 d->dlg = NULL; 465 d->dlg = NULL;
465 } 466 }
@@ -476,6 +477,7 @@ iBool handleCommand_Translation(iTranslation *d, const char *cmd) {
476 cancel_TlsRequest(d->request); 477 cancel_TlsRequest(d->request);
477 } 478 }
478 else { 479 else {
480 setupSheetTransition_Mobile(d->dlg, iFalse);
479 destroy_Widget(d->dlg); 481 destroy_Widget(d->dlg);
480 d->dlg = NULL; 482 d->dlg = NULL;
481 } 483 }
diff --git a/src/ui/util.c b/src/ui/util.c
index 4b35f8f7..86478300 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1176,6 +1176,7 @@ iBool valueInputHandler_(iWidget *dlg, const char *cmd) {
1176 postCommandf_App("valueinput.cancelled id:%s", cstr_String(id_Widget(dlg))); 1176 postCommandf_App("valueinput.cancelled id:%s", cstr_String(id_Widget(dlg)));
1177 setId_Widget(dlg, ""); /* no further commands to emit */ 1177 setId_Widget(dlg, ""); /* no further commands to emit */
1178 } 1178 }
1179 setupSheetTransition_Mobile(dlg, iFalse);
1179 destroy_Widget(dlg); 1180 destroy_Widget(dlg);
1180 return iTrue; 1181 return iTrue;
1181 } 1182 }
@@ -1184,11 +1185,13 @@ iBool valueInputHandler_(iWidget *dlg, const char *cmd) {
1184 else if (equal_Command(cmd, "cancel")) { 1185 else if (equal_Command(cmd, "cancel")) {
1185 postCommandf_App("valueinput.cancelled id:%s", cstr_String(id_Widget(dlg))); 1186 postCommandf_App("valueinput.cancelled id:%s", cstr_String(id_Widget(dlg)));
1186 setId_Widget(dlg, ""); /* no further commands to emit */ 1187 setId_Widget(dlg, ""); /* no further commands to emit */
1188 setupSheetTransition_Mobile(dlg, iFalse);
1187 destroy_Widget(dlg); 1189 destroy_Widget(dlg);
1188 return iTrue; 1190 return iTrue;
1189 } 1191 }
1190 else if (equal_Command(cmd, "valueinput.accept")) { 1192 else if (equal_Command(cmd, "valueinput.accept")) {
1191 acceptValueInput_(dlg); 1193 acceptValueInput_(dlg);
1194 setupSheetTransition_Mobile(dlg, iFalse);
1192 destroy_Widget(dlg); 1195 destroy_Widget(dlg);
1193 return iTrue; 1196 return iTrue;
1194 } 1197 }
@@ -1324,6 +1327,7 @@ static iBool messageHandler_(iWidget *msg, const char *cmd) {
1324 equal_Command(cmd, "scrollbar.fade") || 1327 equal_Command(cmd, "scrollbar.fade") ||
1325 equal_Command(cmd, "widget.overflow") || 1328 equal_Command(cmd, "widget.overflow") ||
1326 startsWith_CStr(cmd, "window."))) { 1329 startsWith_CStr(cmd, "window."))) {
1330 setupSheetTransition_Mobile(msg, iFalse);
1327 destroy_Widget(msg); 1331 destroy_Widget(msg);
1328 } 1332 }
1329 return iFalse; 1333 return iFalse;
@@ -1908,6 +1912,7 @@ static iBool handleBookmarkCreationCommands_SidebarWidget_(iWidget *editor, cons
1908 } 1912 }
1909 postCommand_App("bookmarks.changed"); 1913 postCommand_App("bookmarks.changed");
1910 } 1914 }
1915 setupSheetTransition_Mobile(editor, iFalse);
1911 destroy_Widget(editor); 1916 destroy_Widget(editor);
1912 return iTrue; 1917 return iTrue;
1913 } 1918 }
@@ -1937,6 +1942,7 @@ iWidget *makeBookmarkCreation_Widget(const iString *url, const iString *title, i
1937 1942
1938static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) { 1943static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) {
1939 if (equal_Command(cmd, "cancel")) { 1944 if (equal_Command(cmd, "cancel")) {
1945 setupSheetTransition_Mobile(dlg, iFalse);
1940 destroy_Widget(dlg); 1946 destroy_Widget(dlg);
1941 return iTrue; 1947 return iTrue;
1942 } 1948 }
@@ -1971,6 +1977,7 @@ static iBool handleFeedSettingCommands_(iWidget *dlg, const char *cmd) {
1971 } 1977 }
1972 } 1978 }
1973 postCommand_App("bookmarks.changed"); 1979 postCommand_App("bookmarks.changed");
1980 setupSheetTransition_Mobile(dlg, iFalse);
1974 destroy_Widget(dlg); 1981 destroy_Widget(dlg);
1975 return iTrue; 1982 return iTrue;
1976 } 1983 }
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 64f586ce..5502cb8e 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -101,9 +101,6 @@ static void aboutToBeDestroyed_Widget_(iWidget *d) {
101 setFocus_Widget(NULL); 101 setFocus_Widget(NULL);
102 return; 102 return;
103 } 103 }
104 if (flags_Widget(d) & keepOnTop_WidgetFlag) {
105 removeOne_PtrArray(onTop_Root(d->root), d);
106 }
107 remove_Periodic(periodic_App(), d); 104 remove_Periodic(periodic_App(), d);
108 if (isHover_Widget(d)) { 105 if (isHover_Widget(d)) {
109 get_Window()->hover = NULL; 106 get_Window()->hover = NULL;
@@ -858,6 +855,9 @@ iLocalDef iBool isMouseEvent_(const SDL_Event *ev) {
858} 855}
859 856
860static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) { 857static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) {
858 if (d->flags & destroyPending_WidgetFlag) {
859 return iFalse; /* no more events handled */
860 }
861 const iBool isKey = isKeyboardEvent_(ev); 861 const iBool isKey = isKeyboardEvent_(ev);
862 const iBool isMouse = isMouseEvent_(ev); 862 const iBool isMouse = isMouseEvent_(ev);
863 if ((d->flags & disabled_WidgetFlag) || (d->flags & hidden_WidgetFlag && 863 if ((d->flags & disabled_WidgetFlag) || (d->flags & hidden_WidgetFlag &&
@@ -1103,8 +1103,8 @@ void drawBackground_Widget(const iWidget *d) {
1103 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); 1103 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30);
1104 } 1104 }
1105 const iBool isFaded = fadeBackground && 1105 const iBool isFaded = fadeBackground &&
1106 ~d->flags & noFadeBackground_WidgetFlag && 1106 ~d->flags & noFadeBackground_WidgetFlag;/* &&
1107 ~d->flags & destroyPending_WidgetFlag; 1107 ~d->flags & destroyPending_WidgetFlag;*/
1108 if (isFaded) { 1108 if (isFaded) {
1109 iPaint p; 1109 iPaint p;
1110 init_Paint(&p); 1110 init_Paint(&p);