[gtk+] center box: Take baseline-position fully into account



commit 114f23cec74453c0f09277112aa7537642fa8e97
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 10 14:45:10 2017 -0400

    center box: Take baseline-position fully into account
    
    We need to take baseline-position into account during measure
    as well.

 gtk/gtkcenterbox.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcenterbox.c b/gtk/gtkcenterbox.c
index bfd28c7..8b89df5 100644
--- a/gtk/gtkcenterbox.c
+++ b/gtk/gtkcenterbox.c
@@ -329,13 +329,32 @@ gtk_center_box_measure_opposite (GtkWidget      *widget,
 
   if (above_min >= 0)
     {
+      int min_baseline;
+      int nat_baseline;
+
       total_min = MAX (total_min, above_min + below_min);
       total_nat = MAX (total_nat, above_nat + below_nat);
-      /* assume GTK_BASELINE_POSITION_CENTER for now */
+
+      switch (self->baseline_pos)
+        {
+        case GTK_BASELINE_POSITION_TOP:
+          min_baseline = above_min;
+          nat_baseline = above_nat;
+          break;
+        case GTK_BASELINE_POSITION_CENTER:
+          min_baseline = above_min + (total_min - (above_min + below_min)) / 2;
+          nat_baseline = above_nat + (total_nat - (above_nat + below_nat)) / 2;
+          break;
+        case GTK_BASELINE_POSITION_BOTTOM:
+          min_baseline = total_min - below_min;
+          nat_baseline = total_nat - below_nat;
+          break;
+        }
+
       if (minimum_baseline)
-        *minimum_baseline = above_min + (total_min - (above_min + below_min)) / 2;
+        *minimum_baseline = min_baseline;
       if (natural_baseline)
-        *natural_baseline = above_nat + (total_nat - (above_nat + below_nat)) / 2;
+        *natural_baseline = nat_baseline;
     }
 
   *minimum = total_min;


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