[fadb19bfbddde11ed6828a22e742cc97f5589ce48ac8ec8f94a6510ad5f16b8b/gnome-3-36] clutter/box-layout: Request the correct size for homogeneous layouts



commit c2146b457e99fd83a5748abdb643a913af5a3375
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sun Jun 28 14:13:23 2020 +0200

    clutter/box-layout: Request the correct size for homogeneous layouts
    
    In case the layout is homogeneous, all children aligned by the box
    layout must be allocated the same size. In order to fit them all inside
    the container, the size request of the box layout has to look for the
    child with the largest size and use that size for all children.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2737
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1333

 clutter/clutter/clutter-box-layout.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter/clutter-box-layout.c b/clutter/clutter/clutter-box-layout.c
index 3f5b9db2ab..223b5204ce 100644
--- a/clutter/clutter/clutter-box-layout.c
+++ b/clutter/clutter/clutter-box-layout.c
@@ -475,8 +475,10 @@ get_preferred_size_for_orientation (ClutterBoxLayout   *self,
   ClutterActor *child;
   gint n_children = 0;
   gfloat minimum, natural;
+  float largest_min_size, largest_nat_size;
 
   minimum = natural = 0;
+  largest_min_size = largest_nat_size = 0;
 
   clutter_actor_iter_init (&iter, container);
   while (clutter_actor_iter_next (&iter, &child))
@@ -491,8 +493,22 @@ get_preferred_size_for_orientation (ClutterBoxLayout   *self,
       get_child_size (child, priv->orientation,
                      for_size, &child_min, &child_nat);
 
-      minimum += child_min;
-      natural += child_nat;
+      if (priv->is_homogeneous)
+        {
+          largest_min_size = MAX (largest_min_size, child_min);
+          largest_nat_size = MAX (largest_nat_size, child_nat);
+        }
+      else
+        {
+          minimum += child_min;
+          natural += child_nat;
+        }
+    }
+
+  if (priv->is_homogeneous)
+    {
+      minimum = largest_min_size * n_children;
+      natural = largest_nat_size * n_children;
     }
 
   if (n_children > 1)


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