[libadwaita/wip/exalm/spring-animation-swipes: 8/10] swipe-tracker: Remove the duration parameter from end-swipe
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/spring-animation-swipes: 8/10] swipe-tracker: Remove the duration parameter from end-swipe
- Date: Mon, 6 Dec 2021 16:40:12 +0000 (UTC)
commit 11849510ba90790093ae130a3e46033b1f908e57
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Dec 6 16:51:51 2021 +0500
swipe-tracker: Remove the duration parameter from end-swipe
All widgets have migrated, we can do it now.
Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/27
src/adw-carousel.c | 1 -
src/adw-flap.c | 1 -
src/adw-leaflet.c | 1 -
src/adw-swipe-tracker.c | 25 ++++++++-----------------
4 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index c75c130b..46a31c3a 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -421,7 +421,6 @@ 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 a310d3db..10a60f1a 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -423,7 +423,6 @@ 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 20ba1fe7..baeef771 100644
--- a/src/adw-leaflet.c
+++ b/src/adw-leaflet.c
@@ -1464,7 +1464,6 @@ 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 d8920bc8..a477e977 100644
--- a/src/adw-swipe-tracker.c
+++ b/src/adw-swipe-tracker.c
@@ -426,7 +426,6 @@ gesture_end (AdwSwipeTracker *self,
gboolean is_touchpad)
{
double end_progress, velocity;
- guint duration, max_duration;
if (self->state == ADW_SWIPE_TRACKER_STATE_NONE)
return;
@@ -434,21 +433,9 @@ gesture_end (AdwSwipeTracker *self,
trim_history (self, time);
velocity = calculate_velocity (self);
-
end_progress = get_end_progress (self, velocity, is_touchpad);
- velocity /= distance;
-
- if ((end_progress - self->progress) * velocity <= 0)
- velocity = ANIMATION_BASE_VELOCITY;
-
- max_duration = MAX_ANIMATION_DURATION * log2 (1 + MAX (1, ceil (ABS (self->progress - end_progress))));
-
- duration = ABS ((self->progress - end_progress) / velocity * DURATION_MULTIPLIER);
- if (self->progress != end_progress)
- duration = CLAMP (duration, MIN_ANIMATION_DURATION, max_duration);
-
- g_signal_emit (self, signals[SIGNAL_END_SWIPE], 0, duration, calculate_velocity (self), end_progress);
+ g_signal_emit (self, signals[SIGNAL_END_SWIPE], 0, velocity, end_progress);
if (!self->cancelled)
self->state = ADW_SWIPE_TRACKER_STATE_FINISHING;
@@ -1151,12 +1138,16 @@ 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.
*
+ * The user is expected to animate the deceleration from the current progress
+ * value to @to with an animation using @velocity as the initial velocity,
+ * provided in pixels per second. [class@Adw.SpringAnimation] is usually a
+ * good fit for this.
+ *
* Since: 1.0
*/
signals[SIGNAL_END_SWIPE] =
@@ -1166,8 +1157,8 @@ adw_swipe_tracker_class_init (AdwSwipeTrackerClass *klass)
0,
NULL, NULL, NULL,
G_TYPE_NONE,
- 3,
- G_TYPE_UINT, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
+ 2,
+ G_TYPE_DOUBLE, G_TYPE_DOUBLE);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]