[clutter] tests/interactive: Add a simple test for Actor
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] tests/interactive: Add a simple test for Actor
- Date: Mon, 16 Jan 2012 23:57:15 +0000 (UTC)
commit b42f17b2dcab6d750124afb90b01612311b672ad
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Tue Dec 20 14:47:35 2011 +0000
tests/interactive: Add a simple test for Actor
It's meant to be xincluded in the API reference.
tests/interactive/Makefile.am | 3 +-
tests/interactive/test-actor.c | 62 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletions(-)
---
diff --git a/tests/interactive/Makefile.am b/tests/interactive/Makefile.am
index 357b6bd..aa8628e 100644
--- a/tests/interactive/Makefile.am
+++ b/tests/interactive/Makefile.am
@@ -58,7 +58,8 @@ UNIT_TESTS = \
test-snap-constraint.c \
test-state-script.c \
test-drop.c \
- test-devices.c
+ test-devices.c \
+ test-actor.c
if X11_TESTS
UNIT_TESTS += test-pixmap.c
diff --git a/tests/interactive/test-actor.c b/tests/interactive/test-actor.c
new file mode 100644
index 0000000..35a18f8
--- /dev/null
+++ b/tests/interactive/test-actor.c
@@ -0,0 +1,62 @@
+#include <stdlib.h>
+#include <gmodule.h>
+#include <clutter/clutter.h>
+
+#define SIZE 128
+
+G_MODULE_EXPORT int
+test_actor_main (int argc, char *argv[])
+{
+ ClutterActor *stage, *vase;
+ ClutterActor *flowers[3];
+
+ if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
+ return EXIT_FAILURE;
+
+ stage = clutter_stage_new ();
+ g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
+ clutter_stage_set_title (CLUTTER_STAGE (stage), "Three Flowers in a Vase");
+ clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
+
+ /* there are three flowers in a vase */
+ vase = clutter_actor_new ();
+ clutter_actor_set_name (vase, "vase");
+ clutter_actor_set_layout_manager (vase, clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
+ clutter_actor_set_margin_top (vase, 18);
+ clutter_actor_set_margin_bottom (vase, 18);
+ clutter_actor_set_margin_left (vase, 6);
+ clutter_actor_set_margin_right (vase, 6);
+ clutter_actor_add_constraint (vase, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5));
+ clutter_actor_add_child (stage, vase);
+
+ flowers[0] = clutter_actor_new ();
+ clutter_actor_set_name (flowers[0], "flower.1");
+ clutter_actor_set_size (flowers[0], SIZE, SIZE);
+ clutter_actor_set_background_color (flowers[0], CLUTTER_COLOR_Red);
+ clutter_actor_add_child (vase, flowers[0]);
+
+ flowers[1] = clutter_actor_new ();
+ clutter_actor_set_name (flowers[1], "flower.2");
+ clutter_actor_set_size (flowers[1], SIZE, SIZE);
+ clutter_actor_set_background_color (flowers[1], CLUTTER_COLOR_Yellow);
+ clutter_actor_add_child (vase, flowers[1]);
+
+ /* the third one is green */
+ flowers[2] = clutter_actor_new ();
+ clutter_actor_set_name (flowers[2], "flower.3");
+ clutter_actor_set_size (flowers[2], SIZE, SIZE);
+ clutter_actor_set_background_color (flowers[2], CLUTTER_COLOR_Green);
+ clutter_actor_add_child (vase, flowers[2]);
+
+ clutter_actor_show (stage);
+
+ clutter_main ();
+
+ return EXIT_SUCCESS;
+}
+
+G_MODULE_EXPORT const char *
+test_actor_describe (void)
+{
+ return "Basic example of actor usage.";
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]