[clutter/wip/apocalypses/apocalypse-1: 3/43] actor: Provide a default Container implementation
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/apocalypses/apocalypse-1: 3/43] actor: Provide a default Container implementation
- Date: Wed, 7 Dec 2011 18:13:37 +0000 (UTC)
commit ba4ebacd497165b2ebf7d56554f96f45ec72a336
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Thu Nov 17 16:32:05 2011 +0000
actor: Provide a default Container implementation
We can provide most of the ClutterContainer implementation directly
within ClutterActor â basically removing the need of having the
Container interface in the first place. For backward compatibility
reasons we can keep the interface, but let Actor implement it directly.
clutter/clutter-actor.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 7361934..d493fc1 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -644,6 +644,7 @@ enum
static guint actor_signals[LAST_SIGNAL] = { 0, };
+static void clutter_container_iface_init (ClutterContainerIface *iface);
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
static void clutter_animatable_iface_init (ClutterAnimatableIface *iface);
static void atk_implementor_iface_init (AtkImplementorIface *iface);
@@ -715,6 +716,8 @@ static GQuark quark_shader_data = 0;
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ClutterActor,
clutter_actor,
G_TYPE_INITIALLY_UNOWNED,
+ G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
+ clutter_container_iface_init)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
clutter_scriptable_iface_init)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_ANIMATABLE,
@@ -2797,6 +2800,21 @@ add_or_remove_flatten_effect (ClutterActor *self)
}
}
+static gboolean
+foreach_child_paint (ClutterActor *child,
+ gpointer dummy G_GNUC_UNUSED)
+{
+ clutter_actor_paint (child);
+
+ return TRUE;
+}
+
+static void
+clutter_actor_real_paint (ClutterActor *actor)
+{
+ _clutter_actor_foreach_child (actor, foreach_child_paint, NULL);
+}
+
/**
* clutter_actor_paint:
* @self: A #ClutterActor
@@ -5310,6 +5328,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
klass->get_accessible = clutter_actor_real_get_accessible;
klass->get_paint_volume = clutter_actor_real_get_paint_volume;
klass->has_overlaps = clutter_actor_real_has_overlaps;
+ klass->paint = clutter_actor_real_paint;
}
static void
@@ -9049,6 +9068,69 @@ clutter_actor_set_anchor_point_from_gravity (ClutterActor *self,
}
}
+static void
+actor_add_actor (ClutterContainer *container,
+ ClutterActor *actor)
+{
+ clutter_actor_add_child (CLUTTER_ACTOR (container), actor);
+ clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
+
+ g_signal_emit_by_name (container, "actor-added", actor);
+}
+
+static void
+actor_remove_actor (ClutterContainer *container,
+ ClutterActor *actor)
+{
+ g_object_ref (actor);
+
+ clutter_actor_remove_child (CLUTTER_ACTOR (container), actor);
+ clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
+
+ g_signal_emit_by_name (container, "actor-removed", actor);
+
+ g_object_unref (actor);
+}
+
+typedef struct {
+ ClutterCallback callback;
+ gpointer data;
+} ForeachClosure;
+
+static gboolean
+foreach_cb (ClutterActor *actor,
+ gpointer data)
+{
+ ForeachClosure *clos = data;
+
+ clos->callback (actor, clos->data);
+
+ return TRUE;
+}
+
+static void
+actor_foreach (ClutterContainer *container,
+ ClutterCallback callback,
+ gpointer user_data)
+{
+ ForeachClosure clos;
+
+ clos.callback = callback;
+ clos.data = user_data;
+
+ _clutter_actor_foreach_child (CLUTTER_ACTOR (container),
+ foreach_cb,
+ &clos);
+}
+
+static void
+clutter_container_iface_init (ClutterContainerIface *iface)
+{
+ iface->add = actor_add_actor;
+ iface->remove = actor_remove_actor;
+ iface->foreach = actor_foreach;
+}
+
typedef enum
{
PARSE_X,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]