[tests] Update test-actors (and clones)

The test-actors test (and its clones, test-actor-clone and
test-paint-wrapper) was written a long time ago for a different API
and has been tweaked to bits. We should probably have something a
little bit more complicated, but at least we should not use semantics
and coding patterns from Clutter 0.2, otherwise we won't be testing
anything except that Clutter 0.2 worked.
This commit is contained in:
Emmanuele Bassi
2009-06-11 16:23:26 +01:00
parent 71b62e75d2
commit 19f112f9bc
3 changed files with 184 additions and 188 deletions

View File

@ -36,7 +36,24 @@ static GOptionEntry super_oh_entries[] = {
{ NULL }
};
/* input handler */
static gboolean
on_button_press_event (ClutterActor *actor,
ClutterEvent *event,
SuperOH *oh)
{
gfloat x, y;
clutter_event_get_coords (event, &x, &y);
g_print ("*** button press event (button:%d) at %.2f, %.2f ***\n",
clutter_event_get_button (event),
x, y);
clutter_actor_hide (actor);
return TRUE;
}
static gboolean
input_cb (ClutterActor *stage,
ClutterEvent *event,
@ -44,31 +61,7 @@ input_cb (ClutterActor *stage,
{
SuperOH *oh = data;
if (event->type == CLUTTER_BUTTON_PRESS)
{
ClutterButtonEvent *button_event;
ClutterActor *e;
gfloat x, y;
clutter_event_get_coords (event, &x, &y);
button_event = (ClutterButtonEvent *) event;
g_print ("*** button press event (button:%d) at %.2f, %.2f ***\n",
button_event->button,
x, y);
e = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage),
CLUTTER_PICK_ALL,
x, y);
/* only allow hiding the clones */
if (e && CLUTTER_IS_CLONE (e))
{
clutter_actor_hide (e);
return TRUE;
}
}
else if (event->type == CLUTTER_KEY_RELEASE)
if (event->type == CLUTTER_KEY_RELEASE)
{
g_print ("*** key press event (key:%c) ***\n",
clutter_event_get_key_symbol (event));
@ -76,6 +69,7 @@ input_cb (ClutterActor *stage,
if (clutter_event_get_key_symbol (event) == CLUTTER_q)
{
clutter_main_quit ();
return TRUE;
}
else if (clutter_event_get_key_symbol (event) == CLUTTER_r)
@ -85,8 +79,6 @@ input_cb (ClutterActor *stage,
for (i = 0; i < n_hands; i++)
clutter_actor_show (oh->hand[i]);
clutter_actor_show (oh->real_hand);
return TRUE;
}
}
@ -94,7 +86,6 @@ input_cb (ClutterActor *stage,
return FALSE;
}
/* Timeline handler */
static void
frame_cb (ClutterTimeline *timeline,
@ -116,10 +107,6 @@ frame_cb (ClutterTimeline *timeline,
for (i = 0; i < n_hands; i++)
{
gdouble scale_x, scale_y;
clutter_actor_get_scale (oh->hand[i], &scale_x, &scale_y);
/* Rotate each hand around there centers - to get this we need
* to take into account any scaling.
*/
@ -235,8 +222,11 @@ test_actor_clone_main (int argc, char *argv[])
/* Create a texture from file, then clone in to same resources */
oh->hand[i] = clutter_clone_new (real_hand);
clutter_actor_set_size (oh->hand[i], 200, 213);
clutter_actor_set_reactive (oh->hand[i], TRUE);
/* Place around a circle */
w = clutter_actor_get_width (oh->hand[0]);
h = clutter_actor_get_height (oh->hand[0]);
@ -259,6 +249,10 @@ test_actor_clone_main (int argc, char *argv[])
/* Add to our group group */
clutter_container_add_actor (CLUTTER_CONTAINER (oh->group), oh->hand[i]);
g_signal_connect (oh->hand[i], "button-press-event",
G_CALLBACK (on_button_press_event),
oh);
if (i % 2)
clutter_behaviour_apply (oh->scaler_1, oh->hand[i]);
else
@ -271,9 +265,6 @@ test_actor_clone_main (int argc, char *argv[])
/* Show everying */
clutter_actor_show (stage);
g_signal_connect (stage, "button-press-event",
G_CALLBACK (input_cb),
oh);
g_signal_connect (stage, "key-release-event",
G_CALLBACK (input_cb),
oh);