#include <clutter/clutter.h>
#include <math.h>
-#include <clutter-gtk/gtk-clutter-embed.h>
-#include <clutter-gtk/gtk-clutter-util.h>
+#include <clutter-gtk/clutter-gtk.h>
#define TRAILS 0
#define NHANDS 2
} SuperOH;
-gboolean fade = FALSE;
+static gboolean fade = FALSE;
+static gboolean fullscreen = FALSE;
/* input handler */
void
if (event->type == CLUTTER_BUTTON_PRESS)
{
ClutterActor *a;
- gint x, y;
+ gfloat x, y;
clutter_event_get_coords (event, &x, &y);
- a = clutter_stage_get_actor_at_pos (stage, x, y);
- if (a && (CLUTTER_IS_TEXTURE (a) || CLUTTER_IS_CLONE_TEXTURE (a)))
+ a = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y);
+ if (a && (CLUTTER_IS_TEXTURE (a) || CLUTTER_IS_CLONE (a)))
clutter_actor_hide (a);
}
else if (event->type == CLUTTER_KEY_PRESS)
{
- ClutterKeyEvent *kev = (ClutterKeyEvent *) event;
-
g_print ("*** key press event (key:%c) ***\n",
- clutter_key_event_symbol (kev));
+ clutter_event_get_key_symbol (event));
- if (clutter_key_event_symbol (kev) == CLUTTER_q)
+ if (clutter_event_get_key_symbol (event) == CLUTTER_q)
gtk_main_quit ();
}
}
/* Timeline handler */
void
frame_cb (ClutterTimeline *timeline,
- gint frame_num,
+ gint msecs,
gpointer data)
{
SuperOH *oh = (SuperOH *)data;
gint i;
+ guint rotation = clutter_timeline_get_progress (timeline) * 360.0f;
#if TRAILS
oh->bgpixb = clutter_stage_snapshot (CLUTTER_STAGE (stage),
/* Rotate everything clockwise about stage center*/
clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
CLUTTER_Z_AXIS,
- frame_num,
+ rotation,
WINWIDTH / 2, WINHEIGHT / 2, 0);
for (i = 0; i < NHANDS; i++)
/* rotate each hand around there centers */
clutter_actor_set_rotation (oh->hand[i],
CLUTTER_Z_AXIS,
- - 6.0 * frame_num,
+ - 6.0 * rotation,
clutter_actor_get_width (oh->hand[i]) / 2,
clutter_actor_get_height (oh->hand[i]) / 2,
0);
if (fade == TRUE)
- clutter_actor_set_opacity (oh->hand[i], (255 - (frame_num % 255)));
+ clutter_actor_set_opacity (oh->hand[i], (255 - (rotation % 255)));
}
/*
fade = !fade;
}
+static void
+on_fullscreen (GtkButton *button,
+ GtkWindow *window)
+{
+ if (!fullscreen)
+ {
+ gtk_window_fullscreen (window);
+ fullscreen = TRUE;
+ }
+ else
+ {
+ gtk_window_unfullscreen (window);
+ fullscreen = FALSE;
+ }
+}
+
int
main (int argc, char *argv[])
{
ClutterTimeline *timeline;
ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
- GtkWidget *window, *clutter, *socket_box;
+ GtkWidget *window, *clutter;
GtkWidget *label, *button, *vbox;
GdkPixbuf *pixbuf;
SuperOH *oh;
G_CALLBACK (clickity), NULL);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("Fullscreen");
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_stock (GTK_STOCK_FULLSCREEN,
+ GTK_ICON_SIZE_BUTTON));
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (on_fullscreen),
+ window);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gtk_widget_destroy),
if (i == 0)
oh->hand[i] = gtk_clutter_texture_new_from_pixbuf (pixbuf);
else
- oh->hand[i] = clutter_clone_texture_new (CLUTTER_TEXTURE (oh->hand[0]));
+ oh->hand[i] = clutter_clone_new (oh->hand[0]);
#else
ClutterColor colour = { 255, 0, 0, 255 };
clutter_actor_show_all (CLUTTER_ACTOR (oh->group));
/* Create a timeline to manage animation */
- timeline = clutter_timeline_new (360, 60); /* num frames, fps */
+ timeline = clutter_timeline_new (6000);
g_object_set(timeline, "loop", TRUE, NULL); /* have it loop */
/* fire a callback for frame change */