]> err.no Git - libchamplain/commitdiff
Implement fill/stroke color, and stroke width
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 26 May 2009 02:48:28 +0000 (22:48 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Wed, 10 Jun 2009 00:27:36 +0000 (20:27 -0400)
champlain/champlain-line.c
champlain/champlain-line.h
champlain/champlain-private.h
champlain/champlain-view.c

index 2ac1c4d26c09cf1fa22e6aa65a15f25f09f095f9..d43bc7de950f97e1ed95a80d6b4dfa2a4ff05eae 100644 (file)
@@ -81,6 +81,9 @@ champlain_line_get_property (GObject *object,
       case PROP_STROKE_COLOR:
         clutter_value_set_color (value, priv->stroke_color);
         break;
+      case PROP_STROKE_WIDTH:
+        g_value_set_double (value, priv->stroke_width);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -100,16 +103,24 @@ champlain_line_set_property (GObject *object,
         priv->closed_path = g_value_get_boolean (value);
         break;
       case PROP_FILL:
-        priv->fill = g_value_get_boolean (value);
+        champlain_line_set_fill (CHAMPLAIN_LINE (object),
+            g_value_get_boolean (value));
         break;
       case PROP_STROKE:
-        priv->stroke = g_value_get_boolean (value);
+        champlain_line_set_stroke (CHAMPLAIN_LINE (object),
+            g_value_get_boolean (value));
         break;
       case PROP_FILL_COLOR:
-        champlain_line_set_fill_color (CHAMPLAIN_LINE (object), clutter_value_get_color (value));
+        champlain_line_set_fill_color (CHAMPLAIN_LINE (object),
+            clutter_value_get_color (value));
         break;
       case PROP_STROKE_COLOR:
-        champlain_line_set_stroke_color (CHAMPLAIN_LINE (object), clutter_value_get_color (value));
+        champlain_line_set_stroke_color (CHAMPLAIN_LINE (object),
+            clutter_value_get_color (value));
+        break;
+      case PROP_STROKE_WIDTH:
+        champlain_line_set_stroke_width (CHAMPLAIN_LINE (object),
+            g_value_get_double (value));
         break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -152,9 +163,9 @@ champlain_line_class_init (ChamplainLineClass *klass)
   g_object_class_install_property (object_class,
       PROP_CLOSED_PATH,
       g_param_spec_boolean ("closed-path",
-         "Closed Path",
-         "The Path is Closed",
-         FALSE, CHAMPLAIN_PARAM_READWRITE));
+          "Closed Path",
+          "The Path is Closed",
+          FALSE, CHAMPLAIN_PARAM_READWRITE));
 
   /**
   * ChamplainLine:fill:
@@ -166,9 +177,9 @@ champlain_line_class_init (ChamplainLineClass *klass)
   g_object_class_install_property (object_class,
       PROP_FILL,
       g_param_spec_boolean ("fill",
-         "Fill",
-         "The shape is filled",
-         FALSE, CHAMPLAIN_PARAM_READWRITE));
+          "Fill",
+          "The shape is filled",
+          FALSE, CHAMPLAIN_PARAM_READWRITE));
 
   /**
   * ChamplainLine:stroke:
@@ -180,9 +191,55 @@ champlain_line_class_init (ChamplainLineClass *klass)
   g_object_class_install_property (object_class,
       PROP_STROKE,
       g_param_spec_boolean ("stroke",
-         "Stroke",
-         "The shape is stroked",
-         TRUE, CHAMPLAIN_PARAM_READWRITE));
+          "Stroke",
+          "The shape is stroked",
+          TRUE, CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainLine:stroke-color:
+  *
+  * The line's stroke color
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class,
+      PROP_STROKE_COLOR,
+      clutter_param_spec_color ("stroke-color",
+        "Stroke Color",
+        "The line's stroke color",
+        &DEFAULT_STROKE_COLOR,
+        CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainLine:text-color:
+  *
+  * The line's fill color
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class,
+      PROP_FILL_COLOR,
+      clutter_param_spec_color ("fill-color",
+          "Fill Color",
+          "The line's fill color",
+          &DEFAULT_FILL_COLOR,
+          CHAMPLAIN_PARAM_READWRITE));
+
+  /**
+  * ChamplainLine:stroke-width:
+  *
+  * The line's stroke width (in pixels)
+  *
+  * Since: 0.4
+  */
+  g_object_class_install_property (object_class,
+      PROP_STROKE_WIDTH,
+      g_param_spec_double ("stroke-width",
+          "Stroke Width",
+          "The line's stroke width",
+          0, 100.0,
+          2.0,
+          CHAMPLAIN_PARAM_READWRITE));
 }
 
 static void
