mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
10fbfb1659
Rework part of the show/hide machinery. Allow groups sub-classes and composite actors to override show_all/hide_all in order to decide which children they wish to show/hide. This means that if an actor overrides the default show/hide virtual methods, it'll have to chain up to the parent class show/hide. While we're at it, provide the fully recursive clutter_actor_show_all() and clutter_actor_hide_all() methods. * clutter/clutter-behaviour-path.c: Add apidoc for the ClutterKnot functions; add pathological equality case for clutter_knot_equal(). * clutter/clutter-event.h: * clutter/clutter-feature.h: * clutter/clutter-behaviour.c: * clutter/clutter-behaviour-scale.c:Fix parameters name so that gtk-doc doesn't complain. * clutter/clutter-actor.c: * clutter/clutter-event.c: Add apidoc * clutter/clutter-actor.h: * clutter/clutter-actor.c: Add a clutter_actor_show_all() and a clutter_actor_hide_all() functions; provide a mechanism for groups and composited actors to programmatically select what to show/hide when clutter_actor_show_all() and clutter_actor_hide_all() are called. If you are overriding the ClutterActor::show or the ClutterActor::hide virtual methods you should chain up with the parent class. * clutter/clutter-group.c: Override show_all and hide_all and recursively show/hide every child inside the group; clutter_group_show_all() and clutter_group_hide_all() remain as non recursive versions of clutter_actor_show_all() and clutter_actor_hide_all() (maybe we should rename them in order to avoid name clashes with the bindings). * clutter/clutter-stage.c: * clutter/clutter-texture.c: Chain up with parent class show and hide vfuncs. * clutter/clutter-clone-texture.h: * clutter/clutter-clone-texture.c: Provide API for changing the parent texture of a clone texture actor. * examples/behave.c: * examples/super-oh.c: * examples/test.c: Use clutter_actor_show_all() instead of clutter_group_show_all().
132 lines
3.3 KiB
C
132 lines
3.3 KiB
C
#include <clutter/clutter.h>
|
|
|
|
#define PARA_TEXT "This is a paragraph of text to check both " \
|
|
"word wrapping and basic clipping."
|
|
|
|
void
|
|
rect_cb (ClutterTimeline *timeline,
|
|
gint frame_num,
|
|
gpointer data)
|
|
{
|
|
ClutterActor *rect = CLUTTER_ACTOR(data);
|
|
gint x, y;
|
|
static gint direction = 1;
|
|
|
|
x = clutter_actor_get_x (rect);
|
|
y = clutter_actor_get_y (rect);
|
|
|
|
if (x > (CLUTTER_STAGE_WIDTH() - 200))
|
|
direction = -1;
|
|
|
|
if (x < 100)
|
|
direction = 1;
|
|
|
|
x += direction;
|
|
|
|
clutter_actor_set_position (rect, x, y);
|
|
}
|
|
|
|
|
|
void
|
|
text_cb (ClutterTimeline *timeline,
|
|
gint frame_num,
|
|
gpointer data)
|
|
{
|
|
ClutterLabel *label;
|
|
gchar buf[32];
|
|
gint opacity;
|
|
|
|
label = CLUTTER_LABEL(data);
|
|
|
|
opacity = frame_num/2;
|
|
|
|
g_snprintf(buf, 32, "--> %i <--", frame_num);
|
|
|
|
clutter_label_set_text (label, buf);
|
|
clutter_actor_set_size(CLUTTER_ACTOR(label), 150, 0);
|
|
clutter_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
|
|
|
|
clutter_actor_set_opacity (CLUTTER_ACTOR(label), opacity);
|
|
|
|
clutter_actor_rotate_z (CLUTTER_ACTOR(label),
|
|
frame_num,
|
|
clutter_actor_get_width (CLUTTER_ACTOR(label))/2,
|
|
clutter_actor_get_height (CLUTTER_ACTOR(label))/2);
|
|
}
|
|
|
|
void
|
|
para_cb (ClutterTimeline *timeline,
|
|
gint frame_num,
|
|
gpointer data)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
ClutterActor *texture, *label, *rect, *para;
|
|
ClutterActor *stage;
|
|
ClutterTimeline *timeline;
|
|
ClutterColor rect_col = { 0xff, 0x0, 0x0, 0x99 };
|
|
GdkPixbuf *pixbuf;
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
stage = clutter_stage_get_default ();
|
|
g_signal_connect (stage, "button-press-event",
|
|
G_CALLBACK (clutter_main_quit),
|
|
NULL);
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file ("clutter-logo-800x600.png", NULL);
|
|
|
|
if (!pixbuf)
|
|
g_error("pixbuf load failed");
|
|
|
|
texture = clutter_texture_new_from_pixbuf (pixbuf);
|
|
|
|
label = clutter_label_new_with_text("Sans Bold 32", "hello");
|
|
|
|
clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99);
|
|
clutter_actor_set_position (CLUTTER_ACTOR(label), 550, 100);
|
|
clutter_actor_set_size(label, 400, 0);
|
|
|
|
|
|
rect = clutter_rectangle_new_with_color(&rect_col);
|
|
clutter_actor_set_size(rect, 100, 100);
|
|
clutter_actor_set_position(rect, 100, 100);
|
|
|
|
para = clutter_label_new_with_text ("Sans 24", PARA_TEXT);
|
|
clutter_actor_set_position(para, 10, 10);
|
|
clutter_actor_set_size(para, 200, 0);
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), texture);
|
|
clutter_group_add (CLUTTER_GROUP (stage), label);
|
|
clutter_group_add (CLUTTER_GROUP (stage), rect);
|
|
clutter_group_add (CLUTTER_GROUP (stage), para);
|
|
|
|
clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600);
|
|
|
|
clutter_actor_show_all (CLUTTER_ACTOR (stage));
|
|
|
|
timeline = clutter_timeline_new (360, 200);
|
|
g_object_set (timeline, "loop", TRUE, 0);
|
|
g_signal_connect (timeline, "new-frame", G_CALLBACK (text_cb), label);
|
|
clutter_timeline_start (timeline);
|
|
|
|
timeline = clutter_timeline_new (1, 30);
|
|
g_object_set (timeline, "loop", TRUE, 0);
|
|
g_signal_connect (timeline, "new-frame", G_CALLBACK (rect_cb), rect);
|
|
clutter_timeline_start (timeline);
|
|
|
|
timeline = clutter_timeline_new (1, 10);
|
|
g_object_set (timeline, "loop", TRUE, 0);
|
|
g_signal_connect (timeline, "new-frame", G_CALLBACK (para_cb), rect);
|
|
clutter_timeline_start (timeline);
|
|
|
|
clutter_main();
|
|
|
|
return 0;
|
|
}
|