[glide] Shapes have some properties
- From: Robert Carr <racarr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glide] Shapes have some properties
- Date: Thu, 6 May 2010 11:55:33 +0000 (UTC)
commit f425d1e56c32396c928ba3d610b6c3862d20b41f
Author: Robert Carr <racarr Valentine localdomain>
Date: Thu May 6 07:14:55 2010 -0400
Shapes have some properties
libglide/glide-shape-priv.h | 6 ++
libglide/glide-shape.c | 174 +++++++++++++++++++++++++++++++++++++++++++
libglide/glide-shape.h | 15 ++++
3 files changed, 195 insertions(+), 0 deletions(-)
---
diff --git a/libglide/glide-shape-priv.h b/libglide/glide-shape-priv.h
index 3057bae..efef09a 100644
--- a/libglide/glide-shape-priv.h
+++ b/libglide/glide-shape-priv.h
@@ -26,6 +26,12 @@ G_BEGIN_DECLS
struct _GlideShapePrivate
{
+ ClutterColor color;
+ ClutterColor border_color;
+
+ guint border_width;
+ gboolean has_border;
+
gboolean dragging;
gboolean motion_since_press;
gfloat drag_center_x, drag_center_y;
diff --git a/libglide/glide-shape.c b/libglide/glide-shape.c
index 49f392c..888b501 100644
--- a/libglide/glide-shape.c
+++ b/libglide/glide-shape.c
@@ -24,6 +24,19 @@
G_DEFINE_TYPE (GlideShape, glide_shape, GLIDE_TYPE_ACTOR);
+enum
+ {
+ PROP_0,
+
+ PROP_COLOR,
+ PROP_BORDER_COLOR,
+ PROP_BORDER_WIDTH,
+ PROP_HAS_BORDER
+ };
+
+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)
{
@@ -61,6 +74,64 @@ glide_shape_paint (ClutterActor *self)
}
+static void
+glide_shape_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GlideShape *shape = (GlideShape *)object;
+
+ switch (prop_id)
+ {
+ case PROP_COLOR:
+ glide_shape_set_color (shape, clutter_value_get_color (value));
+ break;
+ case PROP_BORDER_COLOR:
+ glide_shape_set_border_color (shape,
+ clutter_value_get_color (value));
+ break;
+ case PROP_BORDER_WIDTH:
+ glide_shape_set_border_width (shape,
+ g_value_get_uint (value));
+ break;
+ case PROP_HAS_BORDER:
+ glide_shape_set_has_border (shape, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+glide_shape_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GlideShapePrivate *priv = GLIDE_SHAPE(object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_COLOR:
+ clutter_value_set_color (value, &priv->color);
+ break;
+ case PROP_BORDER_COLOR:
+ clutter_value_set_color (value, &priv->border_color);
+ break;
+ case PROP_BORDER_WIDTH:
+ g_value_set_uint (value, priv->border_width);
+ break;
+ case PROP_HAS_BORDER:
+ g_value_set_boolean (value, priv->has_border);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static gboolean
glide_shape_button_press (ClutterActor *actor,
ClutterButtonEvent *event)
@@ -128,19 +199,61 @@ glide_shape_motion (ClutterActor *actor,
}
return FALSE;
}
+
+static void
+glide_shape_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (glide_shape_parent_class)->finalize (object);
+}
static void
glide_shape_class_init (GlideShapeClass *klass)
{
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
g_type_class_add_private (klass, sizeof (GlideShapePrivate));
+ gobject_class->finalize = glide_shape_finalize;
+ gobject_class->set_property = glide_shape_set_property;
+ gobject_class->get_property = glide_shape_get_property;
+
actor_class->paint = glide_shape_paint;
actor_class->button_press_event = glide_shape_button_press;
actor_class->button_release_event = glide_shape_button_release;
actor_class->motion_event = glide_shape_motion;
+
+ pspec = clutter_param_spec_color ("color",
+ "Color",
+ "The color of the rectangle",
+ &default_color,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ 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_object_class_install_property (gobject_class, PROP_BORDER_COLOR, pspec);
+
+ g_object_class_install_property (gobject_class,
+ PROP_BORDER_WIDTH,
+ g_param_spec_uint ("border-width",
+ "Border Width",
+ "The width of the border of the rectangle",
+ 0, G_MAXUINT,
+ 5,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ 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));
}
static void
@@ -157,3 +270,64 @@ glide_shape_new ()
return g_object_new (GLIDE_TYPE_SHAPE, NULL);
}
+void
+glide_shape_set_color (GlideShape *shape,
+ const ClutterColor *color)
+{
+ shape->priv->color = *color;
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (shape));
+
+ g_object_notify (G_OBJECT (shape), "color");
+}
+
+void
+glide_shape_set_border_color (GlideShape *shape,
+ const ClutterColor *border_color)
+{
+ shape->priv->border_color = *border_color;
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (shape));
+
+ g_object_notify (G_OBJECT (shape), "border-color");
+}
+
+void
+glide_shape_get_color (GlideShape *shape, ClutterColor *color)
+{
+ *color = shape->priv->color;
+}
+
+void
+glide_shape_get_border_color (GlideShape *shape, ClutterColor *border_color)
+{
+ *border_color = shape->priv->border_color;
+}
+
+guint
+glide_shape_get_border_width (GlideShape *shape)
+{
+ return shape->priv->border_width;
+}
+
+void
+glide_shape_set_border_width (GlideShape *shape, guint border_width)
+{
+ shape->priv->border_width = border_width;
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (shape));
+
+ g_object_notify (G_OBJECT (shape), "border-width");
+}
+
+void
+glide_shape_set_has_border (GlideShape *shape, gboolean has_border)
+{
+ shape->priv->has_border = has_border;
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (shape));
+
+ g_object_notify (G_OBJECT (shape), "has-border");
+}
+
+gboolean
+glide_shape_get_has_border (GlideShape *shape)
+{
+ return shape->priv->has_border;
+}
diff --git a/libglide/glide-shape.h b/libglide/glide-shape.h
index 5936a00..ea08a6c 100644
--- a/libglide/glide-shape.h
+++ b/libglide/glide-shape.h
@@ -54,6 +54,21 @@ struct _GlideShapeClass
GType glide_shape_get_type (void) G_GNUC_CONST;
ClutterActor *glide_shape_new ();
+void glide_shape_get_color (GlideShape *shape,
+ ClutterColor *color);
+void glide_shape_set_color (GlideShape *shape,
+ const ClutterColor *color);
+guint glide_shape_get_border_width (GlideShape *shape);
+void glide_shape_set_border_width (GlideShape *shape,
+ guint width);
+void glide_shape_get_border_color (GlideShape *shape,
+ ClutterColor *color);
+void glide_shape_set_border_color (GlideShape *shape,
+ const ClutterColor *color);
+
+gboolean glide_shape_get_has_border (GlideShape *shape);
+void glide_shape_set_has_border (GlideShape *shape, gboolean has_border);
+
G_END_DECLS
#endif /* __CLUTTER_SHAPE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]