[sysprof/wip/chergert/sysprof-3] libsysprof-ui: add dashed line support



commit 58d4199e8c84b593399d58b478f1e3d8f517b8e9
Author: Christian Hergert <chergert redhat com>
Date:   Thu May 23 12:48:18 2019 -0700

    libsysprof-ui: add dashed line support

 src/libsysprof-ui/sysprof-line-visualizer-row.c | 27 +++++++++++++++++++++++++
 src/libsysprof-ui/sysprof-line-visualizer-row.h |  4 ++++
 2 files changed, 31 insertions(+)
---
diff --git a/src/libsysprof-ui/sysprof-line-visualizer-row.c b/src/libsysprof-ui/sysprof-line-visualizer-row.c
index 5488a45..3c7e3c2 100644
--- a/src/libsysprof-ui/sysprof-line-visualizer-row.c
+++ b/src/libsysprof-ui/sysprof-line-visualizer-row.c
@@ -79,6 +79,7 @@ typedef struct
   GdkRGBA background;
   guint use_default_style : 1;
   guint fill : 1;
+  guint use_dash : 1;
 } LineInfo;
 
 typedef struct
@@ -113,6 +114,7 @@ enum {
 };
 
 static GParamSpec *properties [N_PROPS];
+static gdouble dashes[] = { 1.0, 2.0 };
 
 static void
 load_data_free (gpointer data)
@@ -223,6 +225,9 @@ sysprof_line_visualizer_row_draw (GtkWidget *widget,
 
           cairo_set_line_width (cr, line_info->line_width);
 
+          if (line_info->use_dash)
+            cairo_set_dash (cr, dashes, G_N_ELEMENTS (dashes), 0);
+
           if (line_info->fill)
             {
               gdk_cairo_set_source_rgba (cr, &line_info->background);
@@ -818,3 +823,25 @@ sysprof_line_visualizer_row_set_fill (SysprofLineVisualizerRow *self,
         }
     }
 }
+
+void
+sysprof_line_visualizer_row_set_dash (SysprofLineVisualizerRow *self,
+                                      guint                     counter_id,
+                                      gboolean                  use_dash)
+{
+  SysprofLineVisualizerRowPrivate *priv = sysprof_line_visualizer_row_get_instance_private (self);
+
+  g_return_if_fail (SYSPROF_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->use_dash = !!use_dash;
+          sysprof_line_visualizer_row_queue_reload (self);
+          break;
+        }
+    }
+}
diff --git a/src/libsysprof-ui/sysprof-line-visualizer-row.h b/src/libsysprof-ui/sysprof-line-visualizer-row.h
index 5d578d9..d27b195 100644
--- a/src/libsysprof-ui/sysprof-line-visualizer-row.h
+++ b/src/libsysprof-ui/sysprof-line-visualizer-row.h
@@ -62,5 +62,9 @@ SYSPROF_AVAILABLE_IN_ALL
 void       sysprof_line_visualizer_row_set_fill       (SysprofLineVisualizerRow *self,
                                                        guint                     counter_id,
                                                        const GdkRGBA            *color);
+SYSPROF_AVAILABLE_IN_ALL
+void       sysprof_line_visualizer_row_set_dash       (SysprofLineVisualizerRow *self,
+                                                       guint                     counter_id,
+                                                       gboolean                  use_dash);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]