From 6a3ae181655ea43a3a5d5996f8f4826d2130abe3 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 26 Jun 2023 15:33:03 -0700 Subject: [PATCH] libsysprof-gtk: measure layers from chart --- src/libsysprof-gtk/sysprof-chart.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libsysprof-gtk/sysprof-chart.c b/src/libsysprof-gtk/sysprof-chart.c index 0ed6bfdd..99e29a98 100644 --- a/src/libsysprof-gtk/sysprof-chart.c +++ b/src/libsysprof-gtk/sysprof-chart.c @@ -168,6 +168,32 @@ sysprof_chart_click_pressed_cb (SysprofChart *self, return ret; } +static void +sysprof_chart_measure (GtkWidget *widget, + GtkOrientation orientation, + int for_size, + int *minimum, + int *natural, + int *minium_baseline, + int *natural_baseline) +{ + *minium_baseline = -1; + *natural_baseline = -1; + + for (GtkWidget *child = gtk_widget_get_first_child (widget); + child != NULL; + child = gtk_widget_get_next_sibling (child)) + { + int child_min; + int child_nat; + + gtk_widget_measure (child, orientation, for_size, &child_min, &child_nat, NULL, NULL); + + *minimum = MAX (*minimum, child_min); + *natural = MAX (*natural, child_nat); + } +} + static void sysprof_chart_dispose (GObject *object) { @@ -240,6 +266,7 @@ sysprof_chart_class_init (SysprofChartClass *klass) object_class->get_property = sysprof_chart_get_property; object_class->set_property = sysprof_chart_set_property; + widget_class->measure = sysprof_chart_measure; widget_class->size_allocate = sysprof_chart_size_allocate; widget_class->snapshot = sysprof_chart_snapshot;