]> err.no Git - libchamplain/commitdiff
Update to Clutter 0.9 latests API changes
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Fri, 12 Jun 2009 13:32:11 +0000 (09:32 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Mon, 3 Aug 2009 22:16:09 +0000 (18:16 -0400)
This commit used to break (but was later fixed) the kinetic scrolling)
due to heavy changes in ClutterTimeline.

champlain/champlain-view.c
demos/animated-marker.c
demos/launcher.c
demos/polygons.c
tidy/tidy-adjustment.c
tidy/tidy-finger-scroll.c
tidy/tidy-scroll-view.c
tidy/tidy-viewport.c

index b1dcd07a088cddcf62cdfd4cd4ab21d7b7dfd38e..64258e54a82fc4b140bbfbe83416e8a976529dab 100644 (file)
@@ -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))
index abe5f4b9dac1dab9f501d80b3330acfc2107a4d4..0ebddd442f030051d4096aa9ecb6b99e9ee3815b 100644 (file)
@@ -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);
 
index a221eca789db02e2be7f9019b5f5c5056e50588a..51a5e3153ce93b617c05889e13ac6648a9464880 100644 (file)
@@ -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);
index c58392f24ba8ba7709e42e1b73df29ea34339feb..6184b6084e07c0a92a118dcb5dd96009485e3c8d 100644 (file)
@@ -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);
index 6eab9905c65b7e2852fb65bb2169fbb888b24039..cd0417e67125a7c477f377e5f7d69b5560adcc8a 100644 (file)
@@ -471,110 +471,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,
@@ -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,
index ff5d9f4b3225144c452e5ac53817133de8fa557f..e92843a51bcc26cc99ea89350f4b5b409c46fbd9 100644 (file)
@@ -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",
index daa683fdb2e4fadb315b8ec3b686ae63e45226c1..2714a3db1b337528e0bd64376f253feffa5e714c 100644 (file)
@@ -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
index 4756f6cc3f7ac3c66e4f593f533cda2e420dfd45..d30d1c585c5a1767a687d0efe622c3f9059f85f7 100644 (file)
@@ -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)