2006-05-29 04:59:36 -04:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
2006-06-21 12:29:28 -04:00
|
|
|
#define PARA_TEXT "This is a paragraph of text to check both " \
|
2006-06-20 16:29:45 -04:00
|
|
|
"word wrapping and basic clipping."
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
void
|
|
|
|
rect_cb (ClutterTimeline *timeline,
|
|
|
|
gint frame_num,
|
|
|
|
gpointer data)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2006-06-20 16:29:45 -04:00
|
|
|
ClutterActor *rect = CLUTTER_ACTOR(data);
|
|
|
|
gint x, y;
|
|
|
|
static gint direction = 1;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
x = clutter_actor_get_x (rect);
|
|
|
|
y = clutter_actor_get_y (rect);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
if (x > (CLUTTER_STAGE_WIDTH() - 200))
|
|
|
|
direction = -1;
|
|
|
|
|
|
|
|
if (x < 100)
|
|
|
|
direction = 1;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
x += direction;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
clutter_actor_set_position (rect, x, y);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
void
|
2006-06-20 16:29:45 -04:00
|
|
|
text_cb (ClutterTimeline *timeline,
|
|
|
|
gint frame_num,
|
|
|
|
gpointer data)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
|
|
|
ClutterLabel *label;
|
|
|
|
gchar buf[32];
|
2006-06-20 16:29:45 -04:00
|
|
|
gint opacity;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
label = CLUTTER_LABEL(data);
|
|
|
|
|
|
|
|
opacity = frame_num/2;
|
|
|
|
|
|
|
|
g_snprintf(buf, 32, "--> %i <--", frame_num);
|
|
|
|
|
|
|
|
clutter_label_set_text (label, buf);
|
2006-10-03 17:59:30 -04:00
|
|
|
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);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
clutter_actor_rotate_z (CLUTTER_ACTOR(label),
|
2006-05-29 04:59:36 -04:00
|
|
|
frame_num,
|
2006-06-13 09:17:45 -04:00
|
|
|
clutter_actor_get_width (CLUTTER_ACTOR(label))/2,
|
|
|
|
clutter_actor_get_height (CLUTTER_ACTOR(label))/2);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
void
|
|
|
|
para_cb (ClutterTimeline *timeline,
|
|
|
|
gint frame_num,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
static void
|
|
|
|
key_press_cb (ClutterStage *stage,
|
|
|
|
ClutterKeyEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_print ("key-press-event\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
key_release_cb (ClutterStage *stage,
|
|
|
|
ClutterKeyEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_print ("key-release-event\n");
|
|
|
|
}
|
|
|
|
|
2007-03-23 05:44:21 -04:00
|
|
|
static gboolean
|
|
|
|
delete_event_cb (ClutterStage *stage,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_print ("delete-event\n");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2006-06-20 16:29:45 -04:00
|
|
|
ClutterActor *texture, *label, *rect, *para;
|
|
|
|
ClutterActor *stage;
|
2006-05-29 04:59:36 -04:00
|
|
|
ClutterTimeline *timeline;
|
2006-10-03 17:59:30 -04:00
|
|
|
ClutterColor rect_col = { 0xff, 0x0, 0x0, 0x99 };
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
GdkPixbuf *pixbuf;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
stage = clutter_stage_get_default ();
|
2007-03-23 05:44:21 -04:00
|
|
|
g_signal_connect (stage, "delete-event",
|
|
|
|
G_CALLBACK (delete_event_cb), NULL);
|
2007-03-22 14:21:59 -04:00
|
|
|
g_signal_connect (stage, "key-press-event",
|
|
|
|
G_CALLBACK (key_press_cb), NULL);
|
|
|
|
g_signal_connect (stage, "key-release-event",
|
|
|
|
G_CALLBACK (key_release_cb), NULL);
|
2006-07-15 18:47:37 -04:00
|
|
|
g_signal_connect (stage, "button-press-event",
|
|
|
|
G_CALLBACK (clutter_main_quit),
|
|
|
|
NULL);
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
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);
|
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
label = clutter_label_new_with_text("Sans Bold 32", "hello");
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
clutter_actor_set_opacity (CLUTTER_ACTOR(label), 0x99);
|
|
|
|
clutter_actor_set_position (CLUTTER_ACTOR(label), 550, 100);
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_actor_set_size(label, 400, 0);
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
rect = clutter_rectangle_new_with_color(&rect_col);
|
|
|
|
clutter_actor_set_size(rect, 100, 100);
|
|
|
|
clutter_actor_set_position(rect, 100, 100);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-20 16:29:45 -04:00
|
|
|
para = clutter_label_new_with_text ("Sans 24", PARA_TEXT);
|
|
|
|
clutter_actor_set_position(para, 10, 10);
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_actor_set_size(para, 200, 0);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), texture);
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), label);
|
2006-06-20 16:29:45 -04:00
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), rect);
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), para);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
clutter_actor_set_size (CLUTTER_ACTOR (stage), 800, 600);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
clutter_actor_show_all (CLUTTER_ACTOR (stage));
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
timeline = clutter_timeline_new (360, 200);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
g_object_set (timeline, "loop", TRUE, 0);
|
2006-06-20 16:29:45 -04:00
|
|
|
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);
|
2006-05-29 04:59:36 -04:00
|
|
|
clutter_timeline_start (timeline);
|
|
|
|
|
|
|
|
clutter_main();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|