From 10fbfb16598dd7613248a562387f8555f47add66 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 12 Dec 2006 20:20:04 +0000 Subject: [PATCH] 2006-12-12 Emmanuele Bassi Rework part of the show/hide machinery. Allow groups sub-classes and composite actors to override show_all/hide_all in order to decide which children they wish to show/hide. This means that if an actor overrides the default show/hide virtual methods, it'll have to chain up to the parent class show/hide. While we're at it, provide the fully recursive clutter_actor_show_all() and clutter_actor_hide_all() methods. * clutter/clutter-behaviour-path.c: Add apidoc for the ClutterKnot functions; add pathological equality case for clutter_knot_equal(). * clutter/clutter-event.h: * clutter/clutter-feature.h: * clutter/clutter-behaviour.c: * clutter/clutter-behaviour-scale.c:Fix parameters name so that gtk-doc doesn't complain. * clutter/clutter-actor.c: * clutter/clutter-event.c: Add apidoc * clutter/clutter-actor.h: * clutter/clutter-actor.c: Add a clutter_actor_show_all() and a clutter_actor_hide_all() functions; provide a mechanism for groups and composited actors to programmatically select what to show/hide when clutter_actor_show_all() and clutter_actor_hide_all() are called. If you are overriding the ClutterActor::show or the ClutterActor::hide virtual methods you should chain up with the parent class. * clutter/clutter-group.c: Override show_all and hide_all and recursively show/hide every child inside the group; clutter_group_show_all() and clutter_group_hide_all() remain as non recursive versions of clutter_actor_show_all() and clutter_actor_hide_all() (maybe we should rename them in order to avoid name clashes with the bindings). * clutter/clutter-stage.c: * clutter/clutter-texture.c: Chain up with parent class show and hide vfuncs. * clutter/clutter-clone-texture.h: * clutter/clutter-clone-texture.c: Provide API for changing the parent texture of a clone texture actor. * examples/behave.c: * examples/super-oh.c: * examples/test.c: Use clutter_actor_show_all() instead of clutter_group_show_all(). --- ChangeLog | 51 +++++++++ clutter/clutter-actor.c | 134 ++++++++++++++++-------- clutter/clutter-actor.h | 20 ++-- clutter/clutter-behaviour-path.c | 32 ++++++ clutter/clutter-behaviour-scale.c | 1 + clutter/clutter-behaviour.c | 10 +- clutter/clutter-clone-texture.c | 96 +++++++++++++---- clutter/clutter-clone-texture.h | 11 +- clutter/clutter-event.c | 36 +++++++ clutter/clutter-event.h | 29 +++-- clutter/clutter-feature.h | 4 +- clutter/clutter-group.c | 50 ++++++--- clutter/clutter-stage.c | 24 +++-- clutter/clutter-texture.c | 14 +++ clutter/clutter-texture.h | 17 ++- doc/reference/clutter-sections.txt | 6 +- doc/reference/tmpl/clutter-actor.sgml | 4 +- doc/reference/tmpl/clutter-color.sgml | 8 -- doc/reference/tmpl/clutter-event.sgml | 17 --- doc/reference/tmpl/clutter-feature.sgml | 2 +- doc/reference/tmpl/clutter-texture.sgml | 6 ++ examples/behave.c | 6 +- examples/super-oh.c | 3 +- examples/test.c | 2 +- 24 files changed, 422 insertions(+), 161 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f2fb1ed9..300a783b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,54 @@ +2006-12-12 Emmanuele Bassi + + Rework part of the show/hide machinery. Allow groups sub-classes + and composite actors to override show_all/hide_all in order to + decide which children they wish to show/hide. This means that + if an actor overrides the default show/hide virtual methods, it'll + have to chain up to the parent class show/hide. While we're at it, + provide the fully recursive clutter_actor_show_all() and + clutter_actor_hide_all() methods. + + * clutter/clutter-behaviour-path.c: Add apidoc for the ClutterKnot + functions; add pathological equality case for clutter_knot_equal(). + + * clutter/clutter-event.h: + * clutter/clutter-feature.h: + * clutter/clutter-behaviour.c: + * clutter/clutter-behaviour-scale.c:Fix parameters name so that + gtk-doc doesn't complain. + + * clutter/clutter-actor.c: + * clutter/clutter-event.c: Add apidoc + + * clutter/clutter-actor.h: + * clutter/clutter-actor.c: Add a clutter_actor_show_all() and a + clutter_actor_hide_all() functions; provide a mechanism for + groups and composited actors to programmatically select what to + show/hide when clutter_actor_show_all() and clutter_actor_hide_all() + are called. If you are overriding the ClutterActor::show or + the ClutterActor::hide virtual methods you should chain up with + the parent class. + + * clutter/clutter-group.c: Override show_all and hide_all and + recursively show/hide every child inside the group; + clutter_group_show_all() and clutter_group_hide_all() remain as non + recursive versions of clutter_actor_show_all() and + clutter_actor_hide_all() (maybe we should rename them in order + to avoid name clashes with the bindings). + + * clutter/clutter-stage.c: + * clutter/clutter-texture.c: Chain up with parent class show + and hide vfuncs. + + * clutter/clutter-clone-texture.h: + * clutter/clutter-clone-texture.c: Provide API for changing the + parent texture of a clone texture actor. + + * examples/behave.c: + * examples/super-oh.c: + * examples/test.c: Use clutter_actor_show_all() instead of + clutter_group_show_all(). + 2006-12-08 Matthew Allum * clutter.doap: diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 35d9accfd..89dba52db 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -114,6 +114,21 @@ redraw_update_idle (gpointer data) return FALSE; } +static void +clutter_actor_real_show (ClutterActor *self) +{ + if (!CLUTTER_ACTOR_IS_VISIBLE (self)) + { + if (!CLUTTER_ACTOR_IS_REALIZED (self)) + clutter_actor_realize (self); + + CLUTTER_ACTOR_SET_FLAGS (self, CLUTTER_ACTOR_MAPPED); + + if (CLUTTER_ACTOR_IS_VISIBLE (self)) + clutter_actor_queue_redraw (self); + } +} + /** * clutter_actor_show * @self: A #ClutterActor @@ -126,22 +141,8 @@ clutter_actor_show (ClutterActor *self) { if (!CLUTTER_ACTOR_IS_VISIBLE (self)) { - ClutterActorClass *klass; - g_object_ref (self); - if (!CLUTTER_ACTOR_IS_REALIZED (self)) - clutter_actor_realize(self); - - CLUTTER_ACTOR_SET_FLAGS (self, CLUTTER_ACTOR_MAPPED); - - klass = CLUTTER_ACTOR_GET_CLASS (self); - if (klass->show) - (klass->show) (self); - - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); - g_signal_emit (self, actor_signals[SHOW], 0); g_object_notify (G_OBJECT (self), "visible"); @@ -149,6 +150,37 @@ clutter_actor_show (ClutterActor *self) } } +/** + * clutter_actor_show_all: + * @self: a #ClutterActor + * + * Recursively show an actor, and any child actor if @self is a + * #ClutterGroup. + * + * Since: 0.2 + */ +void +clutter_actor_show_all (ClutterActor *self) +{ + ClutterActorClass *klass; + + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + + klass = CLUTTER_ACTOR_GET_CLASS (self); + if (klass->show_all) + klass->show_all (self); +} + +void +clutter_actor_real_hide (ClutterActor *self) +{ + if (CLUTTER_ACTOR_IS_VISIBLE (self)) + { + CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_MAPPED); + clutter_actor_queue_redraw (self); + } +} + /** * clutter_actor_hide * @self: A #ClutterActor @@ -161,18 +193,8 @@ clutter_actor_hide (ClutterActor *self) { if (CLUTTER_ACTOR_IS_VISIBLE (self)) { - ClutterActorClass *klass; - g_object_ref (self); - CLUTTER_ACTOR_UNSET_FLAGS (self, CLUTTER_ACTOR_MAPPED); - - klass = CLUTTER_ACTOR_GET_CLASS (self); - if (klass->hide) - (klass->hide) (self); - - clutter_actor_queue_redraw (self); - g_signal_emit (self, actor_signals[HIDE], 0); g_object_notify (G_OBJECT (self), "visible"); @@ -180,6 +202,27 @@ clutter_actor_hide (ClutterActor *self) } } +/** + * clutter_actor_hide_all: + * @self: a #ClutterActor + * + * Recursively hides an actor, and any child actor if @self + * is a #ClutterGroup. + * + * Since: 0.2 + */ +void +clutter_actor_hide_all (ClutterActor *self) +{ + ClutterActorClass *klass; + + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + + klass = CLUTTER_ACTOR_GET_CLASS (self); + if (klass->hide_all) + klass->hide_all (self); +} + /** * clutter_actor_realize * @self: A #ClutterActor @@ -776,18 +819,16 @@ clutter_actor_class_init (ClutterActorClass *klass) clutter_marshal_VOID__OBJECT, G_TYPE_NONE, 1, CLUTTER_TYPE_ACTOR); + + klass->show = clutter_actor_real_show; + klass->show_all = clutter_actor_show; + klass->hide = clutter_actor_real_hide; + klass->hide_all = clutter_actor_hide; } static void clutter_actor_init (ClutterActor *self) { - gboolean was_floating; - - /* sink the GInitiallyUnowned floating flag */ - was_floating = g_object_is_floating (G_OBJECT (self)); - if (was_floating) - g_object_force_floating (G_OBJECT (self)); - self->priv = CLUTTER_ACTOR_GET_PRIVATE (self); self->priv->parent_actor = NULL; @@ -1011,7 +1052,7 @@ clutter_actor_set_size (ClutterActor *self, } /* - * clutter_actor_get_size + * clutter_actor_get_size: * @self: A #ClutterActor * @width: Location to store width if non NULL. * @height: Location to store height if non NULL. @@ -1092,10 +1133,10 @@ clutter_actor_get_abs_position (ClutterActor *self, } /** - * clutter_actor_get_abs_size + * clutter_actor_get_abs_size: * @self: A #ClutterActor - * @x: Location to store width if non NULL. - * @y: Location to store height if non NULL. + * @width: Location to store width if non NULL. + * @height: Location to store height if non NULL. * * Gets the absolute size of an actor taking into account * an scaling factors @@ -1265,12 +1306,14 @@ clutter_actor_set_scale (ClutterActor *self, } /** - * clutter_actor_get_scalex + * clutter_actor_get_scalex: * @self: A #ClutterActor * @scale_x: FIXME * @scale_y: FIXME * * FIXME + * + * Since: 0.2 */ void clutter_actor_get_scalex (ClutterActor *self, @@ -1285,12 +1328,14 @@ clutter_actor_get_scalex (ClutterActor *self, } /** - * clutter_actor_get_scale + * clutter_actor_get_scale: * @self: A #ClutterActor * @scale_x: FIXME * @scale_y: FIXME * * FIXME + * + * Since: 0.2 */ void clutter_actor_get_scale (ClutterActor *self, @@ -1417,10 +1462,16 @@ void clutter_actor_set_depth (ClutterActor *self, gint depth) { - /* Sets Z value. - FIXME: should invert ?*/ - self->priv->z = depth; + ClutterActorPrivate *priv; - if (self->priv->parent_actor) + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + + priv = self->priv; + + /* Sets Z value. - FIXME: should invert ?*/ + priv->z = depth; + + if (priv->parent_actor) { /* We need to resort the group stacking order as to * correctly render alpha values. @@ -1428,8 +1479,7 @@ clutter_actor_set_depth (ClutterActor *self, * FIXME: This is sub optimal. maybe queue the the sort * before stacking */ - clutter_group_sort_depth_order - (CLUTTER_GROUP(self->priv->parent_actor)); + clutter_group_sort_depth_order (CLUTTER_GROUP (priv->parent_actor)); } } diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index a16e15897..20ca4f70b 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -50,19 +50,19 @@ G_BEGIN_DECLS #define CLUTTER_ACTOR_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_ACTOR, ClutterActorClass)) -#define CLUTTER_ACTOR_SET_FLAGS(e,f) ((e)->flags |= (f)) -#define CLUTTER_ACTOR_UNSET_FLAGS(e,f) ((e)->flags &= ~(f)) +#define CLUTTER_ACTOR_SET_FLAGS(e,f) ((e)->flags |= (f)) +#define CLUTTER_ACTOR_UNSET_FLAGS(e,f) ((e)->flags &= ~(f)) -#define CLUTTER_ACTOR_IS_MAPPED(e) ((e)->flags & CLUTTER_ACTOR_MAPPED) -#define CLUTTER_ACTOR_IS_REALIZED(e) ((e)->flags & CLUTTER_ACTOR_REALIZED) -#define CLUTTER_ACTOR_IS_VISIBLE(e) \ - (CLUTTER_ACTOR_IS_MAPPED(e) && CLUTTER_ACTOR_IS_REALIZED(e)) +#define CLUTTER_ACTOR_IS_MAPPED(e) ((e)->flags & CLUTTER_ACTOR_MAPPED) +#define CLUTTER_ACTOR_IS_REALIZED(e) ((e)->flags & CLUTTER_ACTOR_REALIZED) +#define CLUTTER_ACTOR_IS_VISIBLE(e) (CLUTTER_ACTOR_IS_MAPPED (e) && \ + CLUTTER_ACTOR_IS_REALIZED (e)) typedef struct _ClutterActor ClutterActor; typedef struct _ClutterActorClass ClutterActorClass; typedef struct _ClutterActorBox ClutterActorBox; typedef struct _ClutterActorPrivate ClutterActorPrivate; -typedef struct _ClutterGeometry ClutterGeometry; +typedef struct _ClutterGeometry ClutterGeometry; typedef void (*ClutterCallback) (ClutterActor *actor, gpointer data); #define CLUTTER_CALLBACK(f) ((ClutterCallback) (f)) @@ -108,7 +108,9 @@ struct _ClutterActorClass GObjectClass parent_class; void (* show) (ClutterActor *actor); + void (* show_all) (ClutterActor *actor); void (* hide) (ClutterActor *actor); + void (* hide_all) (ClutterActor *actor); void (* realize) (ClutterActor *actor); void (* unrealize) (ClutterActor *actor); void (* paint) (ClutterActor *actor); @@ -125,8 +127,6 @@ struct _ClutterActorClass void (* destroy) (ClutterActor *actor); /* to go ? */ - void (* show_all) (ClutterActor *actor); - void (* hide_all) (ClutterActor *actor); void (* queue_redraw) (ClutterActor *actor); /* padding for future expansion */ @@ -140,7 +140,9 @@ struct _ClutterActorClass GType clutter_actor_get_type (void) G_GNUC_CONST; void clutter_actor_show (ClutterActor *self); +void clutter_actor_show_all (ClutterActor *self); void clutter_actor_hide (ClutterActor *self); +void clutter_actor_hide_all (ClutterActor *self); void clutter_actor_realize (ClutterActor *self); void clutter_actor_unrealize (ClutterActor *self); void clutter_actor_paint (ClutterActor *self); diff --git a/clutter/clutter-behaviour-path.c b/clutter/clutter-behaviour-path.c index 41eecd2e7..01d20f863 100644 --- a/clutter/clutter-behaviour-path.c +++ b/clutter/clutter-behaviour-path.c @@ -55,6 +55,16 @@ #include +/** + * clutter_knot_copy: + * @knot: a #ClutterKnot + * + * Makes an allocated copy of a knot. + * + * Return value: the copied knot. + * + * Since: 0.2 + */ ClutterKnot * clutter_knot_copy (const ClutterKnot *knot) { @@ -67,6 +77,14 @@ clutter_knot_copy (const ClutterKnot *knot) return copy; } +/** + * clutter_knot_free: + * @knot: a #ClutterKnot + * + * Frees the memory of an allocated knot. + * + * Since: 0.2 + */ void clutter_knot_free (ClutterKnot *knot) { @@ -76,6 +94,17 @@ clutter_knot_free (ClutterKnot *knot) } } +/** + * clutter_knot_equal: + * @knot_a: First knot + * @knot_b: Second knot + * + * Compares to knot and checks if the point to the same location. + * + * Return value: %TRUE if the knots point to the same location. + * + * Since: 0.2 + */ gboolean clutter_knot_equal (const ClutterKnot *knot_a, const ClutterKnot *knot_b) @@ -83,6 +112,9 @@ clutter_knot_equal (const ClutterKnot *knot_a, g_return_val_if_fail (knot_a != NULL, FALSE); g_return_val_if_fail (knot_b != NULL, FALSE); + if (knot_a == knot_b) + return TRUE; + return knot_a->x == knot_b->x && knot_a->y == knot_b->y; } diff --git a/clutter/clutter-behaviour-scale.c b/clutter/clutter-behaviour-scale.c index 406fcd50e..1530987f0 100644 --- a/clutter/clutter-behaviour-scale.c +++ b/clutter/clutter-behaviour-scale.c @@ -301,6 +301,7 @@ clutter_behaviour_scale_new (ClutterAlpha *alpha, * @alpha: a #ClutterAlpha * @scale_begin: initial scale factor * @scale_end: final scale factor + * @gravity: FIXME * * A fixed point implementation of clutter_behaviour_scale_new() * diff --git a/clutter/clutter-behaviour.c b/clutter/clutter-behaviour.c index 4f5913dca..88ef626b2 100644 --- a/clutter/clutter-behaviour.c +++ b/clutter/clutter-behaviour.c @@ -376,9 +376,9 @@ clutter_behaviour_set_alpha (ClutterBehaviour *behave, /** * clutter_behaviour_get_actors: - * @behaviour: a #ClutterBehaviour + * @behave: a #ClutterBehaviour * - * Retrieves all the actors to which @behaviour applies. + * Retrieves all the actors to which @behave applies. * * Return value: a list of actors. You should free the returned list * with g_slist_free() when finished using it. @@ -386,14 +386,14 @@ clutter_behaviour_set_alpha (ClutterBehaviour *behave, * Since: 0.2 */ GSList * -clutter_behaviour_get_actors (ClutterBehaviour *behaviour) +clutter_behaviour_get_actors (ClutterBehaviour *behave) { GSList *retval, *l; - g_return_val_if_fail (CLUTTER_BEHAVIOUR (behaviour), NULL); + g_return_val_if_fail (CLUTTER_BEHAVIOUR (behave), NULL); retval = NULL; - for (l = behaviour->priv->actors; l != NULL; l = l->next) + for (l = behave->priv->actors; l != NULL; l = l->next) retval = g_slist_prepend (retval, l->data); return g_slist_reverse (retval); diff --git a/clutter/clutter-clone-texture.c b/clutter/clutter-clone-texture.c index 20edee00b..ca6c2dc07 100644 --- a/clutter/clutter-clone-texture.c +++ b/clutter/clutter-clone-texture.c @@ -35,6 +35,7 @@ #include "clutter-clone-texture.h" #include "clutter-main.h" #include "clutter-feature.h" +#include "clutter-actor.h" #include "clutter-util.h" #include "clutter-enum-types.h" #include "clutter-private.h" @@ -121,11 +122,11 @@ clone_texture_render_to_gl_quad (ClutterCloneTexture *ctexture, clutter_texture_get_n_tiles (priv->parent_texture, &n_x_tiles, &n_y_tiles); - for (x=0; x < n_x_tiles; x++) + for (x = 0; x < n_x_tiles; x++) { lasty = 0; - for (y=0; y < n_y_tiles; y++) + for (y = 0; y < n_y_tiles; y++) { gint actual_w, actual_h; gint xpos, ypos, xsize, ysize, ywaste, xwaste; @@ -180,6 +181,9 @@ clutter_clone_texture_paint (ClutterActor *self) priv = CLUTTER_CLONE_TEXTURE (self)->priv; + /* no need to paint stuff if we don't have a texture to clone */ + if (!priv->parent_texture) + return; /* parent texture may have been hidden, there for need to make sure its * realised with resources available. @@ -190,17 +194,17 @@ clutter_clone_texture_paint (ClutterActor *self) /* FIXME: figure out nicer way of getting at this info... */ - if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) - && clutter_texture_is_tiled (CLUTTER_TEXTURE(parent_texture)) == FALSE) + if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) && + clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture)) == FALSE) target_type = GL_TEXTURE_RECTANGLE_ARB; else target_type = GL_TEXTURE_2D; - glEnable(GL_BLEND); - glEnable(target_type); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_BLEND); + glEnable (target_type); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4ub(255, 255, 255, clutter_actor_get_opacity(self)); + glColor4ub (255, 255, 255, clutter_actor_get_opacity (self)); clutter_actor_get_coords (self, &x1, &y1, &x2, &y2); @@ -210,10 +214,10 @@ clutter_clone_texture_paint (ClutterActor *self) clutter_actor_get_opacity (self)); /* Parent paint translated us into position */ - clone_texture_render_to_gl_quad (CLUTTER_CLONE_TEXTURE(self), + clone_texture_render_to_gl_quad (CLUTTER_CLONE_TEXTURE (self), 0, 0, x2 - x1, y2 - y1); - glDisable(target_type); - glDisable(GL_BLEND); + glDisable (target_type); + glDisable (GL_BLEND); } static void @@ -221,6 +225,7 @@ set_parent_texture (ClutterCloneTexture *ctexture, ClutterTexture *texture) { ClutterCloneTexturePrivate *priv = ctexture->priv; + ClutterActor *actor = CLUTTER_ACTOR (ctexture); if (priv->parent_texture) { @@ -228,16 +233,22 @@ set_parent_texture (ClutterCloneTexture *ctexture, priv->parent_texture = NULL; } + clutter_actor_hide (actor); + if (texture) { gint width, height; priv->parent_texture = g_object_ref (texture); - /* Sync up the size to parent texture base pixbuf size. - */ + /* Sync up the size to parent texture base pixbuf size. */ clutter_texture_get_base_size (texture, &width, &height); - clutter_actor_set_size (CLUTTER_ACTOR(ctexture), width, height); + clutter_actor_set_size (actor, width, height); + + /* queue a redraw if the cloned texture is already visible */ + if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (priv->parent_texture)) && + CLUTTER_ACTOR_IS_VISIBLE (actor)) + clutter_actor_queue_redraw (actor); } } @@ -303,10 +314,10 @@ clutter_clone_texture_get_property (GObject *object, static void clutter_clone_texture_class_init (ClutterCloneTextureClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - actor_class->paint = clutter_clone_texture_paint; + actor_class->paint = clutter_clone_texture_paint; gobject_class->finalize = clutter_clone_texture_finalize; gobject_class->dispose = clutter_clone_texture_dispose; @@ -319,7 +330,7 @@ clutter_clone_texture_class_init (ClutterCloneTextureClass *klass) "Parent Texture", "The parent texture to clone", CLUTTER_TYPE_TEXTURE, - (G_PARAM_CONSTRUCT_ONLY | CLUTTER_PARAM_READWRITE))); + (G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE))); g_type_class_add_private (gobject_class, sizeof (ClutterCloneTexturePrivate)); } @@ -335,19 +346,64 @@ clutter_clone_texture_init (ClutterCloneTexture *self) /** * clutter_clone_texture_new: - * @texture: a #ClutterTexture + * @texture: a #ClutterTexture or %NULL * * Creates an efficient 'clone' of a pre-existing texture if which it - * shares the underlying pixbuf data. + * shares the underlying pixbuf data. + * + * You can use clutter_clone_texture_set_parent_texture() to change the + * parent texture to be cloned. * * Return value: the newly created #ClutterCloneTexture */ ClutterActor * clutter_clone_texture_new (ClutterTexture *texture) { - g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), NULL); + g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL); return g_object_new (CLUTTER_TYPE_CLONE_TEXTURE, "parent-texture", texture, NULL); } + +/** + * clutter_clone_texture_get_parent_texture: + * @clone: a #ClutterCloneTexture + * + * Retrieves the parent #ClutterTexture used by @clone. + * + * Return value: a #ClutterTexture actor, or %NULL + * + * Since: 0.2 + */ +ClutterTexture * +clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone) +{ + g_return_val_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone), NULL); + + return clone->priv->parent_texture; +} + +/** + * clutter_clone_texture_set_parent_texture: + * @clone: a #ClutterCloneTexture + * @texture a #ClutterTexture or %NULL + * + * Sets the parent texture cloned by the #ClutterCloneTexture. + * + * Since: 0.2 + */ +void +clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone, + ClutterTexture *texture) +{ + g_return_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone)); + g_return_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture)); + + g_object_ref (clone); + + set_parent_texture (clone, texture); + + g_object_notify (G_OBJECT (clone), "parent-texture"); + g_object_unref (clone); +} diff --git a/clutter/clutter-clone-texture.h b/clutter/clutter-clone-texture.h index 79af11467..f34c7798d 100644 --- a/clutter/clutter-clone-texture.h +++ b/clutter/clutter-clone-texture.h @@ -26,8 +26,7 @@ #ifndef _HAVE_CLUTTER_CLONE_TEXTURE_H #define _HAVE_CLUTTER_CLONE_TEXTURE_H -#include -#include +#include #include G_BEGIN_DECLS @@ -77,8 +76,12 @@ struct _ClutterCloneTextureClass void (*_clutter_clone_4) (void); }; -GType clutter_clone_texture_get_type (void); -ClutterActor *clutter_clone_texture_new (ClutterTexture *texture); +GType clutter_clone_texture_get_type (void) G_GNUC_CONST; + +ClutterActor * clutter_clone_texture_new (ClutterTexture *texture); +ClutterTexture *clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone); +void clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone, + ClutterTexture *texture); G_END_DECLS diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index 8262ab80d..e9c080014 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -23,29 +23,65 @@ * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "clutter-event.h" #include #include +/** + * clutter_event_type: + * @event: a #ClutterEvent + * + * Retrieves the type of the event. + * + * Return value: a #ClutterEventType + */ ClutterEventType clutter_event_type (ClutterEvent *event) { return event->type; } +/** + * clutter_button_event_time: + * @buttev: a #ClutterButtonEvent + * + * Retrieves the time of the event. + * + * Return value: the time of the event. + */ guint32 clutter_button_event_time (ClutterButtonEvent *buttev) { return buttev->time; } +/** + * clutter_button_event_x: + * @buttev: a #ClutterButtonEvent + * + * Retrieve the x coordinate of the event. + * + * Return value: the x coordinate. + */ gint clutter_button_event_x (ClutterButtonEvent *buttev) { return buttev->x; } +/** + * clutter_button_event_y: + * @buttev: a #ClutterButtonEvent + * + * Retrieve the y coordinate of the event. + * + * Return value: the y coordinate + */ gint clutter_button_event_y (ClutterButtonEvent *buttev) { diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h index df6b5fb87..b4e55f9f1 100644 --- a/clutter/clutter-event.h +++ b/clutter/clutter-event.h @@ -113,26 +113,21 @@ union _ClutterEvent GType clutter_event_get_type (void) G_GNUC_CONST; -ClutterEvent *clutter_event_new (ClutterEventType type); -ClutterEvent *clutter_event_copy (ClutterEvent *event); -void clutter_event_free (ClutterEvent *event); - -ClutterEventType clutter_key_event_type (ClutterKeyEvent *keyev); - -guint32 clutter_key_event_time (ClutterKeyEvent *keyev); - -guint clutter_key_event_state (ClutterKeyEvent *keyev); - -gint clutter_button_event_x (ClutterButtonEvent *buttev); - -gint clutter_button_event_y (ClutterButtonEvent *buttev); - -guint clutter_key_event_symbol (ClutterKeyEvent *keyev); - -guint16 clutter_key_event_code (ClutterKeyEvent *keyev); +ClutterEvent *clutter_event_new (ClutterEventType type); +ClutterEvent *clutter_event_copy (ClutterEvent *event); +void clutter_event_free (ClutterEvent *event); +ClutterEventType clutter_event_type (ClutterEvent *keyev); +guint32 clutter_key_event_time (ClutterKeyEvent *keyev); +guint clutter_key_event_state (ClutterKeyEvent *keyev); +guint clutter_key_event_symbol (ClutterKeyEvent *keyev); +guint16 clutter_key_event_code (ClutterKeyEvent *keyev); guint32 clutter_key_event_unicode (ClutterKeyEvent *keyev); +guint32 clutter_button_event_time (ClutterButtonEvent *buttev); +gint clutter_button_event_x (ClutterButtonEvent *buttev); +gint clutter_button_event_y (ClutterButtonEvent *buttev); + guint32 clutter_keysym_to_unicode (guint keyval); G_END_DECLS diff --git a/clutter/clutter-feature.h b/clutter/clutter-feature.h index 35ac0a5cb..2ef4d3720 100644 --- a/clutter/clutter-feature.h +++ b/clutter/clutter-feature.h @@ -37,7 +37,7 @@ #include #include -G_END_DECLS +G_BEGIN_DECLS typedef enum { @@ -45,7 +45,7 @@ typedef enum CLUTTER_FEATURE_SYNC_TO_VBLANK = (1 << 2) } ClutterFeatureFlags; -gboolean clutter_feature_available (ClutterFeatureFlags flags); +gboolean clutter_feature_available (ClutterFeatureFlags feature); ClutterFeatureFlags clutter_feature_get_all (void); void clutter_feature_wait_for_vblank (void); diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c index 2600d6f94..36120280e 100644 --- a/clutter/clutter-group.c +++ b/clutter/clutter-group.c @@ -158,23 +158,39 @@ clutter_group_finalize (GObject *object) G_OBJECT_CLASS (clutter_group_parent_class)->finalize (object); } +static void +clutter_group_real_show_all (ClutterActor *actor) +{ + clutter_group_foreach (CLUTTER_GROUP (actor), + CLUTTER_CALLBACK (clutter_actor_show_all), + NULL); + clutter_actor_show (actor); +} + +static void +clutter_group_real_hide_all (ClutterActor *actor) +{ + clutter_actor_hide (actor); + clutter_group_foreach (CLUTTER_GROUP (actor), + CLUTTER_CALLBACK (clutter_actor_hide_all), + NULL); +} + static void clutter_group_class_init (ClutterGroupClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - actor_class->paint = clutter_group_paint; - /* - actor_class->show = clutter_group_show_all; - actor_class->hide = clutter_group_hide_all; - */ + actor_class->paint = clutter_group_paint; + actor_class->show_all = clutter_group_real_show_all; + actor_class->hide_all = clutter_group_real_hide_all; actor_class->request_coords = clutter_group_request_coords; actor_class->allocate_coords = clutter_group_allocate_coords; /* GObject */ - object_class->finalize = clutter_group_finalize; - object_class->dispose = clutter_group_dispose; + object_class->finalize = clutter_group_finalize; + object_class->dispose = clutter_group_dispose; group_signals[ADD] = g_signal_new ("add", @@ -272,17 +288,19 @@ clutter_group_foreach (ClutterGroup *self, * clutter_group_show_all: * @self: A #ClutterGroup * - * Show all child actors of the group. Note, does not recurse. - **/ + * Show all child actors of the group. + * Note, does not recurse: use clutter_actor_show_all() for + * a recursive show. + */ void clutter_group_show_all (ClutterGroup *self) { g_return_if_fail (CLUTTER_IS_GROUP (self)); - clutter_actor_show(CLUTTER_ACTOR(self)); + clutter_actor_show (CLUTTER_ACTOR (self)); g_list_foreach (self->priv->children, - (GFunc)clutter_actor_show, + (GFunc) clutter_actor_show, NULL); } @@ -290,8 +308,10 @@ clutter_group_show_all (ClutterGroup *self) * clutter_group_hide_all: * @self: A #ClutterGroup * - * Hide all child actors of the group. Note, does not recurse. - **/ + * Hide all child actors of the group. + * Note, does not recurse: use clutter_actor_hide_all() for + * a recursive hide. + */ void clutter_group_hide_all (ClutterGroup *self) { @@ -300,7 +320,7 @@ clutter_group_hide_all (ClutterGroup *self) clutter_actor_hide(CLUTTER_ACTOR(self)); g_list_foreach (self->priv->children, - (GFunc)clutter_actor_hide, + (GFunc) clutter_actor_hide, NULL); } diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 01733f209..77753b6ec 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -238,17 +238,29 @@ sync_gl_viewport (ClutterStage *stage) static void clutter_stage_show (ClutterActor *self) { - if (clutter_stage_get_xwindow (CLUTTER_STAGE(self))) - XMapWindow (clutter_xdisplay(), - clutter_stage_get_xwindow (CLUTTER_STAGE(self))); + ClutterActorClass *parent_class; + + parent_class = CLUTTER_ACTOR_CLASS (clutter_stage_parent_class); + if (parent_class->show) + parent_class->show (self); + + if (clutter_stage_get_xwindow (CLUTTER_STAGE (self))) + XMapWindow (clutter_xdisplay (), + clutter_stage_get_xwindow (CLUTTER_STAGE (self))); } static void clutter_stage_hide (ClutterActor *self) { - if (clutter_stage_get_xwindow (CLUTTER_STAGE(self))) - XUnmapWindow (clutter_xdisplay(), - clutter_stage_get_xwindow (CLUTTER_STAGE(self))); + ClutterActorClass *parent_class; + + parent_class = CLUTTER_ACTOR_CLASS (clutter_stage_parent_class); + if (parent_class->hide) + parent_class->hide (self); + + if (clutter_stage_get_xwindow (CLUTTER_STAGE (self))) + XUnmapWindow (clutter_xdisplay (), + clutter_stage_get_xwindow (CLUTTER_STAGE (self))); } static void diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 794879a71..f65ee586e 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -639,12 +639,26 @@ clutter_texture_realize (ClutterActor *actor) static void clutter_texture_show (ClutterActor *self) { + ClutterActorClass *parent_class; + + /* chain up parent show */ + parent_class = CLUTTER_ACTOR_CLASS (clutter_texture_parent_class); + if (parent_class->show) + parent_class->show (self); + clutter_actor_realize (self); } static void clutter_texture_hide (ClutterActor *self) { + ClutterActorClass *parent_class; + + /* chain up parent hide */ + parent_class = CLUTTER_ACTOR_CLASS (clutter_texture_parent_class); + if (parent_class->hide) + parent_class->hide (self); + clutter_actor_unrealize (self); } diff --git a/clutter/clutter-texture.h b/clutter/clutter-texture.h index 582810c28..60faa8ae6 100644 --- a/clutter/clutter-texture.h +++ b/clutter/clutter-texture.h @@ -26,9 +26,8 @@ #ifndef _HAVE_CLUTTER_TEXTURE_H #define _HAVE_CLUTTER_TEXTURE_H -#include -#include #include +#include G_BEGIN_DECLS @@ -54,10 +53,18 @@ struct _ClutterTextureClass { ClutterActorClass parent_class; - void (*size_change) (ClutterTexture *texture, - gint width, - gint height); + void (*size_change) (ClutterTexture *texture, + gint width, + gint height); void (*pixbuf_change) (ClutterTexture *texture); + + /* padding, for future expansion */ + void (*_clutter_texture1) (void); + void (*_clutter_texture2) (void); + void (*_clutter_texture3) (void); + void (*_clutter_texture4) (void); + void (*_clutter_texture5) (void); + void (*_clutter_texture6) (void); }; GType clutter_texture_get_type (void) G_GNUC_CONST; diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt index ece6a9168..28aafa2c7 100644 --- a/doc/reference/clutter-sections.txt +++ b/doc/reference/clutter-sections.txt @@ -463,7 +463,6 @@ CLUTTER_FIXED_DIV clutter-color CLUTTER_TYPE_COLOR ClutterColor -clutter_color_get_type clutter_color_parse clutter_color_add clutter_color_subtract @@ -474,6 +473,8 @@ clutter_color_to_hls clutter_color_from_hls clutter_color_to_pixel clutter_color_from_pixel + +clutter_color_get_type
@@ -486,7 +487,6 @@ ClutterButtonEvent ClutterMotionEvent ClutterInputDevice ClutterEvent -clutter_event_get_type clutter_event_new clutter_event_copy clutter_event_free @@ -499,6 +499,8 @@ clutter_key_event_symbol clutter_key_event_code clutter_key_event_unicode clutter_keysym_to_unicode + +clutter_event_get_type
diff --git a/doc/reference/tmpl/clutter-actor.sgml b/doc/reference/tmpl/clutter-actor.sgml index cbc7909a5..d7000dde5 100644 --- a/doc/reference/tmpl/clutter-actor.sgml +++ b/doc/reference/tmpl/clutter-actor.sgml @@ -207,7 +207,9 @@ ClutterActor @parent_class: @show: +@show_all: @hide: +@hide_all: @realize: @unrealize: @paint: @@ -217,8 +219,6 @@ ClutterActor @get_depth: @parent_set: @destroy: -@show_all: -@hide_all: @queue_redraw: @_clutter_actor_1: @_clutter_actor_2: diff --git a/doc/reference/tmpl/clutter-color.sgml b/doc/reference/tmpl/clutter-color.sgml index 9a01df9c9..312ddc39f 100644 --- a/doc/reference/tmpl/clutter-color.sgml +++ b/doc/reference/tmpl/clutter-color.sgml @@ -34,14 +34,6 @@ clutter-color @blue: @alpha: - - - - - -@Returns: - - diff --git a/doc/reference/tmpl/clutter-event.sgml b/doc/reference/tmpl/clutter-event.sgml index de79e61df..66fc377c8 100644 --- a/doc/reference/tmpl/clutter-event.sgml +++ b/doc/reference/tmpl/clutter-event.sgml @@ -94,14 +94,6 @@ Windowing events handled by Clutter. - - - - - -@Returns: - - @@ -128,15 +120,6 @@ Windowing events handled by Clutter. @event: - - - - - -@keyev: -@Returns: - - diff --git a/doc/reference/tmpl/clutter-feature.sgml b/doc/reference/tmpl/clutter-feature.sgml index fe4af08df..0d0dad5a6 100644 --- a/doc/reference/tmpl/clutter-feature.sgml +++ b/doc/reference/tmpl/clutter-feature.sgml @@ -30,7 +30,7 @@ clutter-feature -@flags: +@feature: @Returns: diff --git a/doc/reference/tmpl/clutter-texture.sgml b/doc/reference/tmpl/clutter-texture.sgml index dab45286a..c7423bf68 100644 --- a/doc/reference/tmpl/clutter-texture.sgml +++ b/doc/reference/tmpl/clutter-texture.sgml @@ -92,6 +92,12 @@ ClutterTexture @parent_class: @size_change: @pixbuf_change: +@_clutter_texture1: +@_clutter_texture2: +@_clutter_texture3: +@_clutter_texture4: +@_clutter_texture5: +@_clutter_texture6: diff --git a/examples/behave.c b/examples/behave.c index f6297d0af..bcc6485ad 100644 --- a/examples/behave.c +++ b/examples/behave.c @@ -48,13 +48,13 @@ main (int argc, char *argv[]) clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (rect), &rect_border_color); clutter_actor_show (rect); - + hand = clutter_texture_new_from_pixbuf (pixbuf); clutter_actor_set_position (hand, 0, 0); clutter_actor_show (hand); clutter_group_add_many (CLUTTER_GROUP (group), rect, hand, NULL); - + /* Make a timeline */ timeline = clutter_timeline_new (100, 26); /* num frames, fps */ g_object_set (timeline, "loop", TRUE, 0); @@ -77,7 +77,7 @@ main (int argc, char *argv[]) /* start the timeline and thus the animations */ clutter_timeline_start (timeline); - clutter_group_show_all (CLUTTER_GROUP (stage)); + clutter_actor_show_all (stage); clutter_main(); diff --git a/examples/super-oh.c b/examples/super-oh.c index 6d17036ca..e9af9732c 100644 --- a/examples/super-oh.c +++ b/examples/super-oh.c @@ -242,8 +242,7 @@ main (int argc, char *argv[]) clutter_group_add (CLUTTER_GROUP (stage), CLUTTER_ACTOR(oh->group)); /* Show everying ( and map window ) */ - clutter_group_show_all (CLUTTER_GROUP (oh->group)); - clutter_group_show_all (CLUTTER_GROUP (stage)); + clutter_actor_show_all (stage); g_signal_connect (stage, "button-press-event", G_CALLBACK (input_cb), diff --git a/examples/test.c b/examples/test.c index 4c44705eb..9c83e0c7d 100644 --- a/examples/test.c +++ b/examples/test.c @@ -108,7 +108,7 @@ main (int argc, char *argv[]) clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600); - clutter_group_show_all (CLUTTER_GROUP (stage)); + clutter_actor_show_all (CLUTTER_ACTOR (stage)); timeline = clutter_timeline_new (360, 200); g_object_set (timeline, "loop", TRUE, 0);