summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-06-14 15:36:48 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-06-14 15:36:48 +0300
commitfe238b29132b43f07aa88cf6bb60bec1ff0d3f8d (patch)
tree34d08228270960a73f5586ae907a12d7adb7b393 /src/ui/sidebarwidget.c
parent203426a88b2d94ed56f7d3f8f8eb18a7457cab11 (diff)
Swiping and sidebar; various tweaks
When a page is opened from the sidebar, swiping back will now reopen the sidebar. Another swipe will dismiss the sidebar and navigate back as usual. Attempted to cache theme colors in GmDocument, but there were issues with theme changes.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 4f3ea637..f7181037 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -773,6 +773,7 @@ static void itemClicked_SidebarWidget_(iSidebarWidget *d, iSidebarItem *item, si
773 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id); 773 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id);
774 postCommandf_App("document.goto loc:%p", head->text.start); 774 postCommandf_App("document.goto loc:%p", head->text.start);
775 dismissPortraitPhoneSidebars_Root(as_Widget(d)->root); 775 dismissPortraitPhoneSidebars_Root(as_Widget(d)->root);
776 setOpenedFromSidebar_DocumentWidget(document_App(), iTrue);
776 break; 777 break;
777 } 778 }
778 case feeds_SidebarMode: { 779 case feeds_SidebarMode: {
@@ -783,7 +784,7 @@ static void itemClicked_SidebarWidget_(iSidebarWidget *d, iSidebarItem *item, si
783 case bookmarks_SidebarMode: 784 case bookmarks_SidebarMode:
784 case history_SidebarMode: { 785 case history_SidebarMode: {
785 if (!isEmpty_String(&item->url)) { 786 if (!isEmpty_String(&item->url)) {
786 postCommandf_Root(get_Root(), "open newtab:%d url:%s", 787 postCommandf_Root(get_Root(), "open fromsidebar:1 newtab:%d url:%s",
787 openTabMode_Sym(modState_Keys()), 788 openTabMode_Sym(modState_Keys()),
788 cstr_String(&item->url)); 789 cstr_String(&item->url));
789 } 790 }
@@ -944,13 +945,16 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
944 visX = left_Rect(bounds_Widget(w)) - left_Rect(w->root->widget->rect); 945 visX = left_Rect(bounds_Widget(w)) - left_Rect(w->root->widget->rect);
945 } 946 }
946 setFlags_Widget(w, hidden_WidgetFlag, isVisible_Widget(w)); 947 setFlags_Widget(w, hidden_WidgetFlag, isVisible_Widget(w));
948 /* Safe area inset for mobile. */
949 const int safePad = (d->side == left_SidebarSide ? left_Rect(safeRect_Root(w->root)) : 0);
947 if (isVisible_Widget(w)) { 950 if (isVisible_Widget(w)) {
948 setFlags_Widget(w, keepOnTop_WidgetFlag, iFalse); 951 setFlags_Widget(w, keepOnTop_WidgetFlag, iFalse);
949 w->rect.size.x = d->widthAsGaps * gap_UI; 952 w->rect.size.x = d->widthAsGaps * gap_UI;
950 invalidate_ListWidget(d->list); 953 invalidate_ListWidget(d->list);
951 if (isAnimated) { 954 if (isAnimated) {
952 setFlags_Widget(w, horizontalOffset_WidgetFlag, iTrue); 955 setFlags_Widget(w, horizontalOffset_WidgetFlag, iTrue);
953 setVisualOffset_Widget(w, (d->side == left_SidebarSide ? -1 : 1) * w->rect.size.x, 0, 0); 956 setVisualOffset_Widget(
957 w, (d->side == left_SidebarSide ? -1 : 1) * (w->rect.size.x + safePad), 0, 0);
954 setVisualOffset_Widget(w, 0, 300, easeOut_AnimFlag | softer_AnimFlag); 958 setVisualOffset_Widget(w, 0, 300, easeOut_AnimFlag | softer_AnimFlag);
955 } 959 }
956 } 960 }
@@ -958,11 +962,13 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
958 setFlags_Widget(w, horizontalOffset_WidgetFlag, iTrue); 962 setFlags_Widget(w, horizontalOffset_WidgetFlag, iTrue);
959 if (d->side == right_SidebarSide) { 963 if (d->side == right_SidebarSide) {
960 setVisualOffset_Widget(w, visX, 0, 0); 964 setVisualOffset_Widget(w, visX, 0, 0);
961 setVisualOffset_Widget(w, visX + w->rect.size.x, 300, easeOut_AnimFlag | softer_AnimFlag); 965 setVisualOffset_Widget(
966 w, visX + w->rect.size.x + safePad, 300, easeOut_AnimFlag | softer_AnimFlag);
962 } 967 }
963 else { 968 else {
964 setFlags_Widget(w, keepOnTop_WidgetFlag, iTrue); 969 setFlags_Widget(w, keepOnTop_WidgetFlag, iTrue);
965 setVisualOffset_Widget(w, -w->rect.size.x, 300, easeOut_AnimFlag | softer_AnimFlag); 970 setVisualOffset_Widget(
971 w, -w->rect.size.x - safePad, 300, easeOut_AnimFlag | softer_AnimFlag);
966 } 972 }
967 } 973 }
968 arrange_Widget(w->parent); 974 arrange_Widget(w->parent);