libsysprof-gtk: get Axis working

This commit is contained in:
Christian Hergert
2023-06-26 15:31:24 -07:00
parent f0e556c910
commit df065e81bb
4 changed files with 43 additions and 15 deletions

View File

@ -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',

View File

@ -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));

View File

@ -20,8 +20,24 @@
#include "config.h"
#include <math.h>
#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);
}

View File

@ -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;