[sysprof/wip/visualizers] color-cycle: add reset helper



commit baabf7692c7cece625eae5c2d61d2da25182b163
Author: Christian Hergert <chergert redhat com>
Date:   Wed Sep 28 14:09:32 2016 -0700

    color-cycle: add reset helper
    
    This will reset the colors and move back to position 0.

 lib/sp-color-cycle.c |   14 ++++++++++++++
 lib/sp-color-cycle.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/lib/sp-color-cycle.c b/lib/sp-color-cycle.c
index 4c71fa0..cbfec0a 100644
--- a/lib/sp-color-cycle.c
+++ b/lib/sp-color-cycle.c
@@ -120,3 +120,17 @@ sp_color_cycle_next (SpColorCycle *self,
 
   self->position = (self->position + 1) % self->n_colors;
 }
+
+void
+sp_color_cycle_reset (SpColorCycle *self)
+{
+  g_return_if_fail (self != NULL);
+
+  for (guint i = 0; default_colors[i]; i++)
+    {
+      if G_UNLIKELY (!gdk_rgba_parse (&self->colors[i], default_colors[i]))
+        g_warning ("Failed to parse color %s into an RGBA", default_colors[i]);
+    }
+
+  self->position = 0;
+}
diff --git a/lib/sp-color-cycle.h b/lib/sp-color-cycle.h
index bbac504..ecf65cc 100644
--- a/lib/sp-color-cycle.h
+++ b/lib/sp-color-cycle.h
@@ -31,6 +31,7 @@ GType         sp_color_cycle_get_type (void);
 SpColorCycle *sp_color_cycle_ref      (SpColorCycle *self);
 void          sp_color_cycle_unref    (SpColorCycle *self);
 SpColorCycle *sp_color_cycle_new      (void);
+void          sp_color_cycle_reset    (SpColorCycle *self);
 void          sp_color_cycle_next     (SpColorCycle *self,
                                        GdkRGBA      *rgba);
 


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