clutter: Remove deprecated 'ClutterState'
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
18e7b814f2
commit
a55a286b15
@ -1,33 +0,0 @@
|
||||
[
|
||||
{
|
||||
"type" : "ClutterRectangle",
|
||||
"id" : "rect",
|
||||
"width" : 100,
|
||||
"height" : 100
|
||||
},
|
||||
{
|
||||
"type" : "ClutterState",
|
||||
"id" : "state",
|
||||
|
||||
"transitions" : [
|
||||
{
|
||||
"source" : "base",
|
||||
"target" : "clicked",
|
||||
"duration" : 250,
|
||||
|
||||
"keys" : [
|
||||
[ "rect", "opacity", "linear", 128 ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"source" : "clicked",
|
||||
"target" : "base",
|
||||
"duration" : 150,
|
||||
|
||||
"keys" : [
|
||||
[ "rect", "opacity", "linear", 255 ]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,87 +0,0 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "test-conform-common.h"
|
||||
|
||||
void
|
||||
state_base (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
|
||||
gconstpointer dummy G_GNUC_UNUSED)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
GObject *state = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *test_file;
|
||||
GList *states, *keys;
|
||||
ClutterStateKey *state_key;
|
||||
guint duration;
|
||||
|
||||
test_file = clutter_test_get_data_file ("test-state-1.json");
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (g_test_verbose () && error)
|
||||
g_print ("Error: %s\n", error->message);
|
||||
|
||||
g_free (test_file);
|
||||
|
||||
#if GLIB_CHECK_VERSION (2, 20, 0)
|
||||
g_assert_no_error (error);
|
||||
#else
|
||||
g_assert (error == NULL);
|
||||
#endif
|
||||
|
||||
state = clutter_script_get_object (script, "state");
|
||||
g_assert (CLUTTER_IS_STATE (state));
|
||||
|
||||
states = clutter_state_get_states (CLUTTER_STATE (state));
|
||||
g_assert (states != NULL);
|
||||
|
||||
g_assert (g_list_find (states, g_intern_static_string ("clicked")));
|
||||
g_list_free (states);
|
||||
|
||||
duration = clutter_state_get_duration (CLUTTER_STATE (state), "base", "clicked");
|
||||
g_assert_cmpint (duration, ==, 250);
|
||||
|
||||
duration = clutter_state_get_duration (CLUTTER_STATE (state), "clicked", "base");
|
||||
g_assert_cmpint (duration, ==, 150);
|
||||
|
||||
keys = clutter_state_get_keys (CLUTTER_STATE (state), "base", "clicked",
|
||||
clutter_script_get_object (script, "rect"),
|
||||
"opacity");
|
||||
|
||||
g_assert (keys != NULL);
|
||||
g_assert_cmpint (g_list_length (keys), ==, 1);
|
||||
|
||||
state_key = keys->data;
|
||||
g_assert (clutter_state_key_get_object (state_key) == clutter_script_get_object (script, "rect"));
|
||||
g_assert (clutter_state_key_get_mode (state_key) == CLUTTER_LINEAR);
|
||||
g_assert_cmpstr (clutter_state_key_get_property_name (state_key), ==, "opacity");
|
||||
|
||||
g_list_free (keys);
|
||||
keys = clutter_state_get_keys (CLUTTER_STATE (state), NULL, NULL, NULL, NULL);
|
||||
g_assert_cmpint (g_list_length (keys), ==, 2);
|
||||
g_list_free (keys);
|
||||
|
||||
|
||||
|
||||
clutter_state_set (CLUTTER_STATE (state), "base", "clicked", state, "state", CLUTTER_LINEAR, "foo", NULL);
|
||||
|
||||
keys = clutter_state_get_keys (CLUTTER_STATE (state), "base", "clicked",
|
||||
NULL, NULL);
|
||||
|
||||
g_assert (keys != NULL);
|
||||
g_assert_cmpint (g_list_length (keys), ==, 2);
|
||||
g_list_free (keys);
|
||||
|
||||
states = clutter_state_get_states (CLUTTER_STATE (state));
|
||||
g_assert_cmpint (g_list_length (states), ==, 2);
|
||||
g_list_free (states);
|
||||
|
||||
clutter_state_remove_key (CLUTTER_STATE (state), NULL, "clicked", NULL, NULL);
|
||||
states = clutter_state_get_states (CLUTTER_STATE (state));
|
||||
|
||||
/* removing the "clicked" state, will also cause the "base" state to be removed
|
||||
* since in the .json there is no default source state
|
||||
*/
|
||||
g_assert_cmpint (g_list_length (states), ==, 0);
|
||||
g_list_free (states);
|
||||
|
||||
g_object_unref (script);
|
||||
}
|
@ -21,7 +21,6 @@ clutter_tests_interactive_test_sources = [
|
||||
'test-script.c',
|
||||
'test-grab.c',
|
||||
'test-cogl-shader-glsl.c',
|
||||
'test-state.c',
|
||||
'test-cogl-tex-tile.c',
|
||||
'test-cogl-tex-convert.c',
|
||||
'test-cogl-offscreen.c',
|
||||
@ -40,7 +39,6 @@ clutter_tests_interactive_test_sources = [
|
||||
'test-swipe-action.c',
|
||||
'test-cogl-point-sprites.c',
|
||||
'test-path-constraint.c',
|
||||
'test-state-script.c',
|
||||
'test-devices.c',
|
||||
'test-content.c',
|
||||
'test-keyframe-transition.c',
|
||||
|
@ -1,68 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id" : "button",
|
||||
"type" : "ClutterRectangle",
|
||||
|
||||
"width" : "16 em",
|
||||
"height" : "6 em",
|
||||
|
||||
"color" : "rgb(255, 0, 0)",
|
||||
"opacity" : 128,
|
||||
|
||||
"scale-gravity" : "center",
|
||||
|
||||
"reactive" : true,
|
||||
|
||||
"signals" : [
|
||||
{
|
||||
"name" : "button-press-event",
|
||||
"handler" : "on_button_press"
|
||||
},
|
||||
{ "name" : "enter-event", "states" : "button-states", "target-state" : "hover" },
|
||||
{ "name" : "leave-event", "states" : "button-states", "target-state" : "base" },
|
||||
{ "name" : "button-press-event", "states" : "button-states", "target-state" : "active" },
|
||||
{ "name" : "button-release-event", "states" : "button-states", "target-state" : "hover" }
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"id" : "button-states",
|
||||
"type" : "ClutterState",
|
||||
|
||||
"duration" : 250,
|
||||
|
||||
"transitions" : [
|
||||
{
|
||||
"source" : null,
|
||||
"target" : "base",
|
||||
|
||||
"keys" : [
|
||||
[ "button", "opacity", "linear", 128 ],
|
||||
[ "button", "scale-x", "ease-in-cubic", 1.0 ],
|
||||
[ "button", "scale-y", "ease-in-cubic", 1.0 ],
|
||||
[ "button", "color", "linear", "rgb(255, 0, 0)" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"source" : null,
|
||||
"target" : "hover",
|
||||
|
||||
"keys" : [
|
||||
[ "button", "opacity", "linear", 255 ],
|
||||
[ "button", "scale-x", "ease-out-bounce", 1.4 ],
|
||||
[ "button", "scale-y", "ease-out-bounce", 1.4 ],
|
||||
[ "button", "color", "linear", "rgb(0, 255, 0)" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"source" : null,
|
||||
"target" : "active",
|
||||
|
||||
"keys" : [
|
||||
[ "button", "opacity", "linear", 255 ],
|
||||
[ "button", "color", "linear", "rgb(0, 0, 255)" ]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -1,213 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-utils.h"
|
||||
|
||||
#define STAGE_WIDTH 1024
|
||||
#define STAGE_HEIGHT 768
|
||||
|
||||
#define ACTOR_WIDTH 128
|
||||
#define ACTOR_HEIGHT 128
|
||||
|
||||
#define COLS (STAGE_WIDTH/ACTOR_WIDTH)
|
||||
#define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT)
|
||||
#define TOTAL (ROWS*COLS)
|
||||
|
||||
gint
|
||||
test_state_main (gint argc,
|
||||
gchar **argv);
|
||||
|
||||
const char *
|
||||
test_state_describe (void);
|
||||
|
||||
static gboolean press_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "right");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean release_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "active");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean enter_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "hover");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean leave_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "normal");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void completed (ClutterState *state,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("Completed transitioning to state: %s\n",
|
||||
clutter_state_get_state (state));
|
||||
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
}
|
||||
|
||||
static ClutterActor *new_rect (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint a)
|
||||
{
|
||||
GError *error = NULL;
|
||||
ClutterColor *color = clutter_color_new (r, g, b, a);
|
||||
ClutterActor *group = clutter_actor_new ();
|
||||
ClutterActor *rectangle = clutter_actor_new ();
|
||||
ClutterActor *hand = NULL;
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
|
||||
clutter_actor_set_background_color (rectangle, color);
|
||||
clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
clutter_color_free (color);
|
||||
|
||||
clutter_actor_add_child (group, rectangle);
|
||||
clutter_actor_add_child (group, hand);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT gint
|
||||
test_state_main (gint argc,
|
||||
gchar **argv)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ClutterState *layout_state;
|
||||
gint i;
|
||||
|
||||
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
||||
return 1;
|
||||
|
||||
layout_state = clutter_state_new ();
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black);
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Machine");
|
||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||
g_signal_connect (stage, "button-press-event",
|
||||
G_CALLBACK (press_event), layout_state);
|
||||
g_signal_connect (stage, "button-release-event",
|
||||
G_CALLBACK (release_event), layout_state);
|
||||
|
||||
for (i = 0; i < TOTAL; i++)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
ClutterState *a_state;
|
||||
|
||||
int row = i/COLS;
|
||||
int col = i%COLS;
|
||||
|
||||
actor = new_rect (255 * (1.0 * col / COLS), 50,
|
||||
255 * (1.0 * row / ROWS), 255);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
||||
clutter_actor_set_position (actor, 320.0, 240.0);
|
||||
clutter_actor_set_reactive (actor, TRUE);
|
||||
clutter_actor_add_effect_with_name (actor, "fade",
|
||||
clutter_desaturate_effect_new (0.0));
|
||||
|
||||
|
||||
clutter_state_set (layout_state, NULL, "active",
|
||||
actor, "delayed::x", CLUTTER_LINEAR,
|
||||
ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
|
||||
((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR,
|
||||
ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
|
||||
((row*1.0/ROWS))/2, 0.0,
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "right",
|
||||
actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
(1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "left",
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
|
||||
actor, "x", CLUTTER_LINEAR, 0-64.0,
|
||||
actor, "y", CLUTTER_LINEAR, 0-64.0,
|
||||
NULL);
|
||||
|
||||
a_state = clutter_state_new ();
|
||||
g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
|
||||
a_state, g_object_unref);
|
||||
g_signal_connect (actor, "enter-event",
|
||||
G_CALLBACK (enter_event), a_state);
|
||||
g_signal_connect (actor, "leave-event",
|
||||
G_CALLBACK (leave_event), a_state);
|
||||
|
||||
clutter_state_set (a_state, NULL, "normal",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0x77,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
|
||||
actor, "@effects.fade.factor", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
clutter_state_set (a_state, NULL, "hover",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0xff,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
|
||||
actor, "@effects.fade.factor", CLUTTER_LINEAR, 1.0,
|
||||
NULL);
|
||||
clutter_actor_set_opacity (actor, 0x77);
|
||||
|
||||
clutter_state_set_duration (a_state, NULL, NULL, 500);
|
||||
}
|
||||
|
||||
clutter_state_set_duration (layout_state, NULL, NULL, 1000);
|
||||
clutter_state_set_duration (layout_state, "active", "left", 1400);
|
||||
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_main ();
|
||||
|
||||
g_object_unref (layout_state);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT const char *
|
||||
test_state_describe (void)
|
||||
{
|
||||
return "Animating using the State class.";
|
||||
}
|
@ -11,11 +11,6 @@ clutter_tests_performance_c_args += clutter_debug_c_args
|
||||
clutter_tests_performance_tests = [
|
||||
'test-picking',
|
||||
'test-text-perf',
|
||||
'test-state',
|
||||
'test-state-interactive',
|
||||
'test-state-hidden',
|
||||
'test-state-mini',
|
||||
'test-state-pick',
|
||||
]
|
||||
|
||||
foreach test : clutter_tests_performance_tests
|
||||
|
@ -1,150 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
|
||||
#define STAGE_WIDTH 160
|
||||
#define STAGE_HEIGHT 120
|
||||
|
||||
#define ACTOR_WIDTH 8
|
||||
#define ACTOR_HEIGHT 8
|
||||
|
||||
#define COLS (STAGE_WIDTH/ACTOR_WIDTH)
|
||||
#define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT)
|
||||
#define TOTAL (ROWS*COLS)
|
||||
|
||||
|
||||
static void completed (ClutterState *state,
|
||||
gpointer data)
|
||||
{
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
else if (g_str_equal (clutter_state_get_state (state), "active"))
|
||||
clutter_state_set_state (state, "right");
|
||||
else
|
||||
{
|
||||
clutter_state_set_state (state, "active");
|
||||
}
|
||||
}
|
||||
|
||||
static ClutterActor *new_rect (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint a)
|
||||
{
|
||||
ClutterColor *color = clutter_color_new (r, g, b, a);
|
||||
ClutterActor *group = clutter_group_new ();
|
||||
ClutterActor *rectangle = clutter_rectangle_new_with_color (color);
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
g_free (file);
|
||||
clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
clutter_color_free (color);
|
||||
clutter_container_add (CLUTTER_CONTAINER (group), rectangle, NULL);
|
||||
return group;
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar **argv)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ClutterActor *group;
|
||||
ClutterState *layout_state;
|
||||
gint i;
|
||||
|
||||
clutter_perf_fps_init ();
|
||||
if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv))
|
||||
g_error ("Failed to initialize Clutter");
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
group = clutter_group_new ();
|
||||
layout_state = clutter_state_new ();
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Performance [hidden]");
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
|
||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||
|
||||
for (i=0; i<TOTAL; i++)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
ClutterState *a_state;
|
||||
|
||||
int row = i/COLS;
|
||||
int col = i%COLS;
|
||||
|
||||
actor = new_rect (255 * ( 1.0*col/COLS), 50,
|
||||
255 * ( 1.0*row/ROWS), 255);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), actor);
|
||||
clutter_actor_set_position (actor, 320.0, 240.0);
|
||||
clutter_actor_set_reactive (actor, TRUE);
|
||||
|
||||
|
||||
clutter_state_set (layout_state, NULL, "active",
|
||||
actor, "delayed::x", CLUTTER_LINEAR,
|
||||
ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
|
||||
((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR,
|
||||
ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
|
||||
((row*1.0/ROWS))/2, 0.0,
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "right",
|
||||
actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
(1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "left",
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
|
||||
actor, "x", CLUTTER_LINEAR, 0-64.0,
|
||||
actor, "y", CLUTTER_LINEAR, 0-64.0,
|
||||
NULL);
|
||||
|
||||
a_state = clutter_state_new ();
|
||||
g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
|
||||
a_state, g_object_unref);
|
||||
|
||||
clutter_state_set (a_state, NULL, "normal",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0x77,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
clutter_state_set (a_state, NULL, "hover",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0xff,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
|
||||
NULL);
|
||||
clutter_actor_set_opacity (actor, 0x77);
|
||||
|
||||
clutter_state_set_duration (a_state, NULL, NULL, 500);
|
||||
}
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
|
||||
clutter_actor_set_opacity (group, 0);
|
||||
|
||||
clutter_state_set_duration (layout_state, NULL, NULL, 1000);
|
||||
clutter_state_set_duration (layout_state, "active", "left", 1400);
|
||||
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_perf_fps_start (CLUTTER_STAGE (stage));
|
||||
clutter_main ();
|
||||
clutter_perf_fps_report ("test-state-hidden");
|
||||
g_object_unref (layout_state);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
#define STAGE_WIDTH 800
|
||||
#define STAGE_HEIGHT 600
|
||||
|
||||
#define ACTOR_WIDTH 64
|
||||
#define ACTOR_HEIGHT 64
|
||||
|
||||
#define COLS (STAGE_WIDTH/ACTOR_WIDTH)
|
||||
#define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT)
|
||||
#define TOTAL (ROWS*COLS)
|
||||
|
||||
|
||||
static gboolean press_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "right");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean release_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "active");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean enter_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "hover");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean leave_event (ClutterActor *actor,
|
||||
ClutterEvent *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterState *state = CLUTTER_STATE (user_data);
|
||||
clutter_state_set_state (state, "normal");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void completed (ClutterState *state,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("Completed transitioning to state: %s\n",
|
||||
clutter_state_get_state (state));
|
||||
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
}
|
||||
|
||||
static ClutterActor *new_rect (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint a)
|
||||
{
|
||||
GError *error = NULL;
|
||||
ClutterColor *color = clutter_color_new (r, g, b, a);
|
||||
ClutterActor *group = clutter_group_new ();
|
||||
ClutterActor *rectangle = clutter_rectangle_new_with_color (color);
|
||||
ClutterActor *hand = NULL;
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
|
||||
clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
clutter_color_free (color);
|
||||
clutter_container_add (CLUTTER_CONTAINER (group), rectangle, hand, NULL);
|
||||
return group;
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar **argv)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ClutterState *layout_state;
|
||||
gint i;
|
||||
clutter_perf_fps_init ();
|
||||
if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv))
|
||||
g_error ("Failed to initialize Clutter");
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
layout_state = clutter_state_new ();
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Performance [interactive]");
|
||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
|
||||
g_signal_connect (stage, "button-press-event",
|
||||
G_CALLBACK (press_event), layout_state);
|
||||
g_signal_connect (stage, "button-release-event",
|
||||
G_CALLBACK (release_event), layout_state);
|
||||
|
||||
for (i=0; i<TOTAL; i++)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
ClutterState *a_state;
|
||||
|
||||
int row = i/COLS;
|
||||
int col = i%COLS;
|
||||
|
||||
actor = new_rect (255 * ( 1.0*col/COLS), 50,
|
||||
255 * ( 1.0*row/ROWS), 255);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
||||
clutter_actor_set_position (actor, 320.0, 240.0);
|
||||
clutter_actor_set_reactive (actor, TRUE);
|
||||
|
||||
|
||||
clutter_state_set (layout_state, NULL, "active",
|
||||
actor, "delayed::x", CLUTTER_LINEAR,
|
||||
ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
|
||||
((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR,
|
||||
ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
|
||||
((row*1.0/ROWS))/2, 0.0,
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "right",
|
||||
actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
(1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "left",
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
|
||||
actor, "x", CLUTTER_LINEAR, 0-64.0,
|
||||
actor, "y", CLUTTER_LINEAR, 0-64.0,
|
||||
NULL);
|
||||
|
||||
a_state = clutter_state_new ();
|
||||
g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
|
||||
a_state, g_object_unref);
|
||||
g_signal_connect (actor, "enter-event",
|
||||
G_CALLBACK (enter_event), a_state);
|
||||
g_signal_connect (actor, "leave-event",
|
||||
G_CALLBACK (leave_event), a_state);
|
||||
|
||||
clutter_state_set (a_state, NULL, "normal",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0x77,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
clutter_state_set (a_state, NULL, "hover",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0xff,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
|
||||
NULL);
|
||||
clutter_actor_set_opacity (actor, 0x77);
|
||||
|
||||
clutter_state_set_duration (a_state, NULL, NULL, 500);
|
||||
}
|
||||
|
||||
clutter_state_set_duration (layout_state, NULL, NULL, 1000);
|
||||
clutter_state_set_duration (layout_state, "active", "left", 1400);
|
||||
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_perf_fake_mouse (CLUTTER_STAGE (stage));
|
||||
clutter_perf_fps_start (CLUTTER_STAGE (stage));
|
||||
clutter_main ();
|
||||
clutter_perf_fps_report ("test-state-interactive");
|
||||
g_object_unref (layout_state);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
#define STAGE_WIDTH 160
|
||||
#define STAGE_HEIGHT 120
|
||||
|
||||
#define ACTOR_WIDTH 8
|
||||
#define ACTOR_HEIGHT 8
|
||||
|
||||
#define COLS (STAGE_WIDTH/ACTOR_WIDTH)
|
||||
#define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT)
|
||||
#define TOTAL (ROWS*COLS)
|
||||
|
||||
|
||||
static void completed (ClutterState *state,
|
||||
gpointer data)
|
||||
{
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
else if (g_str_equal (clutter_state_get_state (state), "active"))
|
||||
clutter_state_set_state (state, "right");
|
||||
else
|
||||
{
|
||||
clutter_state_set_state (state, "active");
|
||||
}
|
||||
}
|
||||
|
||||
static ClutterActor *new_rect (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint a)
|
||||
{
|
||||
GError *error = NULL;
|
||||
ClutterColor *color = clutter_color_new (r, g, b, a);
|
||||
ClutterActor *group = clutter_group_new ();
|
||||
ClutterActor *rectangle = clutter_rectangle_new_with_color (color);
|
||||
ClutterActor *hand = NULL;
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
|
||||
clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
clutter_color_free (color);
|
||||
clutter_container_add (CLUTTER_CONTAINER (group), rectangle, hand, NULL);
|
||||
return group;
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar **argv)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ClutterState *layout_state;
|
||||
gint i;
|
||||
|
||||
clutter_perf_fps_init ();
|
||||
if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv))
|
||||
g_error ("Failed to initialize Clutter");
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
layout_state = clutter_state_new ();
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Performance [mini]");
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
|
||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||
|
||||
for (i=0; i<TOTAL; i++)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
ClutterState *a_state;
|
||||
|
||||
int row = i/COLS;
|
||||
int col = i%COLS;
|
||||
|
||||
actor = new_rect (255 * ( 1.0*col/COLS), 50,
|
||||
255 * ( 1.0*row/ROWS), 255);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
||||
clutter_actor_set_position (actor, 320.0, 240.0);
|
||||
clutter_actor_set_reactive (actor, TRUE);
|
||||
|
||||
|
||||
clutter_state_set (layout_state, NULL, "active",
|
||||
actor, "delayed::x", CLUTTER_LINEAR,
|
||||
ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
|
||||
((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR,
|
||||
ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
|
||||
((row*1.0/ROWS))/2, 0.0,
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "right",
|
||||
actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
(1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "left",
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
|
||||
actor, "x", CLUTTER_LINEAR, 0-64.0,
|
||||
actor, "y", CLUTTER_LINEAR, 0-64.0,
|
||||
NULL);
|
||||
|
||||
a_state = clutter_state_new ();
|
||||
g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
|
||||
a_state, g_object_unref);
|
||||
|
||||
clutter_state_set (a_state, NULL, "normal",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0x77,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
clutter_state_set (a_state, NULL, "hover",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0xff,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
|
||||
NULL);
|
||||
clutter_actor_set_opacity (actor, 0x77);
|
||||
|
||||
clutter_state_set_duration (a_state, NULL, NULL, 500);
|
||||
}
|
||||
|
||||
clutter_state_set_duration (layout_state, NULL, NULL, 1000);
|
||||
clutter_state_set_duration (layout_state, "active", "left", 1400);
|
||||
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_perf_fps_start (CLUTTER_STAGE (stage));
|
||||
clutter_main ();
|
||||
clutter_perf_fps_report ("test-state-mini");
|
||||
g_object_unref (layout_state);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
static gint times = 16;
|
||||
|
||||
#define STAGE_WIDTH 800
|
||||
#define STAGE_HEIGHT 600
|
||||
|
||||
#define ACTOR_WIDTH 64
|
||||
#define ACTOR_HEIGHT 64
|
||||
|
||||
#define COLS (STAGE_WIDTH/ACTOR_WIDTH)
|
||||
#define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT)
|
||||
#define TOTAL (ROWS*COLS)
|
||||
|
||||
|
||||
static void completed (ClutterState *state,
|
||||
gpointer data)
|
||||
{
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
else if (g_str_equal (clutter_state_get_state (state), "active"))
|
||||
clutter_state_set_state (state, "right");
|
||||
else
|
||||
{
|
||||
clutter_state_set_state (state, "active");
|
||||
}
|
||||
times --;
|
||||
if (times <=0)
|
||||
clutter_main_quit ();
|
||||
}
|
||||
|
||||
static ClutterActor *new_rect (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint a)
|
||||
{
|
||||
GError *error = NULL;
|
||||
ClutterColor *color = clutter_color_new (r, g, b, a);
|
||||
ClutterActor *group = clutter_group_new ();
|
||||
ClutterActor *rectangle = clutter_rectangle_new_with_color (color);
|
||||
ClutterActor *hand = NULL;
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
|
||||
clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
clutter_color_free (color);
|
||||
clutter_container_add (CLUTTER_CONTAINER (group), rectangle, hand, NULL);
|
||||
return group;
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar **argv)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ClutterState *layout_state;
|
||||
gint i;
|
||||
|
||||
clutter_perf_fps_init ();
|
||||
if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv))
|
||||
g_error ("Failed to initialize Clutter");
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
layout_state = clutter_state_new ();
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Performance [pick]");
|
||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||
|
||||
for (i=0; i<TOTAL; i++)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
ClutterState *a_state;
|
||||
|
||||
int row = i/COLS;
|
||||
int col = i%COLS;
|
||||
|
||||
actor = new_rect (255 * ( 1.0*col/COLS), 50,
|
||||
255 * ( 1.0*row/ROWS), 255);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
||||
clutter_actor_set_position (actor, 320.0, 240.0);
|
||||
clutter_actor_set_reactive (actor, TRUE);
|
||||
|
||||
|
||||
clutter_state_set (layout_state, NULL, "active",
|
||||
actor, "delayed::x", CLUTTER_LINEAR,
|
||||
ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
|
||||
((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR,
|
||||
ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
|
||||
((row*1.0/ROWS))/2, 0.0,
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "right",
|
||||
actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
(1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "left",
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
|
||||
actor, "x", CLUTTER_LINEAR, 0-64.0,
|
||||
actor, "y", CLUTTER_LINEAR, 0-64.0,
|
||||
NULL);
|
||||
|
||||
a_state = clutter_state_new ();
|
||||
g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
|
||||
a_state, g_object_unref);
|
||||
|
||||
clutter_state_set (a_state, NULL, "normal",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0x77,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
clutter_state_set (a_state, NULL, "hover",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0xff,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
|
||||
NULL);
|
||||
clutter_actor_set_opacity (actor, 0x77);
|
||||
|
||||
clutter_state_set_duration (a_state, NULL, NULL, 500);
|
||||
}
|
||||
|
||||
clutter_state_set_duration (layout_state, NULL, NULL, 1000);
|
||||
clutter_state_set_duration (layout_state, "active", "left", 1400);
|
||||
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_perf_fake_mouse (CLUTTER_STAGE (stage));
|
||||
clutter_perf_fps_start (CLUTTER_STAGE (stage));
|
||||
clutter_main ();
|
||||
clutter_perf_fps_report ("test-state-pick");
|
||||
g_object_unref (layout_state);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <gmodule.h>
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-common.h"
|
||||
#include "test-utils.h"
|
||||
|
||||
static gint times = 16;
|
||||
|
||||
#define STAGE_WIDTH 800
|
||||
#define STAGE_HEIGHT 600
|
||||
|
||||
#define ACTOR_WIDTH 64
|
||||
#define ACTOR_HEIGHT 64
|
||||
|
||||
#define COLS (STAGE_WIDTH/ACTOR_WIDTH)
|
||||
#define ROWS (STAGE_HEIGHT/ACTOR_HEIGHT)
|
||||
#define TOTAL (ROWS*COLS)
|
||||
|
||||
|
||||
static void completed (ClutterState *state,
|
||||
gpointer data)
|
||||
{
|
||||
if (g_str_equal (clutter_state_get_state (state), "right"))
|
||||
{
|
||||
/* skip straight to left state when reaching right */
|
||||
clutter_state_warp_to_state (state, "left");
|
||||
}
|
||||
else if (g_str_equal (clutter_state_get_state (state), "active"))
|
||||
clutter_state_set_state (state, "right");
|
||||
else
|
||||
{
|
||||
clutter_state_set_state (state, "active");
|
||||
}
|
||||
times --;
|
||||
if (times <=0)
|
||||
clutter_main_quit ();
|
||||
}
|
||||
|
||||
static ClutterActor *new_rect (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint a)
|
||||
{
|
||||
GError *error = NULL;
|
||||
ClutterColor *color = clutter_color_new (r, g, b, a);
|
||||
ClutterActor *group = clutter_group_new ();
|
||||
ClutterActor *rectangle = clutter_rectangle_new_with_color (color);
|
||||
ClutterActor *hand = NULL;
|
||||
|
||||
gchar *file = g_build_filename (TESTS_DATA_DIR, "redhand.png", NULL);
|
||||
|
||||
hand = clutter_test_utils_create_texture_from_file (file, &error);
|
||||
if (rectangle == NULL)
|
||||
g_error ("image load failed: %s", error->message);
|
||||
g_free (file);
|
||||
clutter_actor_set_size (hand, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
|
||||
clutter_actor_set_size (rectangle, ACTOR_WIDTH,ACTOR_HEIGHT);
|
||||
clutter_color_free (color);
|
||||
clutter_container_add (CLUTTER_CONTAINER (group), rectangle, hand, NULL);
|
||||
return group;
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc,
|
||||
gchar **argv)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ClutterState *layout_state;
|
||||
gint i;
|
||||
|
||||
clutter_perf_fps_init ();
|
||||
if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv))
|
||||
g_error ("Failed to initialize Clutter");
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
layout_state = clutter_state_new ();
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
|
||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Performance");
|
||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
||||
|
||||
for (i=0; i<TOTAL; i++)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
ClutterState *a_state;
|
||||
|
||||
int row = i/COLS;
|
||||
int col = i%COLS;
|
||||
|
||||
actor = new_rect (255 * ( 1.0*col/COLS), 50,
|
||||
255 * ( 1.0*row/ROWS), 255);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
||||
clutter_actor_set_position (actor, 320.0, 240.0);
|
||||
clutter_actor_set_reactive (actor, TRUE);
|
||||
|
||||
|
||||
clutter_state_set (layout_state, NULL, "active",
|
||||
actor, "delayed::x", CLUTTER_LINEAR,
|
||||
ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
|
||||
((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR,
|
||||
ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
|
||||
((row*1.0/ROWS))/2, 0.0,
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "right",
|
||||
actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
(1.0-(row*1.0/ROWS))/2,
|
||||
actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
|
||||
((row*1.0/ROWS))/2,
|
||||
0.0,
|
||||
NULL);
|
||||
|
||||
clutter_state_set (layout_state, NULL, "left",
|
||||
actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
|
||||
actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
|
||||
actor, "x", CLUTTER_LINEAR, 0-64.0,
|
||||
actor, "y", CLUTTER_LINEAR, 0-64.0,
|
||||
NULL);
|
||||
|
||||
a_state = clutter_state_new ();
|
||||
g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
|
||||
a_state, g_object_unref);
|
||||
|
||||
clutter_state_set (a_state, NULL, "normal",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0x77,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
|
||||
NULL);
|
||||
clutter_state_set (a_state, NULL, "hover",
|
||||
actor, "opacity", CLUTTER_LINEAR, 0xff,
|
||||
actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
|
||||
NULL);
|
||||
clutter_actor_set_opacity (actor, 0x77);
|
||||
|
||||
clutter_state_set_duration (a_state, NULL, NULL, 500);
|
||||
}
|
||||
|
||||
clutter_state_set_duration (layout_state, NULL, NULL, 1000);
|
||||
clutter_state_set_duration (layout_state, "active", "left", 1400);
|
||||
|
||||
g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
clutter_state_warp_to_state (layout_state, "left");
|
||||
clutter_state_set_state (layout_state, "active");
|
||||
|
||||
clutter_perf_fps_start (CLUTTER_STAGE (stage));
|
||||
clutter_main ();
|
||||
clutter_perf_fps_report ("test-state");
|
||||
g_object_unref (layout_state);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user