@@ -193,6 +250,7 @@ champlain_line_init (ChamplainLine *self)
   self->priv->points = NULL;
   self->priv->fill = FALSE;
   self->priv->stroke = TRUE;
+  self->priv->stroke_width = 2.0;
 
   self->priv->fill_color = clutter_color_copy (&DEFAULT_FILL_COLOR);
   self->priv->stroke_color = clutter_color_copy (&DEFAULT_STROKE_COLOR);
@@ -326,3 +384,105 @@ champlain_line_get_stroke_color (ChamplainLine *line)
 
   return line->priv->stroke_color;
 }
+
+/**
+ * champlain_line_set_stroke:
+ * @line: The line
+ * @value: if the line is stroked
+ *
+ * Sets the line to have a stroke
+ *
+ * Since: 0.4
+ */
+void
+champlain_line_set_stroke (ChamplainLine *line,
+    gboolean value)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+
+  line->priv->stroke = value;
+}
+
+/**
+ * champlain_line_get_stroke:
+ * @line: The line
+ *
+ * Returns if the line has a stroke
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_line_get_stroke (ChamplainLine *line)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), FALSE);
+
+  return line->priv->stroke;
+}
+
+/**
+ * champlain_line_set_fill:
+ * @line: The line
+ * @value: if the line is filled
+ *
+ * Sets the line to have be filled
+ *
+ * Since: 0.4
+ */
+void
+champlain_line_set_fill (ChamplainLine *line,
+    gboolean value)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+
+  line->priv->fill = value;
+}
+
+/**
+ * champlain_line_get_fill:
+ * @line: The line
+ *
+ * Returns if the line is filled
+ *
+ * Since: 0.4
+ */
+gboolean
+champlain_line_get_fill (ChamplainLine *line)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), FALSE);
+
+  return line->priv->fill;
+}
+
+/**
+ * champlain_line_set_stroke_width:
+ * @line: The line
+ * @value: the width of the stroke (in pixels)
+ *
+ * Sets the width of the stroke
+ *
+ * Since: 0.4
+ */
+void
+champlain_line_set_stroke_width (ChamplainLine *line,
+    gdouble value)
+{
+  g_return_if_fail (CHAMPLAIN_IS_LINE (line));
+
+  line->priv->stroke_width = value;
+}
+
+/**
+ * champlain_line_get_stroke_width:
+ * @line: The line
+ *
+ * Returns the width of the stroke
+ *
+ * Since: 0.4
+ */
+gdouble
+champlain_line_get_stroke_width (ChamplainLine *line)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_LINE (line), 0);
+
+  return line->priv->stroke_width;
+}
index 081073e2a7a7280dbebd9347c8749ba5dff9dc1d..e20574ca5604849a39562c0de35615a1055e24fa 100644 (file)
@@ -74,6 +74,15 @@ void champlain_line_set_stroke_color (ChamplainLine *line,
 ClutterColor * champlain_line_get_fill_color (ChamplainLine *line);
 ClutterColor * champlain_line_get_stroke_color (ChamplainLine *line);
 
+gboolean champlain_line_get_fill (ChamplainLine *line);
+void champlain_line_set_fill (ChamplainLine *line,
+    gboolean value);
+gboolean champlain_line_get_stroke (ChamplainLine *line);
+void champlain_line_set_stroke (ChamplainLine *line,
+    gboolean value);
+void champlain_line_set_stroke_width (ChamplainLine *line,
+    gdouble value);
+gdouble champlain_line_get_stroke_width (ChamplainLine *line);
 G_END_DECLS
 
 #endif
index 2576d0285f802678e407af4fc7840e42dca39dff..2777a5ae856e0c957523e330bb46c1036f098cac 100644 (file)
@@ -44,6 +44,7 @@ struct _ChamplainLinePrivate {
   gboolean fill;
   ClutterColor *fill_color;
   gboolean stroke;
+  gdouble stroke_width;
 };
 
 typedef struct
index eae2cc701ab8029ccde325ebd34a8388e3740776..cc61c30e3329a6639b0babd9821de8c7caec1ab1 100644 (file)
@@ -2219,6 +2219,8 @@ draw_line (ChamplainView *view, cairo_t *cr, ChamplainLine *line)
       line->priv->stroke_color->blue / 255.0,
       line->priv->stroke_color->alpha / 255.0);
 
+  cairo_set_line_width (cr, line->priv->stroke_width);
+
   if (line->priv->stroke)
     cairo_stroke (cr);
 }