[gtk/matthiasc/lottie] Add a setter for stroke color



commit 156d5125ed70da4b241528f540e70a8a43bffe0e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Nov 22 13:45:29 2020 -0500

    Add a setter for stroke color

 tests/curve-editor.c | 19 ++++++++++++++++++-
 tests/curve-editor.h |  7 +++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/tests/curve-editor.c b/tests/curve-editor.c
index 7472e98a00..be034f1aee 100644
--- a/tests/curve-editor.c
+++ b/tests/curve-editor.c
@@ -114,6 +114,7 @@ struct _CurveEditor
   GtkWidget *menu;
   GActionMap *actions;
   GskStroke *stroke;
+  GdkRGBA color;
 };
 
 struct _CurveEditorClass
@@ -1251,7 +1252,7 @@ curve_editor_snapshot (GtkWidget   *widget,
   gsk_path_unref (path);
 
   gtk_snapshot_append_color (snapshot,
-                             &(GdkRGBA){ 0, 0, 0, 1 },
+                             &self->color,
                              &GRAPHENE_RECT_INIT (0, 0, width, height ));
 
   gtk_snapshot_pop (snapshot);
@@ -1441,6 +1442,7 @@ curve_editor_init (CurveEditor *self)
   self->dragged = -1;
   self->edit = FALSE;
   self->stroke = gsk_stroke_new (1.0);
+  self->color = (GdkRGBA){ 0, 0, 0, 1 };
 
   controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
   gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_PRIMARY);
@@ -1629,5 +1631,20 @@ curve_editor_get_stroke (CurveEditor *self)
 {
   return self->stroke;
 }
+
+void
+curve_editor_set_color (CurveEditor *self,
+                        GdkRGBA     *color)
+{
+  self->color = *color;
+
+  gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+const GdkRGBA *
+curve_editor_get_color (CurveEditor *self)
+{
+  return &self->color;
+}
 /* }}} */
 /* vim:set foldmethod=marker expandtab: */
diff --git a/tests/curve-editor.h b/tests/curve-editor.h
index 3d8f3808ae..215adf449f 100644
--- a/tests/curve-editor.h
+++ b/tests/curve-editor.h
@@ -23,4 +23,11 @@ void        curve_editor_set_stroke (CurveEditor *self,
 const GskStroke *
             curve_editor_get_stroke (CurveEditor *self);
 
+
+void        curve_editor_set_color  (CurveEditor *self,
+                                     GdkRGBA     *color);
+
+const GdkRGBA *
+            curve_editor_get_color  (CurveEditor *self);
+
 G_END_DECLS


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