[libhandy/wip/exalm/paginator-animate: 32/41] carousel-box: Remove hdy_carousel_box_animate()



commit ffe42d8a754f4aa1e8ff61f3b923633c468a02f4
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Dec 29 17:32:32 2019 +0500

    carousel-box: Remove hdy_carousel_box_animate()
    
    It would be good to ensure we only ever animate to child positions in
    future, so only allow that.
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 debian/libhandy-1-0.symbols    |  1 -
 src/hdy-carousel-box-private.h |  3 --
 src/hdy-carousel-box.c         | 92 ++++++++++++++++--------------------------
 src/hdy-carousel.c             |  9 ++---
 4 files changed, 38 insertions(+), 67 deletions(-)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index 9f9bfefc..02b2edc2 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -25,7 +25,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
  hdy_avatar_set_show_initials@LIBHANDY_1_0 0.80.0
  hdy_avatar_set_size@LIBHANDY_1_0 0.80.0
  hdy_avatar_set_text@LIBHANDY_1_0 0.80.0
- hdy_carousel_box_animate@LIBHANDY_1_0 0.80.0
  hdy_carousel_box_get_distance@LIBHANDY_1_0 0.80.0
  hdy_carousel_box_get_n_pages@LIBHANDY_1_0 0.80.0
  hdy_carousel_box_get_nth_child@LIBHANDY_1_0 0.80.0
diff --git a/src/hdy-carousel-box-private.h b/src/hdy-carousel-box-private.h
index ffcaf0a0..9295306d 100644
--- a/src/hdy-carousel-box-private.h
+++ b/src/hdy-carousel-box-private.h
@@ -27,9 +27,6 @@ void            hdy_carousel_box_reorder (HdyCarouselBox *self,
                                           GtkWidget      *widget,
                                           gint            position);
 
-void            hdy_carousel_box_animate (HdyCarouselBox *self,
-                                          gdouble         position,
-                                          gint64          duration);
 gboolean        hdy_carousel_box_is_animating (HdyCarouselBox *self);
 void            hdy_carousel_box_stop_animation (HdyCarouselBox *self);
 
diff --git a/src/hdy-carousel-box.c b/src/hdy-carousel-box.c
index ecf8eb97..59ca92c8 100644
--- a/src/hdy-carousel-box.c
+++ b/src/hdy-carousel-box.c
@@ -979,58 +979,6 @@ hdy_carousel_box_reorder (HdyCarouselBox *self,
     shift_position (self, -1);
 }
 
-/**
- * hdy_carousel_box_animate:
- * @self: a #HdyCarouselBox
- * @position: A value to animate to
- * @duration: Animation duration in milliseconds
- *
- * Animates the widget's position to @position over the next @duration
- * milliseconds using easeOutCubic interpolator.
- *
- * If an animation was already running, it will be cancelled automatically.
- *
- * @duration can be 0, in that case the position will be
- * changed immediately.
- *
- * Since: 1.0
- */
-void
-hdy_carousel_box_animate (HdyCarouselBox *self,
-                          gdouble         position,
-                          gint64          duration)
-{
-  GdkFrameClock *frame_clock;
-  gint64 frame_time;
-
-  g_return_if_fail (HDY_IS_CAROUSEL_BOX (self));
-
-  hdy_carousel_box_stop_animation (self);
-
-  if (duration <= 0 || !hdy_get_enable_animations (GTK_WIDGET (self))) {
-    hdy_carousel_box_set_position (self, position);
-    g_signal_emit (self, signals[SIGNAL_ANIMATION_STOPPED], 0);
-    return;
-  }
-
-  frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));
-  if (!frame_clock) {
-    hdy_carousel_box_set_position (self, position);
-    g_signal_emit (self, signals[SIGNAL_ANIMATION_STOPPED], 0);
-    return;
-  }
-
-  frame_time = gdk_frame_clock_get_frame_time (frame_clock);
-
-  self->animation_data.start_position = self->position;
-  self->animation_data.end_position = position;
-
-  self->animation_data.start_time = frame_time / 1000;
-  self->animation_data.end_time = self->animation_data.start_time + duration;
-  self->animation_data.tick_cb_id =
-    gtk_widget_add_tick_callback (GTK_WIDGET (self), animation_cb, self, NULL);
-}
-
 /**
  * hdy_carousel_box_is_animating:
  * @self: a #HdyCarouselBox
@@ -1078,8 +1026,13 @@ hdy_carousel_box_stop_animation (HdyCarouselBox *self)
  * @widget: a child of @self
  * @duration: animation duration in milliseconds
  *
- * Scrolls to @widget position with an animation. If @duration is 0, changes
- * the position immediately.
+ * Scrolls to @widget position over the next @duration milliseconds using
+ * easeOutCubic interpolator.
+ *
+ * If an animation was already running, it will be cancelled automatically.
+ *
+ * @duration can be 0, in that case the position will be
+ * changed immediately.
  *
  * Since: 1.0
  */
@@ -1088,15 +1041,40 @@ hdy_carousel_box_scroll_to (HdyCarouselBox *self,
                             GtkWidget      *widget,
                             gint64          duration)
 {
-  gint index;
+  GdkFrameClock *frame_clock;
+  gint64 frame_time;
+  gdouble position;
 
   g_return_if_fail (HDY_IS_CAROUSEL_BOX (self));
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (duration >= 0);
 
-  index = find_child_index (self, widget);
+  position = find_child_index (self, widget);
+
+  hdy_carousel_box_stop_animation (self);
+
+  if (duration <= 0 || !hdy_get_enable_animations (GTK_WIDGET (self))) {
+    hdy_carousel_box_set_position (self, position);
+    g_signal_emit (self, signals[SIGNAL_ANIMATION_STOPPED], 0);
+    return;
+  }
+
+  frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));
+  if (!frame_clock) {
+    hdy_carousel_box_set_position (self, position);
+    g_signal_emit (self, signals[SIGNAL_ANIMATION_STOPPED], 0);
+    return;
+  }
 
-  hdy_carousel_box_animate (self, index, duration);
+  frame_time = gdk_frame_clock_get_frame_time (frame_clock);
+
+  self->animation_data.start_position = self->position;
+  self->animation_data.end_position = position;
+
+  self->animation_data.start_time = frame_time / 1000;
+  self->animation_data.end_time = self->animation_data.start_time + duration;
+  self->animation_data.tick_cb_id =
+    gtk_widget_add_tick_callback (GTK_WIDGET (self), animation_cb, self, NULL);
 }
 
 /**
diff --git a/src/hdy-carousel.c b/src/hdy-carousel.c
index f5903236..038a798e 100644
--- a/src/hdy-carousel.c
+++ b/src/hdy-carousel.c
@@ -148,13 +148,10 @@ hdy_carousel_end_swipe (HdySwipeable *swipeable,
                         gdouble       to)
 {
   HdyCarousel *self = HDY_CAROUSEL (swipeable);
+  GtkWidget *child;
 
-  if (duration == 0) {
-    hdy_carousel_box_set_position (self->scrolling_box, to);
-    return;
-  }
-
-  hdy_carousel_box_animate (self->scrolling_box, to, duration);
+  child = hdy_carousel_box_get_page_at_position (self->scrolling_box, to);
+  hdy_carousel_box_scroll_to (self->scrolling_box, child, duration);
 }
 
 static gdouble


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