[gnome-shell] Do something reasonable for width-for-height sizing



commit 75b52d36f2c74464ba8e6784c5dba2399516e228
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat May 8 12:08:31 2010 -0400

    Do something reasonable for width-for-height sizing
    
    The StTable code only supports height-for-width. When called in
    width-for-height sizing mode, instead of treating the -1 flag
    value of 'for_width' as a real width, and requesting all the
    children at 1 pixel wide, use the natural width of the table
    as the width for determing the height.
    
    Since we can't rewrap in width-for-height mode, we then report
    the natural width also as the minimum width of the table.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618104

 src/st/st-table.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/st/st-table.c b/src/st/st-table.c
index 1949077..27f4eae 100644
--- a/src/st/st-table.c
+++ b/src/st/st-table.c
@@ -870,6 +870,14 @@ st_table_get_preferred_width (ClutterActor *self,
       total_pref_width += pref_widths[i];
     }
 
+  /* If we were requested width-for-height, then we reported minimum/natural
+   * heights based on our natural width. If we were allocated less than our
+   * natural width, then we need more height. So in the width-for-height
+   * case we need to disable shrinking.
+   */
+  if (for_height >= 0)
+    total_min_width = total_pref_width;
+
   if (min_width_p)
     *min_width_p = total_min_width;
   if (natural_width_p)
@@ -892,6 +900,17 @@ st_table_get_preferred_height (ClutterActor *self,
   gint i;
   gint *min_widths;
 
+  /* We only support height-for-width allocation. So if we are called
+   * width-for-height, calculate heights based on our natural width
+   */
+  if (for_width < 0)
+    {
+      float natural_width;
+
+      clutter_actor_get_preferred_width (self, -1, NULL, &natural_width);
+      for_width = natural_width;
+    }
+
   if (priv->n_rows < 1)
     {
       *min_height_p = 0;



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