[gtk+/wip/baseline2] GtkBox: Modify requested baseline as per baseline_pos



commit f7863d7fa58731d4e3a775946a806f5181f26625
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Mar 25 17:57:07 2013 +0100

    GtkBox: Modify requested baseline as per baseline_pos
    
    If non-baseline-aligned items in the box make the height higher,
    use baseline_pos to figure out where to request the baseline.

 gtk/gtkbox.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 8862527..18b3165 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -1222,17 +1222,33 @@ gtk_box_get_size (GtkWidget      *widget,
       natural += (nvis_children - 1) * private->spacing;
     }
 
+  minimum = MAX (minimum, minimum_below + minimum_above);
+  natural = MAX (natural, natural_below + natural_above);
+
   if (have_baseline)
     {
-      min_baseline = minimum_above;
-      nat_baseline = natural_above;
+      switch (private->baseline_pos)
+       {
+       case GTK_BASELINE_POSITION_TOP:
+         min_baseline = minimum_above;
+         nat_baseline = natural_above;
+         break;
+       case GTK_BASELINE_POSITION_CENTER:
+         min_baseline = minimum_above + (minimum - (minimum_above + minimum_below)) / 2;
+         nat_baseline = natural_above + (natural - (natural_above + natural_below)) / 2;
+         break;
+       case GTK_BASELINE_POSITION_BOTTOM:
+         min_baseline = minimum - minimum_below;
+         nat_baseline = natural - natural_below;
+         break;
+       }
     }
 
   if (minimum_size)
-    *minimum_size = MAX (minimum, minimum_below + minimum_above);
+    *minimum_size = minimum;
 
   if (natural_size)
-    *natural_size = MAX (natural, natural_below + natural_above);
+    *natural_size = natural;
 
   if (minimum_baseline)
     *minimum_baseline = min_baseline;


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