[libadwaita/wip/otte/stack: 4/4] viewstack: Make sure to not under-measure children




commit fd1ab6fdb4636f9a9ad38ae4c756ee1f74124a74
Author: Benjamin Otte <otte redhat com>
Date:   Sun Nov 21 04:57:00 2021 +0100

    viewstack: Make sure to not under-measure children
    
    When the stack is homogeneous in only one direction, the other direction
    may produce min sizes too small for all children. Make sure to query at
    least the min size for those.

 src/adw-view-stack.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/adw-view-stack.c b/src/adw-view-stack.c
index 8cc986e3..368c58e8 100644
--- a/src/adw-view-stack.c
+++ b/src/adw-view-stack.c
@@ -90,6 +90,8 @@
 
 #define TRANSITION_DURATION 200
 
+#define OPPOSITE_ORIENTATION(_orientation) (1 - (_orientation))
+
 enum {
   PROP_0,
   PROP_HHOMOGENEOUS,
@@ -970,7 +972,14 @@ adw_view_stack_measure (GtkWidget      *widget,
       continue;
 
     if (gtk_widget_get_visible (child)) {
-      gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL);
+      if (!self->homogeneous[OPPOSITE_ORIENTATION(orientation)] && self->visible_child != page) {
+        int min_for_size;
+
+        gtk_widget_measure (child, OPPOSITE_ORIENTATION (orientation), -1, &min_for_size, NULL, NULL, NULL);
+        gtk_widget_measure (child, orientation, MAX (min_for_size, for_size), &child_min, &child_nat, NULL, 
NULL);
+      } else {
+        gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL);
+      }
 
       *minimum = MAX (*minimum, child_min);
       *natural = MAX (*natural, child_nat);


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