From 90f8dcc5e18aad2e6e6f3b92e8bce7074eba9bab Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 28 Jun 2019 22:55:39 +0000 Subject: [PATCH] constraint layout: Add debug output for guides Print out the allocation we end up giving to guides. This helps in making sense of the allocations of the child widgets that these guides relate to. --- gtk/gtkconstraintlayout.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gtk/gtkconstraintlayout.c b/gtk/gtkconstraintlayout.c index 378e7840af..23bf8631c6 100644 --- a/gtk/gtkconstraintlayout.c +++ b/gtk/gtkconstraintlayout.c @@ -974,6 +974,30 @@ gtk_constraint_solver_add_constraint (solver, child_baseline); } +#ifdef G_ENABLE_DEBUG + if (GTK_DEBUG_CHECK (LAYOUT)) + { + GHashTableIter iter; + gpointer key; + g_hash_table_iter_init (&iter, self->guides); + while (g_hash_table_iter_next (&iter, &key, NULL)) + { + GtkConstraintGuide *guide = key; + GtkConstraintVariable *var_top, *var_left, *var_width, *var_height; + var_top = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_TOP); + var_left = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_LEFT); + var_width = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_WIDTH); + var_height = gtk_constraint_guide_get_attribute (guide, GTK_CONSTRAINT_ATTRIBUTE_HEIGHT); + g_print ("Allocating guide '%s'[%p] with { .x: %g .y: %g .w: %g .h: %g }\n", + gtk_constraint_guide_get_name (guide), guide, + gtk_constraint_variable_get_value (var_left), + gtk_constraint_variable_get_value (var_top), + gtk_constraint_variable_get_value (var_width), + gtk_constraint_variable_get_value (var_height)); + } + } +#endif + /* The constraints on the children sizes can be removed now */ for (guint i = 0; i < size_constraints->len; i++) {