[clutter-gtk] examples: Clean up
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter-gtk] examples: Clean up
- Date: Tue, 19 Mar 2013 13:45:40 +0000 (UTC)
commit 293221cb3f4284a23911f057505fcef3ef87ccfa
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Mar 19 10:44:29 2013 -0300
examples: Clean up
Drop deprecated API usage, and drop a couple of examples that made
little to no sense, or just demonstrated the API in the wrong way.
examples/Makefile.am | 32 +----
examples/gtk-clutter-events.c | 27 +---
examples/gtk-clutter-multistage.c | 27 +----
examples/gtk-clutter-test-actor.c | 50 ++++----
examples/gtk-clutter-test-scroll.c | 249 -----------------------------------
examples/gtk-clutter-test.c | 36 ++---
examples/gtk-clutter-window-test2.c | 178 -------------------------
7 files changed, 51 insertions(+), 548 deletions(-)
---
diff --git a/examples/Makefile.am b/examples/Makefile.am
index af1b2e9..98e8e4f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -7,9 +7,7 @@ noinst_PROGRAMS = \
gtk-clutter-multistage \
gtk-clutter-test \
gtk-clutter-test-actor \
- gtk-clutter-window-test \
- gtk-clutter-window-test2 \
- gtk-clutter-test-scroll
+ gtk-clutter-window-test
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)/clutter-gtk
@@ -23,33 +21,7 @@ common_ldadd = \
$(CLUTTER_GTK_DEPS_LIBS) \
$(LIBM)
-gtk_clutter_test_SOURCES = gtk-clutter-test.c
-gtk_clutter_test_DEPENDENCIES = $(common_deps)
-gtk_clutter_test_LDADD = $(common_ldadd)
-
-gtk_clutter_test_actor_SOURCES = gtk-clutter-test-actor.c
-gtk_clutter_test_actor_DEPENDENCIES = $(common_deps)
-gtk_clutter_test_actor_LDADD = $(common_ldadd)
-
-gtk_clutter_events_SOURCES = gtk-clutter-events.c
-gtk_clutter_events_DEPENDENCIES = $(common_deps)
-gtk_clutter_events_LDADD = $(common_ldadd)
-
-gtk_clutter_multistage_SOURCES = gtk-clutter-multistage.c
-gtk_clutter_multistage_DEPENDENCIES = $(common_deps)
-gtk_clutter_multistage_LDADD = $(common_ldadd)
-
-gtk_clutter_window_test_SOURCES = gtk-clutter-window-test.c
-gtk_clutter_window_test_DEPENDENCIES = $(common_deps)
-gtk_clutter_window_test_LDADD = $(common_ldadd)
-
-gtk_clutter_window_test2_SOURCES = gtk-clutter-window-test2.c
-gtk_clutter_window_test2_DEPENDENCIES = $(common_deps)
-gtk_clutter_window_test2_LDADD = $(common_ldadd)
-
-gtk_clutter_test_scroll_SOURCES = gtk-clutter-test-scroll.c
-gtk_clutter_test_scroll_DEPENDENCIES = $(common_deps)
-gtk_clutter_test_scroll_LDADD = $(common_ldadd)
+LDADD = $(common_ldadd)
EXTRA_DIST = \
redhand.png
diff --git a/examples/gtk-clutter-events.c b/examples/gtk-clutter-events.c
index 897c124..abdeeeb 100644
--- a/examples/gtk-clutter-events.c
+++ b/examples/gtk-clutter-events.c
@@ -42,31 +42,22 @@ on_gtk_entry_changed (GtkEditable *editable, EventApp *app)
static void
on_x_changed (GtkSpinButton *button, EventApp *app)
{
- clutter_actor_set_rotation (app->hand, CLUTTER_X_AXIS,
- gtk_spin_button_get_value (button),
- 0,
- clutter_actor_get_height (app->hand) / 2,
- 0);
+ clutter_actor_set_rotation_angle (app->hand, CLUTTER_X_AXIS,
+ gtk_spin_button_get_value (button));
}
static void
on_y_changed (GtkSpinButton *button, EventApp *app)
{
- clutter_actor_set_rotation (app->hand, CLUTTER_Y_AXIS,
- gtk_spin_button_get_value (button),
- clutter_actor_get_width (app->hand) / 2,
- 0,
- 0);
+ clutter_actor_set_rotation_angle (app->hand, CLUTTER_Y_AXIS,
+ gtk_spin_button_get_value (button));
}
static void
on_z_changed (GtkSpinButton *button, EventApp *app)
{
- 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);
+ clutter_actor_set_rotation_angle (app->hand, CLUTTER_Z_AXIS,
+ gtk_spin_button_get_value (button));
}
static void
@@ -196,10 +187,8 @@ main (gint argc, gchar **argv)
app->hand = actor = gtk_clutter_texture_new ();
gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (actor), pixbuf, NULL);
clutter_actor_add_child (app->stage, actor);
- clutter_actor_set_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER);
- clutter_actor_set_position (actor,
- clutter_actor_get_width (app->stage) / 2,
- clutter_actor_get_height (app->stage) / 2);
+ clutter_actor_set_pivot_point (actor, 0.5, 0.5);
+ clutter_actor_add_constraint (actor, clutter_align_constraint_new (app->stage, CLUTTER_ALIGN_BOTH, 0.5));
clutter_actor_set_reactive (actor, TRUE);
clutter_actor_set_name (actor, "Red Hand");
g_signal_connect (actor, "button-press-event",
diff --git a/examples/gtk-clutter-multistage.c b/examples/gtk-clutter-multistage.c
index e274bcf..ca394dd 100644
--- a/examples/gtk-clutter-multistage.c
+++ b/examples/gtk-clutter-multistage.c
@@ -3,17 +3,6 @@
#include <clutter-gtk/clutter-gtk.h>
-static void
-on_stage2_allocation_changed (ClutterActor *stage_2,
- const ClutterActorBox *allocation,
- ClutterAllocationFlags flags,
- ClutterActor *texture_2)
-{
- clutter_actor_set_position (texture_2,
- (allocation->x2 - allocation->x1) / 2,
- (allocation->y2 - allocation->y1) / 2);
-}
-
int
main (int argc, char *argv[])
{
@@ -55,10 +44,9 @@ main (int argc, char *argv[])
GTK_STOCK_DIALOG_INFO,
GTK_ICON_SIZE_DIALOG,
NULL);
- clutter_actor_set_anchor_point (tex1,
- clutter_actor_get_width (tex1) / 2,
- clutter_actor_get_height (tex1) / 2);
- clutter_actor_set_position (tex1, 160, 120);
+ clutter_actor_set_position (tex1,
+ 160 - clutter_actor_get_width (tex1) / 2.0,
+ 120 - clutter_actor_get_height (tex1) / 2.0);
clutter_actor_add_child (stage1, tex1);
clutter_actor_show (tex1);
@@ -74,18 +62,11 @@ main (int argc, char *argv[])
"user-info",
GTK_ICON_SIZE_BUTTON,
NULL);
- clutter_actor_set_anchor_point (tex2,
- clutter_actor_get_width (tex2) / 2,
- clutter_actor_get_height (tex2) / 2);
- clutter_actor_set_position (tex2, 160, 60);
+ clutter_actor_add_constraint (tex2, clutter_align_constraint_new (stage2, CLUTTER_ALIGN_BOTH, .5));
clutter_actor_add_child (stage2, tex2);
gtk_container_add (GTK_CONTAINER (vbox), clutter2);
- g_signal_connect (stage2, "allocation-changed",
- G_CALLBACK (on_stage2_allocation_changed),
- tex2);
-
gtk_widget_show_all (window);
gtk_main();
diff --git a/examples/gtk-clutter-test-actor.c b/examples/gtk-clutter-test-actor.c
index e205b45..f035dbe 100644
--- a/examples/gtk-clutter-test-actor.c
+++ b/examples/gtk-clutter-test-actor.c
@@ -28,12 +28,7 @@ frame_cb (ClutterTimeline *timeline,
return;
/* Rotate everything clockwise about stage center */
- clutter_actor_set_rotation (CLUTTER_ACTOR (group),
- CLUTTER_Z_AXIS,
- rotation,
- WINWIDTH / 2,
- WINHEIGHT / 2,
- 0);
+ clutter_actor_set_rotation_angle (group, CLUTTER_Z_AXIS, rotation);
for (i = 0; i < nwidgets; i++)
{
@@ -41,11 +36,7 @@ frame_cb (ClutterTimeline *timeline,
gfloat w = clutter_actor_get_width (widgets[i]);
gfloat h = clutter_actor_get_height (widgets[i]);
- clutter_actor_set_rotation (widgets[i], CLUTTER_Z_AXIS,
- - 2 * rotation,
- w / 2,
- h / 2,
- 0);
+ clutter_actor_set_rotation_angle (widgets[i], CLUTTER_Z_AXIS, - 2 * rotation);
clutter_actor_set_opacity (widgets[i], 50 * sin (2 * M_PI * rotation / 360) + (255 - 50));
}
}
@@ -107,25 +98,30 @@ add_clutter_actor (ClutterActor *actor,
y = WINHEIGHT / 2 + RADIUS * sinf (i * 2 * M_PI / (MAX_NWIDGETS)) - h / 2;
clutter_actor_set_position (actor, x, y);
+ clutter_actor_set_pivot_point (actor, 0.5, 0.5);
}
static gboolean
add_or_remove_timeout (gpointer user_data)
{
- if (nwidgets == MAX_NWIDGETS) {
- /* Removing an item */
- clutter_actor_remove_child (group, widgets[MAX_NWIDGETS - 1]);
- widgets[MAX_NWIDGETS - 1] = NULL;
-
- nwidgets--;
- } else {
- /* Adding an item */
- widgets[MAX_NWIDGETS - 1] = create_gtk_actor (MAX_NWIDGETS - 1);
- nwidgets++;
-
- add_clutter_actor (widgets[MAX_NWIDGETS - 1], group, MAX_NWIDGETS - 1);
- }
- return TRUE;
+ if (nwidgets == MAX_NWIDGETS)
+ {
+ /* Removing an item */
+ clutter_actor_remove_child (group, widgets[MAX_NWIDGETS - 1]);
+ widgets[MAX_NWIDGETS - 1] = NULL;
+
+ nwidgets--;
+ }
+ else
+ {
+ /* Adding an item */
+ widgets[MAX_NWIDGETS - 1] = create_gtk_actor (MAX_NWIDGETS - 1);
+ nwidgets++;
+
+ add_clutter_actor (widgets[MAX_NWIDGETS - 1], group, MAX_NWIDGETS - 1);
+ }
+
+ return G_SOURCE_CONTINUE;
}
int
@@ -169,6 +165,7 @@ main (int argc, char *argv[])
/* create a new group to hold multiple actors in a group */
group = clutter_actor_new ();
+ clutter_actor_set_pivot_point (group, 0.5, 0.5);
for (i = 0; i < MAX_NWIDGETS; i++)
{
@@ -180,8 +177,7 @@ main (int argc, char *argv[])
/* Add the group to the stage and center it*/
clutter_actor_add_child (stage, group);
- clutter_actor_add_constraint (group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
- clutter_actor_add_constraint (group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
+ clutter_actor_add_constraint (group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5));
gtk_widget_show_all (window);
diff --git a/examples/gtk-clutter-test.c b/examples/gtk-clutter-test.c
index cb23260..d903c76 100644
--- a/examples/gtk-clutter-test.c
+++ b/examples/gtk-clutter-test.c
@@ -73,20 +73,14 @@ frame_cb (ClutterTimeline *timeline,
guint rotation = clutter_timeline_get_progress (timeline) * 360.0f;
/* Rotate everything clockwise about stage center*/
- clutter_actor_set_rotation (CLUTTER_ACTOR (oh->group),
- CLUTTER_Z_AXIS,
- rotation,
- WINWIDTH / 2, WINHEIGHT / 2, 0);
+ clutter_actor_set_rotation_angle (oh->group, CLUTTER_Z_AXIS, rotation);
for (i = 0; i < NHANDS; i++)
{
/* rotate each hand around there centers */
- clutter_actor_set_rotation (oh->hand[i],
- CLUTTER_Z_AXIS,
- - 6.0 * rotation,
- clutter_actor_get_width (oh->hand[i]) / 2,
- clutter_actor_get_height (oh->hand[i]) / 2,
- 0);
+ clutter_actor_set_rotation_angle (oh->hand[i],
+ CLUTTER_Z_AXIS,
+ - 6.0 * rotation);
if (fade == TRUE)
clutter_actor_set_opacity (oh->hand[i], (255 - (rotation % 255)));
}
@@ -119,14 +113,13 @@ int
main (int argc, char *argv[])
{
ClutterTimeline *timeline;
- ClutterActor *stage;
- ClutterConstraint *constraint;
- GtkWidget *window, *clutter;
- GtkWidget *label, *button, *vbox;
- GdkPixbuf *pixbuf;
- SuperOH *oh;
- gint i;
- GError *error;
+ ClutterActor *stage;
+ GtkWidget *window, *clutter;
+ GtkWidget *label, *button, *vbox;
+ GdkPixbuf *pixbuf;
+ SuperOH *oh;
+ gint i;
+ GError *error;
error = NULL;
if (gtk_clutter_init_with_args (&argc, &argv,
@@ -200,6 +193,7 @@ main (int argc, char *argv[])
oh->stage = stage;
oh->group = clutter_actor_new ();
+ clutter_actor_set_pivot_point (oh->group, 0.5, 0.5);
for (i = 0; i < NHANDS; i++)
{
@@ -222,6 +216,7 @@ main (int argc, char *argv[])
y = WINHEIGHT / 2 + RADIUS * sin (i * M_PI / (NHANDS / 2)) - h / 2;
clutter_actor_set_position (oh->hand[i], x, y);
+ clutter_actor_set_pivot_point (oh->hand[i], 0.5, 0.5);
/* Add to our group group */
clutter_actor_add_child (oh->group, oh->hand[i]);
@@ -230,10 +225,7 @@ main (int argc, char *argv[])
/* Add the group to the stage */
clutter_actor_add_child (stage, oh->group);
- constraint = clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_X_AXIS, 0.5);
- clutter_actor_add_constraint (oh->group, constraint);
- constraint = clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_Y_AXIS, 0.5);
- clutter_actor_add_constraint (oh->group, constraint);
+ clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_BOTH,
0.5));
g_signal_connect (stage, "button-press-event",
G_CALLBACK (input_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]