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:
Elliot Smith 2010-08-17 11:51:33 +01:00
parent 1e4578d1dd
commit 8c0c2924ae
2 changed files with 41 additions and 41 deletions

View File

@ -16,8 +16,8 @@ static guint animation_duration_ms = 1500;
static const ClutterColor stage_color = { 0x33, 0x33, 0x55, 0xff }; static const ClutterColor stage_color = { 0x33, 0x33, 0x55, 0xff };
typedef struct { typedef struct {
ClutterActor *front; ClutterActor *top;
ClutterActor *back; ClutterActor *bottom;
ClutterState *transitions; ClutterState *transitions;
GSList *image_paths; GSList *image_paths;
guint next_image_index; guint next_image_index;
@ -48,20 +48,20 @@ load_next_image (State *app)
g_debug ("Loading %s", image_path); g_debug ("Loading %s", image_path);
CoglHandle *cogl_texture; 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) if (cogl_texture != NULL)
{ {
/* copy the current texture into the background */ /* 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 */ /* make the bottom opaque and top transparent */
clutter_state_warp_to_state (app->transitions, "show-back"); 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; GError *error = NULL;
clutter_texture_set_from_file (CLUTTER_TEXTURE (app->front), clutter_texture_set_from_file (CLUTTER_TEXTURE (app->top),
image_path, image_path,
&error); &error);
@ -72,8 +72,8 @@ load_next_image (State *app)
return FALSE; return FALSE;
} }
/* fade in the front texture and fade out the back texture */ /* fade in the top texture and fade out the bottom texture */
clutter_state_set_state (app->transitions, "show-front"); clutter_state_set_state (app->transitions, "show-top");
app->next_image_index++; app->next_image_index++;
@ -133,25 +133,25 @@ main (int argc, char *argv[])
box = clutter_box_new (layout); box = clutter_box_new (layout);
clutter_actor_set_size (box, stage_side, stage_side); clutter_actor_set_size (box, stage_side, stage_side);
app->back = clutter_texture_new (); app->bottom = clutter_texture_new ();
clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->back), TRUE); clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->bottom), TRUE);
app->front = clutter_texture_new (); app->top = clutter_texture_new ();
clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (app->front), TRUE); 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->bottom);
clutter_container_add_actor (CLUTTER_CONTAINER (box), app->front); clutter_container_add_actor (CLUTTER_CONTAINER (box), app->top);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
/* animations */ /* animations */
app->transitions = clutter_state_new (); app->transitions = clutter_state_new ();
clutter_state_set (app->transitions, NULL, "show-front", clutter_state_set (app->transitions, NULL, "show-top",
app->front, "opacity", CLUTTER_EASE_IN_CUBIC, 255, app->top, "opacity", CLUTTER_EASE_IN_CUBIC, 255,
app->back, "opacity", CLUTTER_EASE_IN_CUBIC, 0, app->bottom, "opacity", CLUTTER_EASE_IN_CUBIC, 0,
NULL); NULL);
clutter_state_set (app->transitions, NULL, "show-back", clutter_state_set (app->transitions, NULL, "show-bottom",
app->front, "opacity", CLUTTER_LINEAR, 0, app->top, "opacity", CLUTTER_LINEAR, 0,
app->back, "opacity", CLUTTER_LINEAR, 255, app->bottom, "opacity", CLUTTER_LINEAR, 255,
NULL); NULL);
clutter_state_set_duration (app->transitions, clutter_state_set_duration (app->transitions,
NULL, NULL,

View File

@ -70,7 +70,7 @@ main (int argc, char *argv[])
ClutterActor *stage; ClutterActor *stage;
ClutterLayoutManager *layout; ClutterLayoutManager *layout;
ClutterActor *box; ClutterActor *box;
ClutterActor *front, *back; ClutterActor *top, *bottom;
ClutterState *transitions; ClutterState *transitions;
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
@ -87,36 +87,36 @@ main (int argc, char *argv[])
box = clutter_box_new (layout); box = clutter_box_new (layout);
clutter_actor_set_size (box, 600, 600); clutter_actor_set_size (box, 600, 600);
back = clutter_texture_new (); bottom = clutter_texture_new ();
front = clutter_texture_new (); top = clutter_texture_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (box), back); clutter_container_add_actor (CLUTTER_CONTAINER (box), bottom);
clutter_container_add_actor (CLUTTER_CONTAINER (box), front); clutter_container_add_actor (CLUTTER_CONTAINER (box), top);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
/* load the first image into the back */ /* load the first image into the bottom */
load_image (CLUTTER_TEXTURE (back), source); load_image (CLUTTER_TEXTURE (bottom), source);
/* load the second image into the front */ /* load the second image into the top */
load_image (CLUTTER_TEXTURE (front), target); load_image (CLUTTER_TEXTURE (top), target);
/* animations */ /* animations */
transitions = clutter_state_new (); transitions = clutter_state_new ();
clutter_state_set (transitions, NULL, "show-back", clutter_state_set (transitions, NULL, "show-bottom",
front, "opacity", CLUTTER_LINEAR, 0, top, "opacity", CLUTTER_LINEAR, 0,
back, "opacity", CLUTTER_LINEAR, 255, bottom, "opacity", CLUTTER_LINEAR, 255,
NULL); NULL);
clutter_state_set (transitions, NULL, "show-front", clutter_state_set (transitions, NULL, "show-top",
front, "opacity", CLUTTER_EASE_IN_CUBIC, 255, top, "opacity", CLUTTER_EASE_IN_CUBIC, 255,
back, "opacity", CLUTTER_EASE_IN_CUBIC, 0, bottom, "opacity", CLUTTER_EASE_IN_CUBIC, 0,
NULL); NULL);
clutter_state_set_duration (transitions, NULL, NULL, duration); clutter_state_set_duration (transitions, NULL, NULL, duration);
/* make the back opaque and front transparent */ /* make the bottom opaque and top transparent */
clutter_state_warp_to_state (transitions, "show-back"); clutter_state_warp_to_state (transitions, "show-bottom");
/* fade in the front texture and fade out the back texture */ /* fade in the top texture and fade out the bottom texture */
clutter_state_set_state (transitions, "show-front"); clutter_state_set_state (transitions, "show-top");
clutter_actor_show (stage); clutter_actor_show (stage);