[clutter-tutorial] Fixed the build with latest clutter API.



commit 5606a0e800507c5b9fe70d9b86bec53069689f0e
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jun 25 16:49:14 2009 +0200

    Fixed the build with latest clutter API.
    
    * examples/actor_events/main.c (on_stage_button_press),
    (on_rect_button_press), (on_rect_button_release):
    * examples/animation/main.c (on_alpha), (main):
    * examples/behaviour/main.c (on_alpha), (main):
    * examples/custom_container/examplebox.c
    (example_box_get_preferred_width),
    (example_box_get_preferred_height), (example_box_allocate):
    * examples/full_example/main.c (on_timeline_rotation_completed),
    (rotate_all_until_item_is_at_front), (main):
    * examples/score/main.c (main):
    * examples/scrolling/scrollingcontainer.c
    (example_scrolling_container_allocate):
    * examples/scrolling/scrollingcontainer.h:
    * examples/stage/main.c (on_stage_button_press):
    * examples/text/main.c (main):
    * examples/timeline/main.c (main): Fix the build with the latest clutter API,
    mostly:
    - Providing a milliseconds duration to clutter_timeline_new() instead of
    frame and frames_per_second, plus changing associated functions to be
    duration-wise rather than frames-wise.
    - Use float instead of gint.

 ChangeLog                               |   28 +++++++++++++++++++++++++++-
 examples/actor_events/main.c            |   20 ++++++++++----------
 examples/animation/main.c               |    9 ++-------
 examples/behaviour/main.c               |    8 ++------
 examples/custom_container/examplebox.c  |   31 ++++++++++++++++---------------
 examples/full_example/main.c            |    6 +++---
 examples/score/main.c                   |    4 ++--
 examples/scrolling/scrollingcontainer.c |   18 +++++++++---------
 examples/scrolling/scrollingcontainer.h |    2 +-
 examples/stage/main.c                   |    6 +++---
 examples/text/main.c                    |    4 ++--
 examples/timeline/main.c                |    4 ++--
 12 files changed, 79 insertions(+), 61 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a6a6173..e469368 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,34 @@
+2009-06-25  Murray Cumming  <murrayc murrayc com>
+
+	Fixed the build with latest clutter API.
+	
+	* examples/actor_events/main.c (on_stage_button_press),
+	(on_rect_button_press), (on_rect_button_release):
+	* examples/animation/main.c (on_alpha), (main):
+	* examples/behaviour/main.c (on_alpha), (main):
+	* examples/custom_container/examplebox.c
+	(example_box_get_preferred_width),
+	(example_box_get_preferred_height), (example_box_allocate):
+	* examples/full_example/main.c (on_timeline_rotation_completed),
+	(rotate_all_until_item_is_at_front), (main):
+	* examples/score/main.c (main):
+	* examples/scrolling/scrollingcontainer.c
+	(example_scrolling_container_allocate):
+	* examples/scrolling/scrollingcontainer.h:
+	* examples/stage/main.c (on_stage_button_press):
+	* examples/text/main.c (main):
+	* examples/timeline/main.c (main): Fix the build with the latest clutter API, 
+	mostly:
+	- Providing a milliseconds duration to clutter_timeline_new() instead of 
+	frame and frames_per_second, plus changing associated functions to be 
+	duration-wise rather than frames-wise.
+	- Use float instead of gint.
+
 2009-05-06  Johannes Schmid <jschmid openismus com>
 
 	* docs/tutorial/figures/gtk_scrolling.png:
 	* docs/tutorial/figures/text.png:
-	Make screenshot window fucussed to match with other screenshots
+	Make screenshot window focussed to match with other screenshots
 
 2009-05-05  Murray Cumming  <murrayc murrayc com>
 
