mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-gtk: add vfunc to get a model item at x,y
This commit is contained in:
@ -142,3 +142,29 @@ sysprof_chart_layer_snapshot_motion (SysprofChartLayer *self,
|
||||
if (SYSPROF_CHART_LAYER_GET_CLASS (self)->snapshot_motion)
|
||||
SYSPROF_CHART_LAYER_GET_CLASS (self)->snapshot_motion (self, snapshot, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_chart_layer_lookup_item:
|
||||
* @self: a #SysprofChartLayer
|
||||
* @x: the coordinate on the X axis
|
||||
* @y: the coordinate on the Y axis
|
||||
*
|
||||
* Locates an item at `(x,y)`.
|
||||
*
|
||||
* If no item is found at `(x,y)`, then %NULL is returned.
|
||||
*
|
||||
* Returns: (transfer full) (nullable) (type GObject): A #GObject
|
||||
* if successful; otherwise %NULL.
|
||||
*/
|
||||
gpointer
|
||||
sysprof_chart_layer_lookup_item (SysprofChartLayer *self,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_CHART_LAYER (self), NULL);
|
||||
|
||||
if (SYSPROF_CHART_LAYER_GET_CLASS (self)->lookup_item)
|
||||
return SYSPROF_CHART_LAYER_GET_CLASS (self)->lookup_item (self, x, y);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -35,10 +35,13 @@ struct _SysprofChartLayerClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (*snapshot_motion) (SysprofChartLayer *self,
|
||||
GtkSnapshot *snapshot,
|
||||
double x,
|
||||
double y);
|
||||
gpointer (*lookup_item) (SysprofChartLayer *self,
|
||||
double x,
|
||||
double y);
|
||||
void (*snapshot_motion) (SysprofChartLayer *self,
|
||||
GtkSnapshot *snapshot,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _reserved[16];
|
||||
@ -50,6 +53,10 @@ SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_chart_layer_set_title (SysprofChartLayer *self,
|
||||
const char *title);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gpointer sysprof_chart_layer_lookup_item (SysprofChartLayer *self,
|
||||
double x,
|
||||
double y);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_chart_layer_snapshot_motion (SysprofChartLayer *self,
|
||||
GtkSnapshot *snapshot,
|
||||
double x,
|
||||
|
||||
@ -161,6 +161,22 @@ sysprof_depth_layer_snapshot_motion (SysprofChartLayer *layer,
|
||||
gtk_snapshot_append_color (snapshot, &self->hover_color, &rect);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
sysprof_depth_layer_lookup_item (SysprofChartLayer *layer,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
SysprofDepthLayer *self = (SysprofDepthLayer *)layer;
|
||||
const SysprofXYSeriesValue *v;
|
||||
|
||||
g_assert (SYSPROF_IS_DEPTH_LAYER (self));
|
||||
|
||||
if ((v = sysprof_depth_layer_get_value_at_coord (self, x, y, NULL)))
|
||||
return g_list_model_get_item (sysprof_xy_series_get_model (self->series), v->index);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_depth_layer_dispose (GObject *object)
|
||||
{
|
||||
@ -238,6 +254,7 @@ sysprof_depth_layer_class_init (SysprofDepthLayerClass *klass)
|
||||
|
||||
widget_class->snapshot = sysprof_depth_layer_snapshot;
|
||||
|
||||
chart_layer_class->lookup_item = sysprof_depth_layer_lookup_item;
|
||||
chart_layer_class->snapshot_motion = sysprof_depth_layer_snapshot_motion;
|
||||
|
||||
properties[PROP_COLOR] =
|
||||
|
||||
Reference in New Issue
Block a user