summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-04-28 15:03:07 -0400
committerMatthias Clasen <mclasen@redhat.com>2023-04-28 15:05:39 -0400
commit5306ef12f40390bbfe5afb059b5252ffb31a53d0 (patch)
treef908a1ff25ba2b734396981ee3a2e5aa5da86a63
parentbe62147dee9f2d624b8c2042b5939f239a250e61 (diff)
downloadgtk+-5306ef12f40390bbfe5afb059b5252ffb31a53d0.tar.gz
inspector: Show bounds instead of allocation
-rw-r--r--gtk/inspector/misc-info.c24
-rw-r--r--gtk/inspector/misc-info.ui6
2 files changed, 16 insertions, 14 deletions
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index f6a58f0882..0886507e48 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -61,8 +61,8 @@ struct _GtkInspectorMiscInfo
GtkWidget *measure_expand_toggle;
GtkWidget *measure_picture;
GdkPaintable *measure_graph;
- GtkWidget *allocated_size_row;
- GtkWidget *allocated_size;
+ GtkWidget *bounds_row;
+ GtkWidget *bounds;
GtkWidget *baseline_row;
GtkWidget *baseline;
GtkWidget *surface_row;
@@ -145,17 +145,19 @@ static void
update_allocation (GtkWidget *w,
GtkInspectorMiscInfo *sl)
{
- GtkAllocation alloc;
+ graphene_rect_t bounds;
char *size_label;
GEnumClass *class;
GEnumValue *value;
- gtk_widget_get_allocation (w, &alloc);
- size_label = g_strdup_printf ("%d × %d +%d +%d",
- alloc.width, alloc.height,
- alloc.x, alloc.y);
+ if (!gtk_widget_compute_bounds (w, gtk_widget_get_parent (w), &bounds))
+ graphene_rect_init (&bounds, 0, 0, 0, 0);
- gtk_label_set_label (GTK_LABEL (sl->allocated_size), size_label);
+ size_label = g_strdup_printf ("%g × %g +%g +%g",
+ bounds.size.width, bounds.size.height,
+ bounds.origin.x, bounds.origin.y);
+
+ gtk_label_set_label (GTK_LABEL (sl->bounds), size_label);
g_free (size_label);
size_label = g_strdup_printf ("%d", gtk_widget_get_allocated_baseline (w));
@@ -503,7 +505,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
gtk_widget_set_visible (sl->state_row, GTK_IS_WIDGET (object));
gtk_widget_set_visible (sl->direction_row, GTK_IS_WIDGET (object));
gtk_widget_set_visible (sl->request_mode_row, GTK_IS_WIDGET (object));
- gtk_widget_set_visible (sl->allocated_size_row, GTK_IS_WIDGET (object));
+ gtk_widget_set_visible (sl->bounds_row, GTK_IS_WIDGET (object));
gtk_widget_set_visible (sl->baseline_row, GTK_IS_WIDGET (object));
gtk_widget_set_visible (sl->measure_row, GTK_IS_WIDGET (object));
gtk_widget_set_visible (sl->measure_info_row, GTK_IS_WIDGET (object));
@@ -610,8 +612,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, measure_expand_toggle);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, measure_picture);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, measure_graph);
- gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, allocated_size_row);
- gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, allocated_size);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, bounds_row);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, bounds);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, baseline_row);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, baseline);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, surface_row);
diff --git a/gtk/inspector/misc-info.ui b/gtk/inspector/misc-info.ui
index 5db3e98bf9..1df39dc3f5 100644
--- a/gtk/inspector/misc-info.ui
+++ b/gtk/inspector/misc-info.ui
@@ -287,14 +287,14 @@
</object>
</child>
<child>
- <object class="GtkListBoxRow" id="allocated_size_row">
+ <object class="GtkListBoxRow" id="bounds_row">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="spacing">40</property>
<child>
<object class="GtkLabel">
- <property name="label" translatable="yes">Allocation</property>
+ <property name="label" translatable="yes">Bounds</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0</property>
@@ -302,7 +302,7 @@
</object>
</child>
<child>
- <object class="GtkLabel" id="allocated_size">
+ <object class="GtkLabel" id="bounds">
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>