[libchamplain] Update to Clutter 0.9 latests API changes



commit 207371e2a1ff9a4c6faed6e693cc7c2d9098824a
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date:   Fri Jun 12 09:32:11 2009 -0400

    Update to Clutter 0.9 latests API changes
    
    This commit used to break (but was later fixed) the kinetic scrolling)
    due to heavy changes in ClutterTimeline.

 champlain/champlain-view.c |   14 +++---
 demos/animated-marker.c    |    2 +-
 demos/launcher.c           |    4 +-
 demos/polygons.c           |    4 +-
 tidy/tidy-adjustment.c     |  106 +-------------------------------------------
 tidy/tidy-finger-scroll.c  |   15 +++---
 tidy/tidy-scroll-view.c    |   40 +++++++---------
 tidy/tidy-viewport.c       |   12 +++---
 8 files changed, 45 insertions(+), 152 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index b1dcd07..64258e5 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -349,7 +349,7 @@ static void
 license_set_position (ChamplainView *view)
 {
   ChamplainViewPrivate *priv = view->priv;
-  guint width, height;
+  gfloat width, height;
 
   if (!priv->license_actor)
     return;
@@ -1264,7 +1264,7 @@ champlain_view_go_to (ChamplainView *view,
    * is higher and if the points are far away
    */
   duration = 500 * priv->zoom_level / 2.0;
-  ctx->timeline = clutter_timeline_new_for_duration (duration);
+  ctx->timeline = clutter_timeline_new (duration);
   ctx->alpha = clutter_alpha_new_full (ctx->timeline, CLUTTER_EASE_IN_OUT_CIRC);
 
   g_signal_connect (ctx->timeline, "new-frame", G_CALLBACK (timeline_new_frame),
@@ -1529,8 +1529,8 @@ gboolean champlain_view_get_coords_at (ChamplainView *view,
 {
   g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), FALSE);
   ChamplainViewPrivate *priv = view->priv;
-  gint actor_x, actor_y;
-  gint rel_x, rel_y;
+  gfloat actor_x, actor_y;
+  gdouble rel_x, rel_y;
 
   clutter_actor_get_transformed_position (priv->finger_scroll, &actor_x, &actor_y);
 
@@ -2008,9 +2008,9 @@ view_set_zoom_level_at (ChamplainView *view,
   ClutterActor *group, *new_group;
   gdouble lon, lat;
   gint x_diff, y_diff;
-  gint actor_x, actor_y;
-  gint rel_x, rel_y;
-  gint x2, y2;
+  gfloat actor_x, actor_y;
+  gdouble rel_x, rel_y;
+  gfloat x2, y2;
   gdouble lat2, lon2;
 
   if (zoom_level == priv->zoom_level || ZOOM_LEVEL_OUT_OF_RANGE(priv, zoom_level))
diff --git a/demos/animated-marker.c b/demos/animated-marker.c
index abe5f4b..0ebddd4 100644
--- a/demos/animated-marker.c
+++ b/demos/animated-marker.c
@@ -80,7 +80,7 @@ create_marker ()
   clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);
 
   /* Animate the echo circle */
-  timeline = clutter_timeline_new_for_duration (1000);
+  timeline = clutter_timeline_new (1000);
   clutter_timeline_set_loop (timeline, TRUE);
   alpha = clutter_alpha_new_full (timeline, CLUTTER_EASE_OUT_SINE);
 
diff --git a/demos/launcher.c b/demos/launcher.c
index a221eca..51a5e31 100644
--- a/demos/launcher.c
+++ b/demos/launcher.c
@@ -62,7 +62,7 @@ make_button (char *text)
   ClutterActor *button, *button_bg, *button_text;
   ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
   ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
-  guint width, height;
+  gfloat width, height;
 
   button = clutter_group_new ();
 
@@ -87,7 +87,7 @@ main (int argc,
 {
   ClutterActor* actor, *stage, *buttons, *button;
   ChamplainLayer *layer;
-  guint width, total_width = 0;;
+  gfloat width, total_width = 0;;
 
   g_thread_init (NULL);
   clutter_init (&argc, &argv);
diff --git a/demos/polygons.c b/demos/polygons.c
index c58392f..6184b60 100644
--- a/demos/polygons.c
+++ b/demos/polygons.c
@@ -44,7 +44,7 @@ make_button (char *text)
   ClutterActor *button, *button_bg, *button_text;
   ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
   ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
-  guint width, height;
+  gfloat width, height;
 
   button = clutter_group_new ();
 
@@ -69,7 +69,7 @@ main (int argc,
 {
   ClutterActor* actor, *stage, *buttons, *button;
   ChamplainPolygon *polygon;
-  guint width, total_width = 0;;
+  gfloat width, total_width = 0;;
 
   g_thread_init (NULL);
   clutter_init (&argc, &argv);
diff --git a/tidy/tidy-adjustment.c b/tidy/tidy-adjustment.c
index 6eab990..cd0417e 100644
--- a/tidy/tidy-adjustment.c
+++ b/tidy/tidy-adjustment.c
@@ -472,110 +472,6 @@ tidy_adjustment_set_page_size (TidyAdjustment *adjustment,
 }
 
 void
-tidy_adjustment_set_valuesx (TidyAdjustment *adjustment,
-                             gdouble    value,
-                             gdouble    lower,
-                             gdouble    upper,
-                             gdouble    step_increment,
-                             gdouble    page_increment,
-                             gdouble    page_size)
-{
-  TidyAdjustmentPrivate *priv;
-  gboolean emit_changed = FALSE;
-
-  g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
-  priv = adjustment->priv;
-
-  stop_interpolation (adjustment);
-
-  emit_changed = FALSE;
-
-  g_object_freeze_notify (G_OBJECT (adjustment));
-
-  if (priv->lower != lower)
-    {
-      priv->lower = lower;
-      emit_changed = TRUE;
-
-      g_object_notify (G_OBJECT (adjustment), "lower");
-    }
-
-  if (priv->upper != upper)
-    {
-      priv->upper = upper;
-      emit_changed = TRUE;
-
-      g_object_notify (G_OBJECT (adjustment), "upper");
-    }
-
-  if (priv->step_increment != step_increment)
-    {
-      priv->step_increment = step_increment;
-      emit_changed = TRUE;
-
-      g_object_notify (G_OBJECT (adjustment), "step-increment");
-    }
-
-  if (priv->page_increment != page_increment)
-    {
-      priv->page_increment = page_increment;
-      emit_changed = TRUE;
-
-      g_object_notify (G_OBJECT (adjustment), "page-increment");
-    }
-
-  if (priv->page_size != page_size)
-    {
-      priv->page_size = page_size;
-      emit_changed = TRUE;
-
-      g_object_notify (G_OBJECT (adjustment), "page-size");
-    }
-
-  tidy_adjustment_set_value (adjustment, value);
-
-  if (emit_changed)
-    g_signal_emit (G_OBJECT (adjustment), signals[CHANGED], 0);
-
-  g_object_thaw_notify (G_OBJECT (adjustment));
-}
-
-void
-tidy_adjustment_get_valuesx (TidyAdjustment *adjustment,
-                             gdouble   *value,
-                             gdouble   *lower,
-                             gdouble   *upper,
-                             gdouble   *step_increment,
-                             gdouble   *page_increment,
-                             gdouble   *page_size)
-{
-  TidyAdjustmentPrivate *priv;
-
-  g_return_if_fail (TIDY_IS_ADJUSTMENT (adjustment));
-
-  priv = adjustment->priv;
-
-  if (lower)
-    *lower = priv->lower;
-
-  if (upper)
-    *upper = priv->upper;
-
-  if (value)
-    *value = tidy_adjustment_get_value (adjustment);
-
-  if (step_increment)
-    *step_increment = priv->step_increment;
-
-  if (page_increment)
-    *page_increment = priv->page_increment;
-
-  if (page_size)
-    *page_size = priv->page_size;
-}
-
-void
 tidy_adjustment_get_values (TidyAdjustment *adjustment,
                             gdouble        *value,
                             gdouble        *lower,
@@ -685,7 +581,7 @@ tidy_adjustment_interpolate (TidyAdjustment *adjustment,
   priv->new_position = value;
 
   priv->dx = (priv->new_position - priv->old_position) * n_frames;
-  priv->interpolation = clutter_timeline_new (n_frames, fps);
+  priv->interpolation = clutter_timeline_new (((float)n_frames / fps) * 1000);
 
   if (priv->elastic)
     priv->bounce_alpha = clutter_alpha_new_full (priv->interpolation,
diff --git a/tidy/tidy-finger-scroll.c b/tidy/tidy-finger-scroll.c
index ff5d9f4..e92843a 100644
--- a/tidy/tidy-finger-scroll.c
+++ b/tidy/tidy-finger-scroll.c
@@ -315,7 +315,7 @@ deceleration_new_frame_cb (ClutterTimeline *timeline,
                                        &hadjust,
                                        &vadjust);
 
-      for (i = 0; i < clutter_timeline_get_delta (timeline, NULL); i++)
+      for (i = 0; i < clutter_timeline_get_delta (timeline) / 15; i++)
         {
           tidy_adjustment_set_value (hadjust,
                                       priv->dx +
@@ -328,7 +328,7 @@ deceleration_new_frame_cb (ClutterTimeline *timeline,
         }
 
       /* Check if we've hit the upper or lower bounds and stop the timeline */
-      tidy_adjustment_get_valuesx (hadjust, &value, &lower, &upper,
+      tidy_adjustment_get_values (hadjust, &value, &lower, &upper,
                                    NULL, NULL, &page_size);
       if (((priv->dx > 0) && (value < upper - page_size)) ||
           ((priv->dx < 0) && (value > lower)))
@@ -336,7 +336,7 @@ deceleration_new_frame_cb (ClutterTimeline *timeline,
 
       if (stop)
         {
-          tidy_adjustment_get_valuesx (vadjust, &value, &lower, &upper,
+          tidy_adjustment_get_values (vadjust, &value, &lower, &upper,
                                        NULL, NULL, &page_size);
           if (((priv->dy > 0) && (value < upper - page_size)) ||
               ((priv->dy < 0) && (value > lower)))
@@ -404,13 +404,14 @@ button_release_event_cb (ClutterActor *actor,
                *        either fix that, or calculate the correct maximum
                *        value for the buffer size
                */
+
               x_origin += motion->x;
               y_origin += motion->y;
               motion_time.tv_sec += motion->time.tv_sec;
               motion_time.tv_usec += motion->time.tv_usec;
             }
-          x_origin = x_origin / priv->last_motion;
-          y_origin = y_origin / priv->last_motion;
+          x_origin /= priv->last_motion;
+          y_origin /= priv->last_motion;
           motion_time.tv_sec /= priv->last_motion;
           motion_time.tv_usec /= priv->last_motion;
 
@@ -499,7 +500,7 @@ button_release_event_cb (ClutterActor *actor,
                         step_increment) + lower) - value;
                   priv->dy = (d / a);
                   
-                  priv->deceleration_timeline = clutter_timeline_new ((gint)n, 60);
+                  priv->deceleration_timeline = clutter_timeline_new ((n / 60) * 1000.0);
                 }
               else
                 {
@@ -523,7 +524,7 @@ button_release_event_cb (ClutterActor *actor,
                         step_increment) + lower) - value;
                   priv->dy = (d / a);
                   
-                  priv->deceleration_timeline = clutter_timeline_new (4, 60);
+                  priv->deceleration_timeline = clutter_timeline_new (250);
                 }
 
               g_signal_connect (priv->deceleration_timeline, "new_frame",
diff --git a/tidy/tidy-scroll-view.c b/tidy/tidy-scroll-view.c
index daa683f..2714a3d 100644
--- a/tidy/tidy-scroll-view.c
+++ b/tidy/tidy-scroll-view.c
@@ -110,9 +110,9 @@ tidy_scroll_view_pick (ClutterActor *actor, const ClutterColor *color)
 
 static void
 tidy_scroll_view_get_preferred_width (ClutterActor *actor,
-                                      ClutterUnit   for_height,
-                                      ClutterUnit  *min_width_p,
-                                      ClutterUnit  *natural_width_p)
+                                      gfloat   for_height,
+                                      gfloat  *min_width_p,
+                                      gfloat  *natural_width_p)
 {
 
   TidyScrollViewPrivate *priv = TIDY_SCROLL_VIEW (actor)->priv;
@@ -131,9 +131,9 @@ tidy_scroll_view_get_preferred_width (ClutterActor *actor,
 
 static void
 tidy_scroll_view_get_preferred_height (ClutterActor *actor,
-                                       ClutterUnit   for_width,
-                                       ClutterUnit  *min_height_p,
-                                       ClutterUnit  *natural_height_p)
+                                       gfloat   for_width,
+                                       gfloat  *min_height_p,
+                                       gfloat  *natural_height_p)
 {
 
   TidyScrollViewPrivate *priv = TIDY_SCROLL_VIEW (actor)->priv;
@@ -152,36 +152,32 @@ tidy_scroll_view_get_preferred_height (ClutterActor *actor,
 static void
 tidy_scroll_view_allocate (ClutterActor          *actor,
                            const ClutterActorBox *box,
-                           gboolean               absolute_origin_changed)
+                           ClutterAllocationFlags flags)
 {
   ClutterActorBox child_box;
-  
+
   TidyScrollViewPrivate *priv = TIDY_SCROLL_VIEW (actor)->priv;
-  
+
   /* Chain up */
   CLUTTER_ACTOR_CLASS (tidy_scroll_view_parent_class)->
-    allocate (actor, box, absolute_origin_changed);
-  
-  
+    allocate (actor, box, flags);
 
-  
   /* Child */
   child_box.x1 = 0;
   child_box.x2 = box->x2 - box->x1;
   child_box.y1 = 0;
   child_box.y2 = box->y2 - box->y1;
-  
-  
+
   if (priv->child)
     {
-      clutter_actor_allocate (priv->child, &child_box, absolute_origin_changed);
-      clutter_actor_set_clipu (priv->child,
-                               child_box.x1,
-                               child_box.y1,
-                               child_box.x2 - child_box.x1,
-                               child_box.y2 - child_box.y1);
+      clutter_actor_allocate (priv->child, &child_box, flags);
+      clutter_actor_set_clip (priv->child,
+                              child_box.x1,
+                              child_box.y1,
+                              child_box.x2 - child_box.x1,
+                              child_box.y2 - child_box.y1);
     }
-  
+
 }
 
 static void
diff --git a/tidy/tidy-viewport.c b/tidy/tidy-viewport.c
index 4756f6c..d30d1c5 100644
--- a/tidy/tidy-viewport.c
+++ b/tidy/tidy-viewport.c
@@ -51,9 +51,9 @@ G_DEFINE_TYPE_WITH_CODE (TidyViewport, tidy_viewport, CLUTTER_TYPE_GROUP,
 
 struct _TidyViewportPrivate
 {
-  ClutterUnit x;
-  ClutterUnit y;
-  ClutterUnit z;
+  gfloat x;
+  gfloat y;
+  gfloat z;
 
   TidyAdjustment *hadjustment;
   TidyAdjustment *vadjustment;
@@ -228,7 +228,7 @@ tidy_viewport_pick (ClutterActor       *self,
 static void
 tidy_viewport_allocate (ClutterActor          *self,
                         const ClutterActorBox *box,
-                        gboolean               absolute_origin_changed)
+                        ClutterAllocationFlags flags)
 {
   CoglFixed prev_value;
 
@@ -236,7 +236,7 @@ tidy_viewport_allocate (ClutterActor          *self,
 
   /* Chain up */
   CLUTTER_ACTOR_CLASS (tidy_viewport_parent_class)->
-    allocate (self, box, absolute_origin_changed);
+    allocate (self, box, flags);
 
   /* Refresh adjustments */
   if (priv->sync_adjustments)
@@ -487,7 +487,7 @@ clip_notify_cb (ClutterActor *actor,
                 GParamSpec   *pspec,
                 TidyViewport *self)
 {
-  gint width, height;
+  gfloat width, height;
   TidyViewportPrivate *priv = self->priv;
 
   if (!priv->sync_adjustments)



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