~ubuntu-branches/ubuntu/vivid/clutter-1.0/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/interactive/test-actors.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-05-01 23:50:39 UTC
  • mfrom: (4.1.22 experimental)
  • Revision ID: package-import@ubuntu.com-20120501235039-7wehcmtr33nqhv67
Tags: 1.10.4-2
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#undef CLUTTER_DISABLE_DEPRECATED
2
1
#include <clutter/clutter.h>
3
2
 
4
3
#include <math.h>
144
143
    }
145
144
}
146
145
 
 
146
static void
 
147
stop_and_quit (ClutterActor *stage,
 
148
               SuperOH      *data)
 
149
{
 
150
  clutter_timeline_stop (data->timeline);
 
151
 
 
152
  clutter_main_quit ();
 
153
}
 
154
 
147
155
static gdouble
148
156
my_sine_wave (ClutterAlpha *alpha,
149
157
              gpointer      dummy G_GNUC_UNUSED)
158
166
test_actors_main (int argc, char *argv[])
159
167
{
160
168
  ClutterAlpha *alpha;
161
 
  ClutterActor *stage;
162
169
  SuperOH      *oh;
163
170
  gint          i;
164
171
  GError       *error;
180
187
      return EXIT_FAILURE;
181
188
    }
182
189
 
183
 
  stage = clutter_stage_new ();
184
 
  clutter_actor_set_size (stage, 800, 600);
185
 
  clutter_actor_set_name (stage, "Default Stage");
186
 
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
187
 
 
188
 
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Actors");
189
 
  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_LightSkyBlue);
190
 
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
191
 
 
192
190
  oh = g_new (SuperOH, 1);
193
 
  oh->stage = stage;
 
191
 
 
192
  oh->stage = clutter_stage_new ();
 
193
  clutter_actor_set_size (oh->stage, 800, 600);
 
194
  clutter_actor_set_name (oh->stage, "Default Stage");
 
195
  clutter_actor_set_background_color (oh->stage, CLUTTER_COLOR_LightSkyBlue);
 
196
  g_signal_connect (oh->stage, "destroy", G_CALLBACK (stop_and_quit), oh);
 
197
 
 
198
  clutter_stage_set_title (CLUTTER_STAGE (oh->stage), "Actors");
 
199
  clutter_stage_set_user_resizable (CLUTTER_STAGE (oh->stage), TRUE);
194
200
 
195
201
  /* Create a timeline to manage animation */
196
202
  oh->timeline = clutter_timeline_new (6000);
197
 
  clutter_timeline_set_loop (oh->timeline, TRUE);
 
203
  clutter_timeline_set_repeat_count (oh->timeline, -1);
198
204
 
199
205
  /* fire a callback for frame change */
200
206
  g_signal_connect (oh->timeline, "new-frame", G_CALLBACK (frame_cb), oh);
212
218
 
213
219
  g_free (file);
214
220
 
215
 
  /* create a new group to hold multiple actors in a group */
216
 
  oh->group = clutter_group_new();
 
221
  /* create a new actor to hold other actors */
 
222
  oh->group = clutter_actor_new ();
 
223
  clutter_actor_set_layout_manager (oh->group, clutter_fixed_layout_new ());
217
224
  clutter_actor_set_name (oh->group, "Group");
218
225
  g_signal_connect (oh->group, "destroy", G_CALLBACK (on_group_destroy), oh);
219
 
  clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
220
 
  clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
221
 
  clutter_actor_add_constraint (oh->group, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0f));
 
226
  clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_BOTH, 0.5));
 
227
  clutter_actor_add_constraint (oh->group, clutter_bind_constraint_new (oh->stage, CLUTTER_BIND_SIZE, 0.0f));
222
228
 
223
229
  oh->hand = g_new (ClutterActor*, n_hands);
224
230
 
225
 
  oh->stage_width = clutter_actor_get_width (stage);
226
 
  oh->stage_height = clutter_actor_get_height (stage);
 
231
  oh->stage_width = clutter_actor_get_width (oh->stage);
 
232
  oh->stage_height = clutter_actor_get_height (oh->stage);
227
233
  oh->radius = (oh->stage_width + oh->stage_height)
228
234
             / n_hands;
229
235
 
283
289
    }
284
290
 
285
291
  /* Add the group to the stage */
286
 
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), oh->group);
 
292
  clutter_container_add_actor (CLUTTER_CONTAINER (oh->stage), oh->group);
287
293
 
288
294
  /* Show everying */
289
 
  clutter_actor_show (stage);
 
295
  clutter_actor_show (oh->stage);
290
296
 
291
 
  g_signal_connect (stage, "key-release-event",
 
297
  g_signal_connect (oh->stage, "key-release-event",
292
298
                    G_CALLBACK (input_cb),
293
299
                    oh);
294
300