[libadwaita/wip/exalm/spring-animation-swipes: 3/10] swipe-tracker: Add velocity param to end-swipe




commit 788dfd7bffc88c2a019a52dd09afb4b6b6f42379
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Dec 6 14:03:50 2021 +0500

    swipe-tracker: Add velocity param to end-swipe
    
    Keep duration for now, it will be removed after all widgets have stopped
    using it.

 src/adw-carousel.c      | 1 +
 src/adw-flap.c          | 1 +
 src/adw-leaflet.c       | 1 +
 src/adw-swipe-tracker.c | 7 ++++---
 4 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index 045e096d..09089d59 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -422,6 +422,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
 static void
 end_swipe_cb (AdwSwipeTracker *tracker,
               guint            duration,
+              double           velocity,
               double           to,
               AdwCarousel     *self)
 {
diff --git a/src/adw-flap.c b/src/adw-flap.c
index 6d892851..786476d7 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -420,6 +420,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
 static void
 end_swipe_cb (AdwSwipeTracker *tracker,
               guint            duration,
+              double           velocity,
               double           to,
               AdwFlap         *self)
 {
diff --git a/src/adw-leaflet.c b/src/adw-leaflet.c
index 5c076b1d..8a3a3972 100644
--- a/src/adw-leaflet.c
+++ b/src/adw-leaflet.c
@@ -1467,6 +1467,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
 static void
 end_swipe_cb (AdwSwipeTracker *tracker,
               guint            duration,
+              double           velocity,
               double           to,
               AdwLeaflet      *self)
 {
diff --git a/src/adw-swipe-tracker.c b/src/adw-swipe-tracker.c
index 543e17c3..d8920bc8 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -448,7 +448,7 @@ gesture_end (AdwSwipeTracker *self,
   if (self->progress != end_progress)
     duration = CLAMP (duration, MIN_ANIMATION_DURATION, max_duration);
 
-  g_signal_emit (self, signals[SIGNAL_END_SWIPE], 0, duration, end_progress);
+  g_signal_emit (self, signals[SIGNAL_END_SWIPE], 0, duration, calculate_velocity (self), end_progress);
 
   if (!self->cancelled)
     self->state = ADW_SWIPE_TRACKER_STATE_FINISHING;
@@ -1152,6 +1152,7 @@ adw_swipe_tracker_class_init (AdwSwipeTrackerClass *klass)
    * AdwSwipeTracker::end-swipe:
    * @self: the `AdwSwipeTracker` instance
    * @duration: snap-back animation duration in milliseconds
+   * @velocity: the velocity of the swipe
    * @to: the progress value to animate to
    *
    * This signal is emitted as soon as the gesture has stopped.
@@ -1165,8 +1166,8 @@ adw_swipe_tracker_class_init (AdwSwipeTrackerClass *klass)
                   0,
                   NULL, NULL, NULL,
                   G_TYPE_NONE,
-                  2,
-                  G_TYPE_UINT, G_TYPE_DOUBLE);
+                  3,
+                  G_TYPE_UINT, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
 }
 
 static void


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