[gtk/wip/otte/for-master: 1/8] widget: force adjustment method is one size is FILL




commit 50e089349744f3244b5fba1823eb80f92f4d2dcd
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 20 00:46:08 2021 +0100

    widget: force adjustment method is one size is FILL
    
    If halign=fill, force adjustment to height-for-width.
    If valign=fill, force adjustment to width-for-height.
    Otherwise look at request mode.
    
    This way we don't try to adapt the filled dimension and only adjust
    the one that is not set to fill.

 gtk/gtkwidget.c                                      |  4 +++-
 testsuite/reftests/wrap-margin-align-critical.ref.ui | 11 +++--------
 2 files changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 73dc6b20be..65c62be6a0 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3832,7 +3832,9 @@ gtk_widget_adjust_size_allocation (GtkWidget     *widget,
   /* Note that adjust_for_align removes any margins from the
    * allocated sizes and possibly limits them to the natural sizes */
 
-  if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+  if (priv->halign == GTK_ALIGN_FILL ||
+      (priv->valign != GTK_ALIGN_FILL &&
+       gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH))
     {
       gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL,
                           allocation->height + priv->margin.top + priv->margin.bottom,
diff --git a/testsuite/reftests/wrap-margin-align-critical.ref.ui 
b/testsuite/reftests/wrap-margin-align-critical.ref.ui
index 04d550c82d..19daf3fe96 100644
--- a/testsuite/reftests/wrap-margin-align-critical.ref.ui
+++ b/testsuite/reftests/wrap-margin-align-critical.ref.ui
@@ -5,15 +5,10 @@
     <property name="default-height">300</property>
     <property name="decorated">0</property>
     <child>
-      <object class="GtkBox">
+      <object class="GtkLabel">
         <property name="halign">center</property>
-        <child>
-          <object class="GtkLabel">
-            <property name="halign">center</property>
-            <property name="label">Hello World</property>
-            <property name="wrap">True</property>
-          </object>
-        </child>
+        <property name="label">Hello World</property>
+        <property name="wrap">True</property>
       </object>
     </child>
   </object>


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