[libhandy/wip/haecker-felix/flap-widget] Fix extra shadow in fold transitions



commit e27e2ea7a5747cbf8679dee1a060a5e6074b40bb
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Nov 19 15:40:31 2020 +0500

    Fix extra shadow in fold transitions

 src/hdy-flap.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index 70050e9f..4acdc77e 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -64,6 +64,8 @@ struct _HdyFlap
   gdouble reveal_progress;
   HdyAnimation *reveal_animation;
 
+  gboolean schedule_fold;
+
   GtkOrientation orientation;
 
   HdyShadowHelper *shadow_helper;
@@ -166,7 +168,8 @@ animate_fold (HdyFlap *self)
     hdy_animation_new (GTK_WIDGET (self),
                        self->fold_progress,
                        self->folded ? 1 : 0,
-                       self->fold_duration,
+                       /* When the flap is completely hidden, we can skip animation */
+                       (self->reveal_progress > 0) ? self->fold_duration : 0,
                        hdy_ease_out_cubic,
                        (HdyAnimationValueCallback) fold_animation_value_cb,
                        (HdyAnimationDoneCallback) fold_animation_done_cb,
@@ -189,6 +192,12 @@ reveal_animation_done_cb (HdyFlap *self)
 
   if (self->reveal_progress <= 0)
     hdy_shadow_helper_clear_cache (self->shadow_helper);
+
+  if (self->schedule_fold) {
+    self->schedule_fold = FALSE;
+
+    animate_fold (self);
+  }
 }
 
 static void
@@ -248,10 +257,13 @@ set_folded (HdyFlap  *self,
 
   gtk_widget_queue_allocate (GTK_WIDGET (self));
 
-  animate_fold (self);
+  if (!self->locked && folded)
+    self->schedule_fold = TRUE;
+  else
+    animate_fold (self);
 
   if (!self->locked)
-    set_reveal_flap (self, !self->folded, self->fold_duration, TRUE);
+    hdy_flap_set_reveal_flap (self, !self->folded);
 
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLDED]);
 }
@@ -627,14 +639,20 @@ hdy_flap_size_allocate (GtkWidget     *widget,
   if (self->flap) {
     gtk_widget_set_child_visible (self->flap, self->reveal_progress > 0);
 
-    if (self->reveal_progress > 0) {
-      if (gtk_widget_get_realized (widget))
+    if (gtk_widget_get_realized (widget)) {
+      if (self->reveal_progress > 0) {
+        gdk_window_show_unraised (self->flap_window);
         gdk_window_move_resize (self->flap_window,
                                 self->flap_allocation.x,
                                 self->flap_allocation.y,
                                 self->flap_allocation.width,
                                 self->flap_allocation.height);
+      } else {
+        gdk_window_hide (self->flap_window);
+      }
+    }
 
+    if (self->reveal_progress > 0) {
       child_alloc.width = self->flap_allocation.width;
       child_alloc.height = self->flap_allocation.height;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]