diff --git a/examples/actor_events/main.c b/examples/actor_events/main.c
index bcbab55..d6b0f23 100644
--- a/examples/actor_events/main.c
+++ b/examples/actor_events/main.c
@@ -20,16 +20,16 @@
 static gboolean
 on_stage_button_press (ClutterStage *stage, ClutterEvent *event, gpointer data)
 {
-  gint x = 0;
-  gint y = 0;
+  gfloat x = 0;
+  gfloat y = 0;
   clutter_event_get_coords (event, &x, &y);
 
-  g_print ("Clicked stage at (%d, %d)\n", x, y);
+  g_print ("Clicked stage at (%f, %f)\n", x, y);
 
   /* Discover whether there is an actor at that position.
    * Note that you can also connect directly to the actor's signals instead.
    */
-  ClutterActor *rect = clutter_stage_get_actor_at_pos (stage, x, y);
+  ClutterActor *rect = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y);
   if (!rect)
     return FALSE;
 
@@ -42,11 +42,11 @@ on_stage_button_press (ClutterStage *stage, ClutterEvent *event, gpointer data)
 static gboolean
 on_rect_button_press (ClutterRectangle *rect, ClutterEvent *event, gpointer data)
 {
-  gint x = 0;
-  gint y = 0;
+  gfloat x = 0;
+  gfloat y = 0;
   clutter_event_get_coords (event, &x, &y);
 
-  g_print ("Clicked rectangle at (%d, %d)\n", x, y);
+  g_print ("Clicked rectangle at (%f, %f)\n", x, y);
 
   /* clutter_main_quit(); */
 
@@ -56,11 +56,11 @@ on_rect_button_press (ClutterRectangle *rect, ClutterEvent *event, gpointer data
 static gboolean
 on_rect_button_release (ClutterRectangle *rect, ClutterEvent *event, gpointer data)
 {
-  gint x = 0;
-  gint y = 0;
+  gfloat x = 0;
+  gfloat y = 0;
   clutter_event_get_coords (event, &x, &y);
 
-  g_print ("Click-release on rectangle at (%d, %d)\n", x, y);
+  g_print ("Click-release on rectangle at (%f, %f)\n", x, y);
 
   return TRUE; /* Stop further handling of this event. */
 }
diff --git a/examples/animation/main.c b/examples/animation/main.c
index a4f7fb2..953b8c7 100644
--- a/examples/animation/main.c
+++ b/examples/animation/main.c
@@ -31,11 +31,7 @@ on_alpha (ClutterAlpha *alpha, gpointer data)
    *  so we can base our value upon it:
    */
   ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
-  const int current_frame_num = clutter_timeline_get_current_frame (timeline);
-  const int n_frames = clutter_timeline_get_n_frames (timeline);
-
-  /* Return a value that is simply proportional to the frame position: */
-  return (current_frame_num / n_frames);
+  return clutter_timeline_get_progress (timeline);
 }
 
 
@@ -61,8 +57,7 @@ int main(int argc, char *argv[])
   /* Show the stage: */
   clutter_actor_show (stage);
 
-  ClutterTimeline *timeline = 
-    clutter_timeline_new(100 /* frames */, 30 /* frames per second. */);
+  ClutterTimeline *timeline =  clutter_timeline_new(5000 /* milliseconds */);
   clutter_timeline_set_loop(timeline, TRUE); 
   clutter_timeline_start(timeline);
 
diff --git a/examples/behaviour/main.c b/examples/behaviour/main.c
index 0cac19f..6b770d8 100644
--- a/examples/behaviour/main.c
+++ b/examples/behaviour/main.c
@@ -30,11 +30,7 @@ on_alpha (ClutterAlpha *alpha, gpointer data)
    *  so we can base our value upon it:
    */
   ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
-  const int current_frame_num = clutter_timeline_get_current_frame (timeline);
-  const int n_frames = clutter_timeline_get_n_frames (timeline);
-
-  /* Return a value that is simply proportional to the frame position: */
-  return (current_frame_num / n_frames);
+  return clutter_timeline_get_progress (timeline);
 }
 
 
@@ -60,7 +56,7 @@ int main(int argc, char *argv[])
   /* Show the stage: */
   clutter_actor_show (stage);
 
-  ClutterTimeline *timeline = clutter_timeline_new(10 /* frames */, 30 /* frames per second. */);
+  ClutterTimeline *timeline = clutter_timeline_new(5000 /* milliseconds */);
   clutter_timeline_set_loop(timeline, TRUE); 
   clutter_timeline_start(timeline);
 
