[sysprof] line-visualizer: add support for filling line areas
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] line-visualizer: add support for filling line areas
- Date: Sun, 20 May 2018 22:51:56 +0000 (UTC)
commit 0535691afaa1bbf3e83f1e0cd73ad317072ea3f6
Author: Christian Hergert <chergert redhat com>
Date: Sat May 19 13:24:58 2018 +0100
line-visualizer: add support for filling line areas
This allows us to fill the area and set it to an RGBA instead of the same
as the line color itself.
lib/visualizers/sp-line-visualizer-row.c | 60 +++++++++++++++++++++++++++---
lib/visualizers/sp-line-visualizer-row.h | 16 +++++--
2 files changed, 65 insertions(+), 11 deletions(-)
---
diff --git a/lib/visualizers/sp-line-visualizer-row.c b/lib/visualizers/sp-line-visualizer-row.c
index 99a58ba..e00594b 100644
--- a/lib/visualizers/sp-line-visualizer-row.c
+++ b/lib/visualizers/sp-line-visualizer-row.c
@@ -69,8 +69,8 @@ typedef struct
{
guint id;
gdouble line_width;
- GdkRGBA background;
GdkRGBA foreground;
+ GdkRGBA background;
guint use_default_style : 1;
guint fill : 1;
} LineInfo;
@@ -215,17 +215,19 @@ sp_line_visualizer_row_draw (GtkWidget *widget,
cairo_set_line_width (cr, line_info->line_width);
+ if (line_info->fill)
+ {
+ gdk_cairo_set_source_rgba (cr, &line_info->background);
+ cairo_fill_preserve (cr);
+ }
+
if (line_info->use_default_style)
color = foreground;
else
color = line_info->foreground;
gdk_cairo_set_source_rgba (cr, &color);
-
- if (line_info->fill)
- cairo_fill (cr);
- else
- cairo_stroke (cr);
+ cairo_stroke (cr);
}
}
@@ -683,3 +685,49 @@ sp_line_visualizer_row_load_data_finish (SpLineVisualizerRow *self,
return g_task_propagate_pointer (G_TASK (result), error);
}
+
+void
+sp_line_visualizer_row_set_line_width (SpLineVisualizerRow *self,
+ guint counter_id,
+ gdouble width)
+{
+ SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
+
+ g_return_if_fail (SP_IS_LINE_VISUALIZER_ROW (self));
+
+ for (guint i = 0; i < priv->lines->len; i++)
+ {
+ LineInfo *info = &g_array_index (priv->lines, LineInfo, i);
+
+ if (info->id == counter_id)
+ {
+ info->line_width = width;
+ sp_line_visualizer_row_queue_reload (self);
+ break;
+ }
+ }
+}
+
+void
+sp_line_visualizer_row_set_fill (SpLineVisualizerRow *self,
+ guint counter_id,
+ const GdkRGBA *color)
+{
+ SpLineVisualizerRowPrivate *priv = sp_line_visualizer_row_get_instance_private (self);
+
+ g_return_if_fail (SP_IS_LINE_VISUALIZER_ROW (self));
+
+ for (guint i = 0; i < priv->lines->len; i++)
+ {
+ LineInfo *info = &g_array_index (priv->lines, LineInfo, i);
+
+ if (info->id == counter_id)
+ {
+ info->fill = !!color;
+ if (color != NULL)
+ info->background = *color;
+ sp_line_visualizer_row_queue_reload (self);
+ break;
+ }
+ }
+}
diff --git a/lib/visualizers/sp-line-visualizer-row.h b/lib/visualizers/sp-line-visualizer-row.h
index 07eb805..7b41244 100644
--- a/lib/visualizers/sp-line-visualizer-row.h
+++ b/lib/visualizers/sp-line-visualizer-row.h
@@ -38,11 +38,17 @@ struct _SpLineVisualizerRowClass
gpointer _reserved[16];
};
-GtkWidget *sp_line_visualizer_row_new (void);
-void sp_line_visualizer_row_clear (SpLineVisualizerRow *self);
-void sp_line_visualizer_row_add_counter (SpLineVisualizerRow *self,
- guint counter_id,
- const GdkRGBA *color);
+GtkWidget *sp_line_visualizer_row_new (void);
+void sp_line_visualizer_row_clear (SpLineVisualizerRow *self);
+void sp_line_visualizer_row_add_counter (SpLineVisualizerRow *self,
+ guint counter_id,
+ const GdkRGBA *color);
+void sp_line_visualizer_row_set_line_width (SpLineVisualizerRow *self,
+ guint counter_id,
+ gdouble width);
+void sp_line_visualizer_row_set_fill (SpLineVisualizerRow *self,
+ guint counter_id,
+ const GdkRGBA *color);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]