From df065e81bb0f99b0295d24982cab739091e713bd Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 26 Jun 2023 15:31:24 -0700 Subject: [PATCH] libsysprof-gtk: get Axis working --- src/libsysprof-gtk/meson.build | 2 ++ src/libsysprof-gtk/sysprof-axis.c | 2 +- src/libsysprof-gtk/sysprof-value-axis.c | 46 +++++++++++++++++++------ src/libsysprof-gtk/sysprof-value-axis.h | 8 ++--- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/libsysprof-gtk/meson.build b/src/libsysprof-gtk/meson.build index 8ffa7405..0efc2504 100644 --- a/src/libsysprof-gtk/meson.build +++ b/src/libsysprof-gtk/meson.build @@ -15,6 +15,7 @@ libsysprof_gtk_public_sources = [ 'sysprof-time-span-layer.c', 'sysprof-time-series.c', 'sysprof-time-series-item.c', + 'sysprof-value-axis.c', 'sysprof-weighted-callgraph-view.c', 'sysprof-xy-layer.c', 'sysprof-xy-series.c', @@ -41,6 +42,7 @@ libsysprof_gtk_public_headers = [ 'sysprof-time-series-item.h', 'sysprof-time-span-layer.h', 'sysprof-weighted-callgraph-view.h', + 'sysprof-value-axis.h', 'sysprof-xy-layer.h', 'sysprof-xy-series.h', 'sysprof-xy-series-item.h', diff --git a/src/libsysprof-gtk/sysprof-axis.c b/src/libsysprof-gtk/sysprof-axis.c index ff7f7069..a45415aa 100644 --- a/src/libsysprof-gtk/sysprof-axis.c +++ b/src/libsysprof-gtk/sysprof-axis.c @@ -152,7 +152,7 @@ sysprof_axis_set_title (SysprofAxis *self, } void -_charts_axis_emit_range_changed (SysprofAxis *self) +_sysprof_axis_emit_range_changed (SysprofAxis *self) { g_return_if_fail (SYSPROF_IS_AXIS (self)); diff --git a/src/libsysprof-gtk/sysprof-value-axis.c b/src/libsysprof-gtk/sysprof-value-axis.c index 5cec74f7..c126cf6e 100644 --- a/src/libsysprof-gtk/sysprof-value-axis.c +++ b/src/libsysprof-gtk/sysprof-value-axis.c @@ -20,8 +20,24 @@ #include "config.h" +#include + +#include "sysprof-axis-private.h" #include "sysprof-value-axis.h" +struct _SysprofValueAxis +{ + SysprofAxis parent_instance; + double min_value; + double max_value; + double distance; +}; + +struct _SysprofValueAxisClass +{ + SysprofAxisClass parent_class; +}; + enum { PROP_0, PROP_MIN_VALUE, @@ -79,8 +95,8 @@ sysprof_value_axis_real_get_min_value (SysprofAxis *axis, } static double -sysprof_value_axis_normalize (SysprofAxis *axis, - const GValue *value) +sysprof_value_axis_normalize (SysprofAxis *axis, + const GValue *value) { SysprofValueAxis *self = (SysprofValueAxis *)axis; double v = get_as_double (value); @@ -91,9 +107,9 @@ sysprof_value_axis_normalize (SysprofAxis *axis, static void sysprof_value_axis_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { SysprofValueAxis *self = SYSPROF_VALUE_AXIS (object); @@ -114,9 +130,9 @@ sysprof_value_axis_get_property (GObject *object, static void sysprof_value_axis_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) + guint prop_id, + const GValue *value, + GParamSpec *pspec) { SysprofValueAxis *self = SYSPROF_VALUE_AXIS (object); @@ -175,7 +191,7 @@ sysprof_value_axis_get_min_value (SysprofValueAxis *self) void sysprof_value_axis_set_min_value (SysprofValueAxis *self, - double min_value) + double min_value) { g_return_if_fail (SYSPROF_IS_VALUE_AXIS (self)); @@ -198,7 +214,7 @@ sysprof_value_axis_get_max_value (SysprofValueAxis *self) void sysprof_value_axis_set_max_value (SysprofValueAxis *self, - double max_value) + double max_value) { g_return_if_fail (SYSPROF_IS_VALUE_AXIS (self)); @@ -210,3 +226,13 @@ sysprof_value_axis_set_max_value (SysprofValueAxis *self, _sysprof_axis_emit_range_changed (SYSPROF_AXIS (self)); } } + +SysprofAxis * +sysprof_value_axis_new (double min_value, + double max_value) +{ + return g_object_new (SYSPROF_TYPE_VALUE_AXIS, + "min-value", min_value, + "max-value", max_value, + NULL); +} diff --git a/src/libsysprof-gtk/sysprof-value-axis.h b/src/libsysprof-gtk/sysprof-value-axis.h index 8eb21c6e..54dae803 100644 --- a/src/libsysprof-gtk/sysprof-value-axis.h +++ b/src/libsysprof-gtk/sysprof-value-axis.h @@ -24,10 +24,10 @@ G_BEGIN_DECLS -#define SYSPROF_TYPE_VALUE_AXIS (sysprof_value_axis_get_type()) -#define SYSPROF_IS_AXIS(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_AXIS)) -#define SYSPROF_AXIS(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_AXIS, SysprofValueAxis)) -#define SYSPROF_AXIS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_AXIS, SysprofValueAxisClass)) +#define SYSPROF_TYPE_VALUE_AXIS (sysprof_value_axis_get_type()) +#define SYSPROF_IS_VALUE_AXIS(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_VALUE_AXIS)) +#define SYSPROF_VALUE_AXIS(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_VALUE_AXIS, SysprofValueAxis)) +#define SYSPROF_VALUE_AXIS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_VALUE_AXIS, SysprofValueAxisClass)) typedef struct _SysprofValueAxis SysprofValueAxis; typedef struct _SysprofValueAxisClass SysprofValueAxisClass;