{
const gchar *text = gtk_entry_get_text (GTK_ENTRY (editable));
- clutter_entry_set_text (CLUTTER_ENTRY (app->clutter_entry), text);
+ clutter_text_set_text (CLUTTER_TEXT (app->clutter_entry), text);
}
static void
on_x_changed (GtkSpinButton *button, EventApp *app)
{
- clutter_actor_rotate_x (app->hand,
- gtk_spin_button_get_value (button),
- clutter_actor_get_height (app->hand),
- 0);
+ clutter_actor_set_rotation (app->hand, CLUTTER_X_AXIS,
+ gtk_spin_button_get_value (button),
+ 0,
+ clutter_actor_get_height (app->hand) / 2,
+ 0);
}
static void
on_y_changed (GtkSpinButton *button, EventApp *app)
{
- clutter_actor_rotate_y (app->hand,
- gtk_spin_button_get_value (button),
- clutter_actor_get_width (app->hand) /2,
- 0);
+ clutter_actor_set_rotation (app->hand, CLUTTER_Y_AXIS,
+ gtk_spin_button_get_value (button),
+ clutter_actor_get_width (app->hand) / 2,
+ 0,
+ 0);
}
static void
on_z_changed (GtkSpinButton *button, EventApp *app)
{
- clutter_actor_rotate_z (app->hand,
- gtk_spin_button_get_value (button),
- clutter_actor_get_width (app->hand) /2,
- clutter_actor_get_height (app->hand)/2);
+ clutter_actor_set_rotation (app->hand, CLUTTER_Z_AXIS,
+ gtk_spin_button_get_value (button),
+ clutter_actor_get_width (app->hand) / 2,
+ clutter_actor_get_height (app->hand) / 2,
+ 0);
}
static void
static void
create_colors (EventApp *app, ClutterColor *stage, ClutterColor *text)
{
- GtkStyle *style = gtk_widget_get_style (app->window);
- GdkColor color;
-
- /* Set the stage color to base[NORMAL] */
- color = style->bg[GTK_STATE_NORMAL];
- stage->red = (guint8) ((color.red/65535.0) * 255);
- stage->green = (guint8) ((color.green/65535.0) * 255);
- stage->blue = (guint8) ((color.blue/65535.0) * 255);
-
- /* Now the text color */
- color = style->text[GTK_STATE_NORMAL];
- text->red =(guint8) ((color.red/65535.0) * 255);
- text->green = (guint8) ((color.green/65535.0) * 255);
- text->blue = (guint8) ((color.blue/65535.0) * 255);
+ gtk_clutter_get_bg_color (app->window, GTK_STATE_NORMAL, stage);
+ gtk_clutter_get_text_color (app->window, GTK_STATE_NORMAL, text);
}
-
+
+static gboolean
+on_stage_capture (ClutterActor *actor,
+ ClutterEvent *event,
+ gpointer dummy)
+{
+ if (event->type == CLUTTER_BUTTON_RELEASE)
+ {
+ gfloat x, y;
+
+ clutter_event_get_coords (event, &x, &y);
+
+ g_print ("Event captured at (%.2f, %.2f)\n", x, y);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+on_hand_button_press (ClutterActor *actor,
+ ClutterButtonEvent *event,
+ gpointer dummy)
+{
+ g_print ("Button press on hand ('%s')\n",
+ g_type_name (G_OBJECT_TYPE (actor)));
+
+ return FALSE;
+}
+
gint
main (gint argc, gchar **argv)
{
GtkWidget *widget, *vbox, *hbox, *button, *label, *box;
ClutterActor *actor;
GdkPixbuf *pixbuf = NULL;
- guint width, height;
+ gfloat width, height;
ClutterColor stage_color = {255, 255, 255, 255};
ClutterColor text_color = {0, 0, 0, 255};
- clutter_init (&argc, &argv);
-
- gtk_init (&argc, &argv);
+ if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
+ g_error ("Unable to initialize GtkClutter");
/* Create the inital gtk window and widgets, just like normal */
widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* Set up clutter & create our stage */
create_colors (app, &stage_color, &text_color);
- widget = gtk_clutter_new ();
+ widget = gtk_clutter_embed_new ();
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
- app->stage = gtk_clutter_get_stage (GTK_CLUTTER (widget));
+ app->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (widget));
clutter_stage_set_color (CLUTTER_STAGE (app->stage), &stage_color);
+ gtk_widget_set_size_request (widget, 640, 480);
+ g_signal_connect (app->stage, "captured-event",
+ G_CALLBACK (on_stage_capture),
+ NULL);
/* Create the main texture that the spin buttons manipulate */
pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
if (pixbuf == NULL)
g_error ("Unable to load pixbuf\n");
- actor = clutter_texture_new_from_pixbuf (pixbuf);
+ actor = gtk_clutter_texture_new_from_pixbuf (pixbuf);
app->hand = actor;
clutter_group_add (CLUTTER_GROUP (app->stage), actor);
clutter_actor_get_size (actor, &width, &height);
clutter_actor_set_position (actor,
(CLUTTER_STAGE_WIDTH ()/2) - (width/2),
(CLUTTER_STAGE_HEIGHT ()/2) - (height/2));
+ clutter_actor_set_reactive (actor, TRUE);
+ g_signal_connect (actor, "button-press-event",
+ G_CALLBACK (on_hand_button_press),
+ NULL);
/* Setup the clutter entry */
- actor = clutter_entry_new_full ("Sans 10", "", &text_color);
+ actor = clutter_text_new_full ("Sans 10", "", &text_color);
app->clutter_entry = actor;
clutter_group_add (CLUTTER_GROUP (app->stage), actor);
clutter_actor_set_position (actor, 0, 0);
gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0);
g_signal_connect (button, "value-changed", G_CALLBACK (on_opacity_changed), app);
- clutter_actor_show_all (app->stage);
gtk_widget_show_all (app->window);
+ /* Only show/show_all the stage after parent show. widget_show will call
+ * show on the stage.
+ */
+ clutter_actor_show_all (app->stage);
+
gtk_main ();
return 0;