diff --git a/examples/custom_container/examplebox.c b/examples/custom_container/examplebox.c
index b645f95..f228b51 100644
--- a/examples/custom_container/examplebox.c
+++ b/examples/custom_container/examplebox.c
@@ -187,13 +187,13 @@ example_box_pick (ClutterActor *actor,
 /* An implementation for the ClutterActor::get_preferred_width() vfunc: */
 static void
 example_box_get_preferred_width (ClutterActor *actor,
-                                 ClutterUnit   for_height,
-                                 ClutterUnit  *min_width_p,
-                                 ClutterUnit  *natural_width_p)
+                                 float for_height,
+                                 float *min_width_p,
+                                 float *natural_width_p)
 {
   ExampleBox *box = EXAMPLE_BOX (actor);
   GList *l;
-  ClutterUnit min_width = 0, natural_width = 0;
+  float min_width = 0, natural_width = 0;
 
   /* For this container, the preferred width is the sum of the widths
    * of the children. The preferred width depends on the height provided
@@ -208,8 +208,8 @@ example_box_get_preferred_width (ClutterActor *actor,
       
       if (CLUTTER_ACTOR_IS_VISIBLE (child))
         {
-          ClutterUnit child_min_width, child_natural_width;
-
+          float child_min_width = 0;
+          float child_natural_width = 0;
           clutter_actor_get_preferred_width (child, for_height, &child_min_width, &child_natural_width);
 
           min_width += child_min_width;
@@ -227,13 +227,13 @@ example_box_get_preferred_width (ClutterActor *actor,
 /* An implementation for the ClutterActor::get_preferred_height() vfunc: */
 static void
 example_box_get_preferred_height (ClutterActor *actor,
-                                  ClutterUnit   for_width,
-                                  ClutterUnit  *min_height_p,
-                                  ClutterUnit  *natural_height_p)
+                                  float for_width,
+                                  float *min_height_p,
+                                  float *natural_height_p)
 {
   ExampleBox *box = EXAMPLE_BOX (actor);
   GList *l;
-  ClutterUnit min_height = 0, natural_height = 0;
+  float min_height = 0, natural_height = 0;
 
   /* For this container, the preferred height is the maximum height
    * of the children. The preferred height is independent of the given width.
@@ -247,8 +247,8 @@ example_box_get_preferred_height (ClutterActor *actor,
       
       if (CLUTTER_ACTOR_IS_VISIBLE (child))
         {
-          ClutterUnit child_min_height, child_natural_height;
-
+          float child_min_height = 0;
+          float child_natural_height = 0;
           clutter_actor_get_preferred_height (child, -1, &child_min_height, &child_natural_height);
 
           min_height = MAX (min_height, child_min_height);
@@ -267,19 +267,20 @@ example_box_get_preferred_height (ClutterActor *actor,
 static void
 example_box_allocate (ClutterActor          *actor,
                       const ClutterActorBox *box,
-		      gboolean               absolute_origin_changed)
+		                  ClutterAllocationFlags absolute_origin_changed)
 {
   ExampleBox *ebox = EXAMPLE_BOX (actor);
 
   /* Look at each child actor: */
-  ClutterUnit child_x = 0;
+  float child_x = 0;
   GList *l = NULL;
   for (l = ebox->children; l; l = l->next)
     {
       ClutterActor *child = l->data;
 
       /* Discover what size the child wants: */
-      ClutterUnit child_width, child_height;
+      float child_width = 0;
+      float child_height = 0;
       clutter_actor_get_preferred_size (child, NULL, NULL, &child_width, &child_height);
 
       /* Calculate the position and size that the child may actually have: */
diff --git a/examples/full_example/main.c b/examples/full_example/main.c
index e992f55..a0ca0ca 100644
--- a/examples/full_example/main.c
+++ b/examples/full_example/main.c
@@ -210,7 +210,7 @@ void on_timeline_rotation_completed(ClutterTimeline* timeline, gpointer user_dat
    */
   /* Transform the image: */
   ClutterActor *actor = item_at_front->actor;
-  timeline_moveup = clutter_timeline_new(60 /* frames */, 30 /* fps */);
+  timeline_moveup = clutter_timeline_new(1000 /* milliseconds */);
   ClutterAlpha *alpha =
     clutter_alpha_new_full (timeline_moveup, CLUTTER_EASE_OUT_SINE);
  
@@ -338,7 +338,7 @@ void rotate_all_until_item_is_at_front(Item *item)
      pos_to_move = pos_front - pos;
   }
 
-  clutter_timeline_set_n_frames (timeline_rotation, angle_diff);
+  clutter_timeline_set_duration (timeline_rotation, angle_diff * 0.2);
 
   /* Remember what item will be at the front when this timeline finishes: */
   item_at_front = item;
@@ -404,7 +404,7 @@ int main(int argc, char *argv[])
   /* Show the stage: */
   clutter_actor_show (stage);
 
-  timeline_rotation = clutter_timeline_new(60 /* frames */, 30 /* frames per second. */);
+  timeline_rotation = clutter_timeline_new(2000 /* milliseconds */);
   g_signal_connect (timeline_rotation, "completed", G_CALLBACK (on_timeline_rotation_completed), NULL);
 
   /* Add an actor for each image: */
diff --git a/examples/score/main.c b/examples/score/main.c
index 54f71c5..61d06ed 100644
--- a/examples/score/main.c
+++ b/examples/score/main.c
@@ -96,11 +96,11 @@ int main(int argc, char *argv[])
   ClutterScore *score = clutter_score_new ();
   clutter_score_set_loop (score, TRUE);
 
-  ClutterTimeline *timeline_rotation = clutter_timeline_new (200 /* frames */, 120 /* frames per second. */);
+  ClutterTimeline *timeline_rotation = clutter_timeline_new (5000 /* milliseconds */);
   g_signal_connect (timeline_rotation, "new-frame", G_CALLBACK (on_timeline_rotation_new_frame), NULL);
   clutter_score_append (score, NULL, timeline_rotation);
 
-  ClutterTimeline *timeline_move = clutter_timeline_new (200 /* frames */, 120 /* frames per second. */);
+  ClutterTimeline *timeline_move = clutter_timeline_new (5000 /* milliseconds */);
   g_signal_connect (timeline_move, "new-frame", G_CALLBACK (on_timeline_move_new_frame), NULL);
   clutter_score_append (score,  timeline_rotation, timeline_move);
 
diff --git a/examples/scrolling/scrollingcontainer.c b/examples/scrolling/scrollingcontainer.c
index 24f2a70..dc28e18 100644
--- a/examples/scrolling/scrollingcontainer.c
+++ b/examples/scrolling/scrollingcontainer.c
@@ -156,13 +156,13 @@ example_scrolling_container_pick (ClutterActor *actor,
 static void
 example_scrolling_container_allocate (ClutterActor          *actor,
                                       const ClutterActorBox *box,
-                                      gboolean               absolute_origin_changed)
+                                      ClutterAllocationFlags absolute_origin_changed)
 {
   ExampleScrollingContainer *self = EXAMPLE_SCROLLING_CONTAINER (actor);
 
   /* Make sure that the children adapt their positions: */
-  ClutterUnit width = box->x2 - box->x1;
-  ClutterUnit height = box->y2 - box->y1;
+  float width = box->x2 - box->x1;
+  float height = box->y2 - box->y1;
 
   if (width < 0)
     width = 0;
@@ -182,30 +182,30 @@ example_scrolling_container_allocate (ClutterActor          *actor,
   clutter_actor_allocate (self->group, &child_box, absolute_origin_changed);
 
   /* Make sure that the group only shows the specified area, by clipping: */
-  clutter_actor_set_clip (self->group, 0, 0, CLUTTER_UNITS_TO_DEVICE(width), CLUTTER_UNITS_TO_DEVICE(height));
+  clutter_actor_set_clip (self->group, 0, 0, width, height);
 
   /* Show a rectangle border to show the area: */
   clutter_actor_allocate (self->rect, &child_box, absolute_origin_changed);
   clutter_actor_lower (self->rect, NULL);
 
   /* Look at each child actor: */
-  gint child_x = -(self->offset);
+  float child_x = -(self->offset);
   GList *l = NULL;
   for (l = self->children; l; l = l->next)
     {
       ClutterActor *child = l->data;
-      ClutterUnit width, height;
-
+      float width = 0;
+      float height = 0;
       clutter_actor_get_preferred_size (child, NULL, NULL, &width, &height);
 
-      child_box.x1 = CLUTTER_UNITS_FROM_DEVICE (child_x);
+      child_box.x1 = child_x;
       child_box.y1 = 0;
       child_box.x2 = child_box.x1 + width;
       child_box.y2 = child_box.y1 + height;
 
       clutter_actor_allocate (child, &child_box, absolute_origin_changed);
 
-      child_x += CLUTTER_UNITS_TO_DEVICE (width);
+      child_x += width;
    }
 
   CLUTTER_ACTOR_CLASS (example_scrolling_container_parent_class)->allocate (actor, box, absolute_origin_changed);
diff --git a/examples/scrolling/scrollingcontainer.h b/examples/scrolling/scrollingcontainer.h
index 28f128d..ffbf135 100644
--- a/examples/scrolling/scrollingcontainer.h
+++ b/examples/scrolling/scrollingcontainer.h
@@ -44,7 +44,7 @@ struct _ExampleScrollingContainer
   
   /* All the child actors are in this group: */
   ClutterActor *group;
-  gint offset;
+  float offset;
 
   /* A rectange to show the bounds: */
   ClutterActor *rect;
diff --git a/examples/stage/main.c b/examples/stage/main.c
index 6168c84..f37a764 100644
--- a/examples/stage/main.c
+++ b/examples/stage/main.c
@@ -20,11 +20,11 @@
 static gboolean
 on_stage_button_press (ClutterStage *stage, ClutterEvent *event, gpointer data)
 {
-  gint x = 0;
-  gint y = 0;
+  float x = 0;
+  float y = 0;
   clutter_event_get_coords (event, &x, &y);
 
-  g_print ("Stage clicked at (%d, %d)\n", x, y);
+  g_print ("Stage clicked at (%f, %f)\n", x, y);
 
   return TRUE; /* Stop further handling of this event. */
 }
diff --git a/examples/text/main.c b/examples/text/main.c
index 43e67b6..c0ea899 100644
--- a/examples/text/main.c
+++ b/examples/text/main.c
@@ -42,8 +42,8 @@ int main(int argc, char *argv[])
   clutter_text_set_line_wrap (CLUTTER_TEXT (text), FALSE);
   
   /* Discover the preferred height and use that height: */
-  ClutterUnit min_height = 0;
-  ClutterUnit natural_height = 0;
+  float min_height = 0;
+  float natural_height = 0;
   clutter_actor_get_preferred_height (text, 750, &min_height,
     &natural_height);
   clutter_actor_set_size (text, 750, natural_height);
diff --git a/examples/timeline/main.c b/examples/timeline/main.c
index dc93b5c..2b8b330 100644
--- a/examples/timeline/main.c
+++ b/examples/timeline/main.c
@@ -85,8 +85,8 @@ int main(int argc, char *argv[])
   /* Show the stage: */
   clutter_actor_show (stage);
 
-  ClutterTimeline *timeline = clutter_timeline_new(10 /* frames */, 120 /* frames per second. */);
-  clutter_timeline_add_marker_at_frame (timeline, "clutter-tutorial", 5);
+  ClutterTimeline *timeline = clutter_timeline_new(5000 /* milliseconds */);
+  clutter_timeline_add_marker_at_time (timeline, "clutter-tutorial", 2000 /* milliseconds */);
   g_signal_connect (timeline, "new-frame", G_CALLBACK (on_timeline_new_frame), NULL);
   g_signal_connect (timeline, "marker-reached", G_CALLBACK (on_timeline_marker_reached), NULL);
   clutter_timeline_set_loop(timeline, TRUE); 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]