[libhandy] swipe-tracker: Stop using hdy_swipeable_get_range()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] swipe-tracker: Stop using hdy_swipeable_get_range()
- Date: Tue, 30 Jun 2020 15:11:12 +0000 (UTC)
commit c8e62d06ce307be6c49158fe4625683a0509dfa9
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Jun 28 20:00:37 2020 +0500
swipe-tracker: Stop using hdy_swipeable_get_range()
Now that get_snap_points() is implemented everywhere, we can easily
reimplement get_range() using it.
Signed-off-by: Alexander Mikhaylenko <alexm gnome org>
src/hdy-swipe-tracker.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index f78951d6..57a74d14 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -125,6 +125,20 @@ reset (HdySwipeTracker *self)
gtk_grab_remove (GTK_WIDGET (self->swipeable));
}
+static void
+get_range (HdySwipeTracker *self,
+ gdouble *first,
+ gdouble *last)
+{
+ g_autofree gdouble *points = NULL;
+ gint n;
+
+ points = hdy_swipeable_get_snap_points (self->swipeable, &n);
+
+ *first = points[0];
+ *last = points[n - 1];
+}
+
static void
gesture_prepare (HdySwipeTracker *self,
HdyNavigationDirection direction)
@@ -185,7 +199,7 @@ gesture_update (HdySwipeTracker *self,
if (time != self->prev_time)
self->velocity = delta / (time - self->prev_time);
- hdy_swipeable_get_range (self->swipeable, &first_point, &last_point);
+ get_range (self, &first_point, &last_point);
progress = self->progress + delta;
progress = CLAMP (progress, first_point, last_point);
@@ -343,7 +357,7 @@ drag_update_cb (HdySwipeTracker *self,
gdouble first_point, last_point;
gboolean is_overshooting;
- hdy_swipeable_get_range (self->swipeable, &first_point, &last_point);
+ get_range (self, &first_point, &last_point);
drag_distance = sqrt (offset_x * offset_x + offset_y * offset_y);
is_overshooting = (offset < 0 && self->progress <= first_point) ||
@@ -475,7 +489,7 @@ handle_scroll_event (HdySwipeTracker *self,
gboolean is_overshooting;
gdouble first_point, last_point;
- hdy_swipeable_get_range (self->swipeable, &first_point, &last_point);
+ get_range (self, &first_point, &last_point);
is_overshooting = (delta < 0 && self->progress <= first_point) ||
(delta > 0 && self->progress >= last_point);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]