[glide] Shapes have some new paint action



commit 83f29f8329a928dfb35fff1bf409b3e32d8d1948
Author: Robert Carr <racarr Valentine localdomain>
Date:   Thu May 6 07:22:18 2010 -0400

    Shapes have some new paint action

 libglide/glide-shape.c |   98 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 66 insertions(+), 32 deletions(-)
---
diff --git a/libglide/glide-shape.c b/libglide/glide-shape.c
index 888b501..c2b8367 100644
--- a/libglide/glide-shape.c
+++ b/libglide/glide-shape.c
@@ -37,41 +37,75 @@ enum
 static const ClutterColor default_color = {255,255,255,255};
 static const ClutterColor default_border_color = {0,0,0,255};
 
-static void
-glide_shape_paint (ClutterActor *self)
+static void 
+glide_shape_paint_rectangle (ClutterActor *self)
 {
-  ClutterGeometry          geom;
+  GlideShapePrivate *priv = GLIDE_SHAPE(self)->priv;
+  ClutterGeometry geom;
+  guint8 tmp_alpha;
 
   clutter_actor_get_allocation_geometry (self, &geom);
 
-  cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
-
-  
-  cogl_rectangle (10, 0,
-		  geom.width,
-		  10);
-  
-  cogl_rectangle (geom.width - 10,
-		  10,
-		  geom.width,
-		  geom.height);
-  
-  cogl_rectangle (0, geom.height - 10,
-		  geom.width - 10,
-		  geom.height);
-  
-  cogl_rectangle (0, 0,
-		  10,
-		  geom.height - 10);
-  
-  
-  cogl_set_source_color4ub (0x00, 0xff, 0x00, 0xff);
+  if (priv->has_border)
+    {
+      tmp_alpha = clutter_actor_get_paint_opacity (self)
+                * priv->border_color.alpha
+                / 255;
+
+      cogl_set_source_color4ub (priv->border_color.red,
+                                priv->border_color.green,
+                                priv->border_color.blue,
+                                tmp_alpha);
+
+      cogl_rectangle (priv->border_width, 0,
+                      geom.width,
+                      priv->border_width);
+
+      cogl_rectangle (geom.width - priv->border_width,
+                      priv->border_width,
+                      geom.width,
+                      geom.height);
+
+      cogl_rectangle (0, geom.height - priv->border_width,
+                      geom.width - priv->border_width,
+                      geom.height);
+
+      cogl_rectangle (0, 0,
+                      priv->border_width,
+                      geom.height - priv->border_width);
+
+      tmp_alpha = clutter_actor_get_paint_opacity (self)
+                * priv->color.alpha
+                / 255;
+
+      cogl_set_source_color4ub (priv->color.red,
+                                priv->color.green,
+                                priv->color.blue,
+                                tmp_alpha);
+
+      cogl_rectangle (priv->border_width, priv->border_width,
+                      geom.width - priv->border_width,
+                      geom.height - priv->border_width);
+    }
+  else
+    {
+      tmp_alpha = clutter_actor_get_paint_opacity (self)
+                * priv->color.alpha
+                / 255;
 
-  cogl_rectangle (10, 10,
-		  geom.width - 10,
-		  geom.height - 10);
+      cogl_set_source_color4ub (priv->color.red,
+                                priv->color.green,
+                                priv->color.blue,
+                                tmp_alpha);
 
+      cogl_rectangle (0, 0, geom.width, geom.height);
+    }
+}
 
+static void
+glide_shape_paint (ClutterActor *self)
+{
+  glide_shape_paint_rectangle (self);
 }
 
 static void
@@ -229,14 +263,14 @@ glide_shape_class_init (GlideShapeClass *klass)
                                     "Color",
                                     "The color of the rectangle",
                                     &default_color,
-                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
   g_object_class_install_property (gobject_class, PROP_COLOR, pspec);
 
   pspec = clutter_param_spec_color ("border-color",
                                     "Border Color",
                                     "The color of the border of the rectangle",
                                     &default_border_color,
-                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT);
   g_object_class_install_property (gobject_class, PROP_BORDER_COLOR, pspec);
 
   g_object_class_install_property (gobject_class,
@@ -246,14 +280,14 @@ glide_shape_class_init (GlideShapeClass *klass)
                                                       "The width of the border of the rectangle",
                                                       0, G_MAXUINT,
                                                       5,
-                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
   g_object_class_install_property (gobject_class,
                                    PROP_HAS_BORDER,
                                    g_param_spec_boolean ("has-border",
                                                          "Has Border",
                                                          "Whether the rectangle should have a border",
                                                          TRUE,
-                                                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+                                                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
 }
 
 static void



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