From 114f23cec74453c0f09277112aa7537642fa8e97 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 10 Jun 2017 14:45:10 -0400 Subject: [PATCH] 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 file changed, 22 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcenterbox.c b/gtk/gtkcenterbox.c index bfd28c7098..8b89df5008 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;