~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to tests/interactive/test-clutter-cairo-flowers.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
  return ctex;
138
138
}
139
139
 
140
 
gboolean
141
 
tick (gpointer data)
 
140
static void
 
141
tick (ClutterTimeline *timeline,
 
142
      gint             msecs,
 
143
      gpointer         data)
142
144
{
143
145
  Flower **flowers = (Flower**)data;
144
146
  gint i = 0;
145
147
 
146
 
  for (i=0; i< N_FLOWERS; i++)
 
148
  for (i = 0; i < N_FLOWERS; i++)
147
149
    {
 
150
      ClutterActor *stage;
 
151
 
148
152
      flowers[i]->y   += flowers[i]->v;
149
153
      flowers[i]->rot += flowers[i]->rv;
150
154
 
151
 
      if (flowers[i]->y > (gint)clutter_actor_get_height
152
 
                                (clutter_stage_get_default ()))
153
 
            flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex);
 
155
      stage = clutter_stage_get_default ();
 
156
      if (flowers[i]->y > (gint) clutter_actor_get_height (stage))
 
157
        flowers[i]->y = -clutter_actor_get_height (flowers[i]->ctex);
154
158
 
155
159
      clutter_actor_set_position (flowers[i]->ctex,
156
160
                                  flowers[i]->x, flowers[i]->y);
162
166
                                  clutter_actor_get_height (flowers[i]->ctex)/2,
163
167
                                  0);
164
168
    }
165
 
 
166
 
  return TRUE;
167
169
}
168
170
 
169
 
void foo(void) { g_usleep(10000000); }
170
 
 
171
171
int
172
172
test_clutter_cairo_flowers_main (int argc, char **argv)
173
173
{
174
 
  int           i;
175
 
  ClutterActor *stage;
176
 
  ClutterColor  stage_color = { 0x0, 0x0, 0x0, 0xff };
177
 
  Flower       *flowers[N_FLOWERS];
 
174
  int              i;
 
175
  ClutterActor    *stage;
 
176
  ClutterColor     stage_color = { 0x0, 0x0, 0x0, 0xff };
 
177
  ClutterTimeline *timeline;
 
178
  Flower          *flowers[N_FLOWERS];
178
179
 
179
180
  srand (time (NULL));
180
181
 
201
202
                                  flowers[i]->x, flowers[i]->y);
202
203
    }
203
204
 
204
 
  g_timeout_add (50, tick, flowers);
 
205
  /* Create a timeline to manage animation */
 
206
  timeline = clutter_timeline_new (6000);
 
207
  clutter_timeline_set_loop (timeline, TRUE);
 
208
 
 
209
  /* fire a callback for frame change */
 
210
  g_signal_connect (timeline, "new-frame", G_CALLBACK (tick), flowers);
205
211
 
206
212
  clutter_actor_show (stage);
207
213
 
 
214
  clutter_timeline_start (timeline);
 
215
 
208
216
  g_signal_connect (stage, "key-press-event",
209
217
                    G_CALLBACK (clutter_main_quit),
210
218
                    NULL);