mutter/examples/test-text.c
Emmanuele Bassi 3c2defee9d 2007-06-07 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-container.[ch]: Add a generic actor container
	interface, for actors to implement without subclassing ClutterGroup.

	* clutter/clutter-group.[ch]: Make ClutterGroup implement the
	ClutterContainer interface, and deprecate the colliding methods.

	* clutter/clutter-layout.[ch]: Add extended layout interface.
	Actors and containers requiring or honouring complex layout
	management should implement this interface and provide at least
	one of the available layout types: width for height, height for
	width, natural size, iterative size request.

	* clutter/clutter-label.c: A ClutterLabel requires height for
	width layout management, so it implements the ClutterLayout
	interface.

	* clutter/Makefile.am: Add new files to the build.

	* tests/*.c:
	* examples/*.c: Update tests and examples code to use the
	new ClutterContainer API instead of ClutterGroup.
2007-06-07 14:41:35 +00:00

57 lines
1.5 KiB
C

#include <clutter/clutter.h>
void
frame_cb (ClutterTimeline *timeline,
gint frame_num,
gpointer data)
{
ClutterActor *label = (ClutterActor*)data;
clutter_actor_set_depth(label, -400 + (frame_num * 40));
clutter_actor_set_opacity (label, 255 - frame_num );
}
int
main (int argc, char *argv[])
{
ClutterTimeline *timeline;
ClutterActor *label;
ClutterActor *stage;
gchar *text;
gsize size;
ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
ClutterColor label_color = { 0x11, 0xdd, 0x11, 0xaa };
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
if (!g_file_get_contents ("test-text.c", &text, &size, NULL))
g_error("g_file_get_contents() of test-text.c failed");
clutter_actor_set_size (stage, 800, 600);
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
label = clutter_label_new_with_text ("Mono 8", text);
clutter_label_set_color (CLUTTER_LABEL (label), &label_color);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
clutter_actor_show_all (stage);
timeline = clutter_timeline_new (400, 60); /* num frames, fps */
g_object_set(timeline, "loop", TRUE, 0); /* have it loop */
g_signal_connect(timeline, "new-frame", G_CALLBACK (frame_cb), label);
/* and start it */
clutter_timeline_start (timeline);
g_signal_connect (stage, "key-press-event",
G_CALLBACK (clutter_main_quit), NULL);
clutter_main();
return 0;
}