[gtk/constraint-guide-3: 7/9] constraint layout: Add debug output for guides



commit 761e2ae5e0f6a15217a25cec6bbcf5e386c5860d
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 28 22:55:39 2019 +0000

    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 c5d5e18b82..75bc8b1965 100644
--- a/gtk/gtkconstraintlayout.c
+++ b/gtk/gtkconstraintlayout.c
@@ -973,6 +973,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++)
     {


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