[libhandy/wip/haecker-felix/flap-widget] Make sure folded state updates before allocating stuff



commit b5810d93a5162df648f01c41d62b59a0700d7401
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Nov 18 17:17:27 2020 +0500

    Make sure folded state updates before allocating stuff
    
    Fix desync with disabled animations.

 src/hdy-flap.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/src/hdy-flap.c b/src/hdy-flap.c
index 7d714a8c..c5f7ed66 100644
--- a/src/hdy-flap.c
+++ b/src/hdy-flap.c
@@ -374,14 +374,6 @@ allocate_content (HdyFlap       *self,
   offset = adjust_for_overlay (self, flap_size);
 
   if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
-    if (self->fold_policy == HDY_FLAP_FOLD_POLICY_AUTO) {
-      GtkRequisition flap_min;
-
-      gtk_widget_get_preferred_size (self->flap, &flap_min, NULL);
-
-      set_folded (self, alloc->width <= content_min.width + flap_min.width);
-    }
-
     content_alloc.y = 0;
     content_alloc.height = alloc->height;
     content_alloc.width = MAX (alloc->width - offset, content_min.width);
@@ -391,14 +383,6 @@ allocate_content (HdyFlap       *self,
     else
       content_alloc.x = 0;
   } else {
-    if (self->fold_policy == HDY_FLAP_FOLD_POLICY_AUTO) {
-      GtkRequisition flap_min;
-
-      gtk_widget_get_preferred_size (self->flap, &flap_min, NULL);
-
-      set_folded (self, alloc->height <= content_min.height + flap_min.height);
-    }
-
     content_alloc.x = 0;
     content_alloc.width = alloc->width;
     content_alloc.height = MAX (alloc->height - offset, content_min.height);
@@ -424,12 +408,24 @@ hdy_flap_size_allocate (GtkWidget     *widget,
     gdk_window_move_resize (gtk_widget_get_window (widget),
                             alloc->x, alloc->y, alloc->width, alloc->height);
 
-  if (self->flap)
-    allocate_flap (self, alloc);
+  if (self->fold_policy == HDY_FLAP_FOLD_POLICY_AUTO) {
+    GtkRequisition flap_min, content_min;
+
+    gtk_widget_get_preferred_size (self->flap, &flap_min, NULL);
+    gtk_widget_get_preferred_size (self->content, &content_min, NULL);
+
+    if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
+      set_folded (self, alloc->width <= content_min.width + flap_min.width);
+    else
+      set_folded (self, alloc->height <= content_min.height + flap_min.height);
+  }
 
   if (self->content)
     allocate_content (self, alloc);
 
+  if (self->flap)
+    allocate_flap (self, alloc);
+
   gtk_widget_set_clip (widget, alloc);
 }
 
@@ -1172,10 +1168,10 @@ hdy_flap_set_fold_policy (HdyFlap           *self,
   self->fold_policy = policy;
 
   if (self->fold_policy == HDY_FLAP_FOLD_POLICY_ALWAYS)
-    set_folded(self, TRUE);
+    set_folded (self, TRUE);
 
   if (self->fold_policy == HDY_FLAP_FOLD_POLICY_NEVER)
-    set_folded(self, FALSE);
+    set_folded (self, FALSE);
 
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLD_POLICY]);
 }


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