summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-17 21:28:07 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-17 21:28:07 +0300
commitc94469c3b5e46fa15939de271e6a4e1cc812dea3 (patch)
tree8ccb30ff4a48726dc945296a95d1d5007cf331dd /src/ui/sidebarwidget.c
parentab10c23969bb7d7be73613d50ae2a3755da39fb0 (diff)
SidebarWidget: Animate show/hide
Also addressed clipping issues when using multiple roots.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index d4e2fb3b..436eb250 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -878,10 +878,31 @@ static iBool handleSidebarCommand_SidebarWidget_(iSidebarWidget *d, const char *
878 if (arg_Command(cmd) && isVisible_Widget(w)) { 878 if (arg_Command(cmd) && isVisible_Widget(w)) {
879 return iTrue; 879 return iTrue;
880 } 880 }
881 const iBool isAnimated = (deviceType_App() != phone_AppDeviceType);
882 int visX = 0;
883 if (isVisible_Widget(w)) {
884 visX = left_Rect(bounds_Widget(w)) - left_Rect(w->root->widget->rect);
885 }
881 setFlags_Widget(w, hidden_WidgetFlag, isVisible_Widget(w)); 886 setFlags_Widget(w, hidden_WidgetFlag, isVisible_Widget(w));
882 if (isVisible_Widget(w)) { 887 if (isVisible_Widget(w)) {
888 setFlags_Widget(w, keepOnTop_WidgetFlag, iFalse);
883 w->rect.size.x = d->widthAsGaps * gap_UI; 889 w->rect.size.x = d->widthAsGaps * gap_UI;
884 invalidate_ListWidget(d->list); 890 invalidate_ListWidget(d->list);
891 if (isAnimated) {
892 setFlags_Widget(w, horizontalOffset_WidgetFlag, iTrue);
893 setVisualOffset_Widget(w, (d->side == left_SideBarSide ? -1 : 1) * w->rect.size.x, 0, 0);
894 setVisualOffset_Widget(w, 0, 300, easeOut_AnimFlag | softer_AnimFlag);
895 }
896 }
897 else if (isAnimated) {
898 if (d->side == right_SideBarSide) {
899 setVisualOffset_Widget(w, visX, 0, 0);
900 setVisualOffset_Widget(w, visX + w->rect.size.x, 300, easeOut_AnimFlag | softer_AnimFlag);
901 }
902 else {
903 setFlags_Widget(w, keepOnTop_WidgetFlag, iTrue);
904 setVisualOffset_Widget(w, -w->rect.size.x, 300, easeOut_AnimFlag | softer_AnimFlag);
905 }
885 } 906 }
886 arrange_Widget(w->parent); 907 arrange_Widget(w->parent);
887 /* BUG: Rearranging because the arrange above didn't fully resolve the height. */ 908 /* BUG: Rearranging because the arrange above didn't fully resolve the height. */
@@ -1433,9 +1454,17 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) {
1433 const iRect bounds = bounds_Widget(w); 1454 const iRect bounds = bounds_Widget(w);
1434 iPaint p; 1455 iPaint p;
1435 init_Paint(&p); 1456 init_Paint(&p);
1457 if (flags_Widget(w) & visualOffset_WidgetFlag && isVisible_Widget(w)) {
1458 fillRect_Paint(&p, boundsWithoutVisualOffset_Widget(w), tmBackground_ColorId);
1459 }
1436 draw_Widget(w); 1460 draw_Widget(w);
1437 drawVLine_Paint( 1461 if (isVisible_Widget(w)) {
1438 &p, addX_I2(topRight_Rect(bounds), -1), height_Rect(bounds), uiSeparator_ColorId); 1462 drawVLine_Paint(
1463 &p,
1464 addX_I2(d->side == left_SideBarSide ? topRight_Rect(bounds) : topLeft_Rect(bounds), -1),
1465 height_Rect(bounds),
1466 uiSeparator_ColorId);
1467 }
1439} 1468}
1440 1469
1441static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, 1470static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,