cookbook: Renamed front/back to top/bottom in cross-fade example
Front/back seems like the wrong terminology when discussing actors arranged in layers. Top/bottom fits better with Clutter API function names and other recipes, so renamed variables.
This commit is contained in:
parent
1e4578d1dd
commit
8c0c2924ae
@ -16,8 +16,8 @@ static guint animation_duration_ms = 1500;
|
||||
static const ClutterColor stage_color = { 0x33, 0x33, 0x55, 0xff };
|
||||
|
||||
typedef struct {
|
||||
ClutterActor *front;
|
||||
ClutterActor *back;
|
||||
ClutterActor *top;
|
||||
ClutterActor *bottom;
|
||||
ClutterState *transitions;
|
||||
GSList *image_paths;
|
||||
guint next_image_index;
|
||||
@ -48,20 +48,20 @@ load_next_image (State *app)
|
||||
g_debug ("Loading %s", image_path);
|
||||
|
||||
CoglHandle *cogl_texture;
|
||||
cogl_texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (app->front));
|
||||
cogl_texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (app->top));
|
||||
|
||||
if (cogl_texture != NULL)
|
||||
{
|
||||
/* copy the current texture into the background */
|
||||
clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (app->back), cogl_texture);
|
||||
clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (app->bottom), cogl_texture);
|
||||
|
||||
/* make the back opaque and front transparent */
|
||||
clutter_state_warp_to_state (app->transitions, "show-back");
|
||||
/* make the bottom opaque and top transparent */
|
||||
clutter_state_warp_to_state (app->transitions, "show-bottom");
|
||||
}
|
||||
|
||||
/* load the next image into the front */
|
||||
/* load the next image into the top */
|
||||
GError *error = NULL;
|
||||
clutter_texture_set_from_file (CLUTTER_TEXTURE (app->front),
|
||||
clutter_texture_set_from_file (CLUTTER_TEXTURE (app->top),
|
||||
image_path,
|
||||
&error);
|
||||
|
||||
@ -72,8 +72,8 @@ load_next_image (State *app)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* fade in the front texture and fade out the back texture */
|
||||
clutter_state_set_state (app->transitions, "show-front");
|
||||
/* fade in the top texture and fade out the bottom texture */
|
||||
clutter_state_set_state (app->transitions, "show-top");
|
||||
|
||||
app->next_image_index++;
|
||||
|
||||
@ -133,25 +133,25 @@ main (int argc, char *argv[])
|
||||
box = clutter_box_new (layout);
|
||||
clutter_actor_set_size (box, stage_side, stage_side);
|
||||
|
||||
app->back = clutter_texture_new ();
|
||||
clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->back), TRUE);
|
||||
app->bottom = clutter_texture_new ();
|
||||
clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->bottom), TRUE);
|
||||
|
||||
app->front = clutter_texture_new ();
|
||||
clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->front), TRUE);
|
||||
app->top = clutter_texture_new ();
|
||||
clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->top), TRUE);
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), app->back);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), app->front);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), app->bottom);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), app->top);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
|
||||
|
||||
/* animations */
|
||||
app->transitions = clutter_state_new ();
|
||||
clutter_state_set (app->transitions, NULL, "show-front",
|
||||
app->front, "opacity", CLUTTER_EASE_IN_CUBIC, 255,
|
||||
app->back, "opacity", CLUTTER_EASE_IN_CUBIC, 0,
|
||||
clutter_state_set (app->transitions, NULL, "show-top",
|
||||
app->top, "opacity", CLUTTER_EASE_IN_CUBIC, 255,
|
||||
app->bottom, "opacity", CLUTTER_EASE_IN_CUBIC, 0,
|
||||
NULL);
|
||||
clutter_state_set (app->transitions, NULL, "show-back",
|
||||
app->front, "opacity", CLUTTER_LINEAR, 0,
|
||||
app->back, "opacity", CLUTTER_LINEAR, 255,
|
||||
clutter_state_set (app->transitions, NULL, "show-bottom",
|
||||
app->top, "opacity", CLUTTER_LINEAR, 0,
|
||||
app->bottom, "opacity", CLUTTER_LINEAR, 255,
|
||||
NULL);
|
||||
clutter_state_set_duration (app->transitions,
|
||||
NULL,
|
||||
|
@ -70,7 +70,7 @@ main (int argc, char *argv[])
|
||||
ClutterActor *stage;
|
||||
ClutterLayoutManager *layout;
|
||||
ClutterActor *box;
|
||||
ClutterActor *front, *back;
|
||||
ClutterActor *top, *bottom;
|
||||
ClutterState *transitions;
|
||||
|
||||
clutter_init (&argc, &argv);
|
||||
@ -87,36 +87,36 @@ main (int argc, char *argv[])
|
||||
box = clutter_box_new (layout);
|
||||
clutter_actor_set_size (box, 600, 600);
|
||||
|
||||
back = clutter_texture_new ();
|
||||
front = clutter_texture_new ();
|
||||
bottom = clutter_texture_new ();
|
||||
top = clutter_texture_new ();
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), back);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), front);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), bottom);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (box), top);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
|
||||
|
||||
/* load the first image into the back */
|
||||
load_image (CLUTTER_TEXTURE (back), source);
|
||||
/* load the first image into the bottom */
|
||||
load_image (CLUTTER_TEXTURE (bottom), source);
|
||||
|
||||
/* load the second image into the front */
|
||||
load_image (CLUTTER_TEXTURE (front), target);
|
||||
/* load the second image into the top */
|
||||
load_image (CLUTTER_TEXTURE (top), target);
|
||||
|
||||
/* animations */
|
||||
transitions = clutter_state_new ();
|
||||
clutter_state_set (transitions, NULL, "show-back",
|
||||
front, "opacity", CLUTTER_LINEAR, 0,
|
||||
back, "opacity", CLUTTER_LINEAR, 255,
|
||||
clutter_state_set (transitions, NULL, "show-bottom",
|
||||
top, "opacity", CLUTTER_LINEAR, 0,
|
||||
bottom, "opacity", CLUTTER_LINEAR, 255,
|
||||
NULL);
|
||||
clutter_state_set (transitions, NULL, "show-front",
|
||||
front, "opacity", CLUTTER_EASE_IN_CUBIC, 255,
|
||||
back, "opacity", CLUTTER_EASE_IN_CUBIC, 0,
|
||||
clutter_state_set (transitions, NULL, "show-top",
|
||||
top, "opacity", CLUTTER_EASE_IN_CUBIC, 255,
|
||||
bottom, "opacity", CLUTTER_EASE_IN_CUBIC, 0,
|
||||
NULL);
|
||||
clutter_state_set_duration (transitions, NULL, NULL, duration);
|
||||
|
||||
/* make the back opaque and front transparent */
|
||||
clutter_state_warp_to_state (transitions, "show-back");
|
||||
/* make the bottom opaque and top transparent */
|
||||
clutter_state_warp_to_state (transitions, "show-bottom");
|
||||
|
||||
/* fade in the front texture and fade out the back texture */
|
||||
clutter_state_set_state (transitions, "show-front");
|
||||
/* fade in the top texture and fade out the bottom texture */
|
||||
clutter_state_set_state (transitions, "show-top");
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user