summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-07 21:20:25 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-07 21:20:25 +0200
commit63ad3813f76d53a6fa98f45868e8b096331a2d18 (patch)
tree24d31f21351f332dc7d5758e59c43e22fb44a303 /src
parent824da6cbec4a6a28d0fde710777b2bbf771006a0 (diff)
DocumentWidget: Fixed swipe navigation
TODO: If the swipe is aborted, the state ends up wrong.
Diffstat (limited to 'src')
-rw-r--r--src/ui/documentwidget.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 1c861b8f..f4c934f6 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2735,35 +2735,41 @@ static iBool handleSwipe_DocumentWidget_(iDocumentWidget *d, const char *cmd) {
2735 if (equal_Command(cmd, "edgeswipe.ended") && argLabel_Command(cmd, "side") == 1) { 2735 if (equal_Command(cmd, "edgeswipe.ended") && argLabel_Command(cmd, "side") == 1) {
2736 iWidget *swipeParent = swipeParent_DocumentWidget_(d); 2736 iWidget *swipeParent = swipeParent_DocumentWidget_(d);
2737 iDocumentWidget *swipeIn = findChild_Widget(swipeParent, "swipein"); 2737 iDocumentWidget *swipeIn = findChild_Widget(swipeParent, "swipein");
2738// iDocumentWidget *swipeInDoc = (iDocumentWidget *) swipeIn;
2739 /* "swipe.back" will soon follow. The `d` document will do the actual back navigation, 2738 /* "swipe.back" will soon follow. The `d` document will do the actual back navigation,
2740 switching immediately to a cached page. However, if one is not available, we'll need 2739 switching immediately to a cached page. However, if one is not available, we'll need
2741 to show a blank page for a while. */ 2740 to show a blank page for a while. */
2742 if (swipeIn) { 2741 if (swipeIn) {
2742 iWidget *swipeParent = swipeParent_DocumentWidget_(d);
2743 iDocumentWidget *target = new_DocumentWidget();
2744 addChildPos_Widget(swipeParent, iClob(target), back_WidgetAddPos);
2745 setId_Widget(as_Widget(target), "swipeout");
2746 swap_DocumentWidget_(target, d->doc, d);
2743 setUrlAndSource_DocumentWidget(d, 2747 setUrlAndSource_DocumentWidget(d,
2744 swipeIn->mod.url, 2748 swipeIn->mod.url,
2745 collectNewCStr_String("text/gemini"), 2749 collectNewCStr_String("text/gemini"),
2746 collect_Block(new_Block(0))); 2750 collect_Block(new_Block(0)));
2747 //swap_DocumentWidget_(d, swipeIn->doc, swipeIn);
2748 as_Widget(swipeIn)->offsetRef = NULL; 2751 as_Widget(swipeIn)->offsetRef = NULL;
2749 destroy_Widget(as_Widget(swipeIn)); 2752 destroy_Widget(as_Widget(swipeIn));
2750 } 2753 }
2751 } 2754 }
2752 if (equal_Command(cmd, "swipe.back")) { 2755 if (equal_Command(cmd, "swipe.back")) {
2756 iWidget *swipeParent = swipeParent_DocumentWidget_(d);
2757 iDocumentWidget *target = findChild_Widget(swipeParent, "swipeout");
2753 if (atOldest_History(d->mod.history)) { 2758 if (atOldest_History(d->mod.history)) {
2754 setVisualOffset_Widget(w, 0, 100, 0); 2759 setVisualOffset_Widget(w, 0, 100, 0);
2760 if (target) {
2761 destroy_Widget(as_Widget(target)); /* didn't need it after all */
2762 }
2755 return iTrue; 2763 return iTrue;
2756 } 2764 }
2757 iWidget *swipeParent = swipeParent_DocumentWidget_(d); 2765// iDocumentWidget *target = new_DocumentWidget();
2758 iDocumentWidget *target = new_DocumentWidget(); 2766// setId_Widget(as_Widget(target), "swipeout");
2759 setId_Widget(as_Widget(target), "swipeout");
2760 /* The target takes the old document and jumps on top. */ 2767 /* The target takes the old document and jumps on top. */
2761 target->widget.rect.pos = windowToInner_Widget(swipeParent, innerToWindow_Widget(w, zero_I2())); 2768 target->widget.rect.pos = windowToInner_Widget(swipeParent, innerToWindow_Widget(w, zero_I2()));
2762 /* Note: `innerToWindow_Widget` does not apply visual offset. */ 2769 /* Note: `innerToWindow_Widget` does not apply visual offset. */
2763 target->widget.rect.size = w->rect.size; 2770 target->widget.rect.size = w->rect.size;
2764 setFlags_Widget(as_Widget(target), fixedPosition_WidgetFlag | fixedSize_WidgetFlag, iTrue); 2771 setFlags_Widget(as_Widget(target), fixedPosition_WidgetFlag | fixedSize_WidgetFlag, iTrue);
2765 swap_DocumentWidget_(target, d->doc, d); 2772// swap_DocumentWidget_(target, d->doc, d);
2766 addChildPos_Widget(swipeParent, iClob(target), back_WidgetAddPos);
2767 setFlags_Widget(as_Widget(d), refChildrenOffset_WidgetFlag, iTrue); 2773 setFlags_Widget(as_Widget(d), refChildrenOffset_WidgetFlag, iTrue);
2768 as_Widget(d)->offsetRef = swipeParent; 2774 as_Widget(d)->offsetRef = swipeParent;
2769 setVisualOffset_Widget(as_Widget(target), value_Anim(&w->visualOffset), 0, 0); 2775 setVisualOffset_Widget(as_Widget(target), value_Anim(&w->visualOffset), 0, 0);