[clutter/wip/apocalypses/apocalypse-1: 37/44] actor: Make Actor instantiatable



commit 0d6b8a927cdebb0c025f8fe7b2b8fc0aa438cc07
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Dec 6 16:09:53 2011 +0000

    actor: Make Actor instantiatable
    
    ClutterActor now has all the API and capabilities for being a concrete
    class:
    
      - layout management, through delegation
      - container implementation and API
      - background color
    
    This means that a simple scene can be built straight out of actors
    without using subclasses except for the Stage.
    
    This is the first step towards the deprecation of most of the Actor
    subclasses provided by Clutter.

 clutter/clutter-actor.c           |   40 ++++++++++++++++++++++++++----------
 clutter/clutter-actor.h           |    4 ++-
 tests/conform/test-actor-layout.c |   24 ++++++++++++++-------
 3 files changed, 48 insertions(+), 20 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 13407ca..9c1e0f1 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -731,17 +731,17 @@ static ClutterPaintVolume *_clutter_actor_get_paint_volume_mutable (ClutterActor
 static GQuark quark_shader_data = 0;
 static GQuark quark_actor_layout_info = 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,
-                                                         clutter_animatable_iface_init)
-                                  G_IMPLEMENT_INTERFACE (ATK_TYPE_IMPLEMENTOR,
-                                                         atk_implementor_iface_init));
+G_DEFINE_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,
+                                                clutter_animatable_iface_init)
+                         G_IMPLEMENT_INTERFACE (ATK_TYPE_IMPLEMENTOR,
+                                                atk_implementor_iface_init));
 
 /*< private >
  * clutter_actor_get_debug_name:
@@ -5814,6 +5814,24 @@ clutter_actor_init (ClutterActor *self)
 }
 
 /**
+ * clutter_actor_new:
+ *
+ * Creates a new #ClutterActor.
+ *
+ * A newly created actor has a floating reference, which will be sunk
+ * when it is added to another actor.
+ *
+ * Return value: (transfer full): the newly created #ClutterActor
+ *
+ * Since: 1.10
+ */
+ClutterActor *
+clutter_actor_new (void)
+{
+  return g_object_new (CLUTTER_TYPE_ACTOR, NULL);
+}
+
+/**
  * clutter_actor_destroy:
  * @self: a #ClutterActor
  *
diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h
index 6c29b68..59ade1c 100644
--- a/clutter/clutter-actor.h
+++ b/clutter/clutter-actor.h
@@ -261,7 +261,9 @@ struct _ClutterActorClass
   gpointer _padding_dummy[28];
 };
 
-GType                 clutter_actor_get_type                  (void) G_GNUC_CONST;
+GType clutter_actor_get_type (void) G_GNUC_CONST;
+
+ClutterActor *        clutter_actor_new                       (void);
 
 void                  clutter_actor_set_flags                 (ClutterActor          *self,
                                                                ClutterActorFlags      flags);
diff --git a/tests/conform/test-actor-layout.c b/tests/conform/test-actor-layout.c
index 74b83e3..62cab0e 100644
--- a/tests/conform/test-actor-layout.c
+++ b/tests/conform/test-actor-layout.c
@@ -212,20 +212,24 @@ basic_layout (TestConformSimpleFixture *fixture,
   ClutterActor *flower[3];
   TestState *state;
 
-  vase = clutter_box_new (clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
+  vase = clutter_actor_new ();
+  clutter_actor_set_layout_manager (vase, clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
   clutter_actor_add_child (stage, vase);
 
-  flower[0] = clutter_rectangle_new_with_color (CLUTTER_COLOR_Red);
+  flower[0] = clutter_actor_new ();
+  clutter_actor_set_background_color (flower[0], CLUTTER_COLOR_Red);
   clutter_actor_set_size (flower[0], 100, 100);
   clutter_actor_set_name (flower[0], "Red Flower");
   clutter_actor_add_child (vase, flower[0]);
 
-  flower[1] = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow);
+  flower[1] = clutter_actor_new ();
+  clutter_actor_set_background_color (flower[1], CLUTTER_COLOR_Yellow);
   clutter_actor_set_size (flower[1], 100, 100);
   clutter_actor_set_name (flower[1], "Yellow Flower");
   clutter_actor_add_child (vase, flower[1]);
 
-  flower[2] = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green);
+  flower[2] = clutter_actor_new ();
+  clutter_actor_set_background_color (flower[2], CLUTTER_COLOR_Green);
   clutter_actor_set_size (flower[2], 100, 100);
   clutter_actor_set_name (flower[2], "Green Flower");
   clutter_actor_add_child (vase, flower[2]);
@@ -252,22 +256,26 @@ margin_layout (TestConformSimpleFixture *fixture,
   ClutterActor *flower[3];
   TestState *state;
 
-  vase = clutter_box_new (clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
+  vase = clutter_actor_new ();
+  clutter_actor_set_layout_manager (vase, clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
   clutter_actor_add_child (stage, vase);
 
-  flower[0] = clutter_rectangle_new_with_color (CLUTTER_COLOR_Red);
+  flower[0] = clutter_actor_new ();
+  clutter_actor_set_background_color (flower[0], CLUTTER_COLOR_Red);
   clutter_actor_set_size (flower[0], 100, 100);
   clutter_actor_set_name (flower[0], "Red Flower");
   clutter_actor_add_child (vase, flower[0]);
 
-  flower[1] = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow);
+  flower[1] = clutter_actor_new ();
+  clutter_actor_set_background_color (flower[1], CLUTTER_COLOR_Yellow);
   clutter_actor_set_size (flower[1], 100, 100);
   clutter_actor_set_name (flower[1], "Yellow Flower");
   clutter_actor_set_margin_right (flower[1], 6);
   clutter_actor_set_margin_left (flower[1], 6);
   clutter_actor_add_child (vase, flower[1]);
 
-  flower[2] = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green);
+  flower[2] = clutter_actor_new ();
+  clutter_actor_set_background_color (flower[2], CLUTTER_COLOR_Green);
   clutter_actor_set_size (flower[2], 100, 100);
   clutter_actor_set_name (flower[2], "Green Flower");
   clutter_actor_set_margin_top (flower[2], 6);



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