[libhandy/wip/exalm/paginator-animate: 24/41] swipe-tracker: Remove hdy_swipe_tracker_confirm_swipe()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy/wip/exalm/paginator-animate: 24/41] swipe-tracker: Remove hdy_swipe_tracker_confirm_swipe()
- Date: Wed, 27 May 2020 15:53:59 +0000 (UTC)
commit 993cbf09306d97845e12b74ded403589e4127801
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Dec 26 14:41:58 2019 +0500
swipe-tracker: Remove hdy_swipe_tracker_confirm_swipe()
Update HdySwipeable docs.
Signed-off-by: Alexander Mikhaylenko <alexm gnome org>
debian/libhandy-1-0.symbols | 1 -
src/hdy-carousel.c | 11 ----
src/hdy-stackable-box.c | 33 ------------
src/hdy-swipe-tracker-private.h | 7 ---
src/hdy-swipe-tracker.c | 109 ++--------------------------------------
5 files changed, 5 insertions(+), 156 deletions(-)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index ba7d309a..9f9bfefc 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -305,7 +305,6 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
hdy_swipe_group_new@LIBHANDY_1_0 0.0.12
hdy_swipe_group_remove_swipeable@LIBHANDY_1_0 0.0.12
hdy_swipe_tracker_captured_event@LIBHANDY_1_0 0.0.11
- hdy_swipe_tracker_confirm_swipe@LIBHANDY_1_0 0.0.11
hdy_swipe_tracker_get_allow_mouse_drag@LIBHANDY_1_0 0.0.12
hdy_swipe_tracker_get_enabled@LIBHANDY_1_0 0.0.11
hdy_swipe_tracker_get_reversed@LIBHANDY_1_0 0.0.11
diff --git a/src/hdy-carousel.c b/src/hdy-carousel.c
index 9c6d63d9..03e411ab 100644
--- a/src/hdy-carousel.c
+++ b/src/hdy-carousel.c
@@ -129,19 +129,8 @@ hdy_carousel_begin_swipe (HdySwipeable *swipeable,
gboolean direct)
{
HdyCarousel *self = HDY_CAROUSEL (swipeable);
- gdouble distance, progress, cancel_progress;
- gint n_snap_points;
- gdouble *snap_points;
hdy_carousel_box_stop_animation (self->scrolling_box);
-
- distance = hdy_swipeable_get_distance (swipeable);
- snap_points = hdy_swipeable_get_snap_points (swipeable, &n_snap_points);
- progress = hdy_swipeable_get_progress (swipeable);
- cancel_progress = hdy_swipeable_get_cancel_progress (swipeable);
-
- hdy_swipe_tracker_confirm_swipe (self->tracker, distance, snap_points,
- n_snap_points, progress, cancel_progress);
}
static void
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index cecf4f38..318bd17c 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -3157,36 +3157,11 @@ hdy_stackable_box_switch_child (HdyStackableBox *self,
duration, FALSE);
}
-/* FIXME: This will go away in the next commits */
-static gdouble *
-get_snap_points_from_range (HdyStackableBox *self,
- gint *n_snap_points)
-{
- gint n;
- gdouble *points, lower, upper;
-
- hdy_stackable_box_get_range (self, &lower, &upper);
-
- n = (lower != upper) ? 2 : 1;
-
- points = g_new0 (gdouble, n);
- points[0] = lower;
- points[n - 1] = upper;
-
- if (n_snap_points)
- *n_snap_points = n;
-
- return points;
-}
-
void
hdy_stackable_box_begin_swipe (HdyStackableBox *self,
HdyNavigationDirection direction,
gboolean direct)
{
- gint n_snap_points;
- gdouble *snap_points, distance, progress, cancel_progress;
-
self->child_transition.is_direct_swipe = direct;
self->child_transition.swipe_direction = direction;
@@ -3210,14 +3185,6 @@ hdy_stackable_box_begin_swipe (HdyStackableBox *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CHILD_TRANSITION_RUNNING]);
}
}
-
- distance = hdy_stackable_box_get_distance (self);
- snap_points = get_snap_points_from_range (self, &n_snap_points);
- progress = hdy_stackable_box_get_progress (self);
- cancel_progress = hdy_stackable_box_get_cancel_progress (self);
-
- hdy_swipe_tracker_confirm_swipe (self->tracker, distance, snap_points,
- n_snap_points, progress, cancel_progress);
}
void
diff --git a/src/hdy-swipe-tracker-private.h b/src/hdy-swipe-tracker-private.h
index 54307431..f268b27f 100644
--- a/src/hdy-swipe-tracker-private.h
+++ b/src/hdy-swipe-tracker-private.h
@@ -36,11 +36,4 @@ void hdy_swipe_tracker_set_allow_mouse_drag (HdySwipeTracker *self,
gboolean hdy_swipe_tracker_captured_event (HdySwipeTracker *self,
GdkEvent *event);
-void hdy_swipe_tracker_confirm_swipe (HdySwipeTracker *self,
- gdouble distance,
- gdouble *snap_points,
- gint n_snap_points,
- gdouble current_progress,
- gdouble cancel_progress);
-
G_END_DECLS
diff --git a/src/hdy-swipe-tracker.c b/src/hdy-swipe-tracker.c
index 9d172b33..288bda54 100644
--- a/src/hdy-swipe-tracker.c
+++ b/src/hdy-swipe-tracker.c
@@ -63,7 +63,6 @@
typedef enum {
HDY_SWIPE_TRACKER_STATE_NONE,
- HDY_SWIPE_TRACKER_STATE_PREPARING,
HDY_SWIPE_TRACKER_STATE_PENDING,
HDY_SWIPE_TRACKER_STATE_SCROLLING,
HDY_SWIPE_TRACKER_STATE_FINISHING,
@@ -85,13 +84,9 @@ struct _HdySwipeTracker
gdouble initial_progress;
gdouble progress;
gboolean cancelled;
- gdouble cancel_progress;
gdouble prev_offset;
- gdouble distance;
- gdouble *snap_points;
- gint n_snap_points;
gboolean is_scrolling;
HdySwipeTrackerState state;
@@ -118,12 +113,9 @@ static GParamSpec *props[LAST_PROP];
static void
reset (HdySwipeTracker *self)
{
- g_clear_pointer (&self->snap_points, g_free);
-
self->state = HDY_SWIPE_TRACKER_STATE_NONE;
self->prev_offset = 0;
- self->distance = 0;
self->initial_progress = 0;
self->progress = 0;
@@ -131,8 +123,6 @@ reset (HdySwipeTracker *self)
self->prev_time = 0;
self->velocity = 0;
- self->cancel_progress = 0;
-
self->cancelled = FALSE;
if (self->swipeable)
@@ -146,8 +136,12 @@ gesture_prepare (HdySwipeTracker *self,
if (self->state != HDY_SWIPE_TRACKER_STATE_NONE)
return;
- self->state = HDY_SWIPE_TRACKER_STATE_PREPARING;
hdy_swipeable_begin_swipe (self->swipeable, direction, TRUE);
+
+ self->initial_progress = hdy_swipeable_get_progress (self->swipeable);
+ self->progress = self->initial_progress;
+ self->velocity = 0;
+ self->state = HDY_SWIPE_TRACKER_STATE_PENDING;
}
static void
@@ -279,11 +273,6 @@ static void
gesture_cancel (HdySwipeTracker *self,
gdouble distance)
{
- if (self->state == HDY_SWIPE_TRACKER_STATE_PREPARING) {
- reset (self);
- return;
- }
-
if (self->state != HDY_SWIPE_TRACKER_STATE_PENDING &&
self->state != HDY_SWIPE_TRACKER_STATE_SCROLLING)
return;
@@ -440,13 +429,6 @@ captured_scroll_event (HdySwipeTracker *self,
}
}
- if (self->state == HDY_SWIPE_TRACKER_STATE_PREPARING) {
- if (gdk_event_is_scroll_stop_event (event))
- gesture_cancel (self, distance);
-
- return GDK_EVENT_PROPAGATE;
- }
-
if (self->state == HDY_SWIPE_TRACKER_STATE_PENDING) {
gboolean is_overshooting;
gdouble first_point, last_point;
@@ -516,7 +498,6 @@ hdy_swipe_tracker_dispose (GObject *object)
if (self->touch_gesture)
g_signal_handlers_disconnect_by_data (self->touch_gesture, self);
- g_clear_pointer (&self->snap_points, g_free);
g_clear_object (&self->touch_gesture);
g_clear_object (&self->swipeable);
@@ -926,83 +907,3 @@ hdy_swipe_tracker_captured_event (HdySwipeTracker *self,
return retval;
}
-
-static gboolean
-is_sorted (gdouble *array,
- gint n)
-{
- gint i;
-
- if (n < 2)
- return TRUE;
-
- for (i = 0; i < n - 1; i++)
- if (array[i] > array[i + 1])
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * hdy_swipe_tracker_confirm_swipe:
- * @self: a #HdySwipeTracker
- * @distance: swipe distance in pixels
- * @snap_points: (array length=n_snap_points) (transfer full): array of snap
- * points, must be sorted in ascending order
- * @n_snap_points: length of @snap_points
- * @current_progress: initial progress value
- * @cancel_progress: the value that will be used if the swipe is cancelled
- *
- * Confirms a swipe. User has to call this in #HdySwipeTracker::begin signal
- * handler, otherwise the swipe wouldn't start. If there's an animation running,
- * the user should stop it and pass its calue as @current_progress.
- *
- * The call is not a guarantee that the swipe will be started; child widgets
- * may intercept it, in which case #HdySwipeTracker::end will be emitted with
- * @cancel_progress value and 0 duration.
- *
- * @cancel_progress must always be a snap point, or an otherwise a value
- * matching a non-transient state, otherwise the widget will get stuck
- * mid-animation.
- *
- * If there's no animation running, @current_progress and @cancel_progress
- * must be same.
- *
- * Since: 0.0.11
- */
-void
-hdy_swipe_tracker_confirm_swipe (HdySwipeTracker *self,
- gdouble distance,
- gdouble *snap_points,
- gint n_snap_points,
- gdouble current_progress,
- gdouble cancel_progress)
-{
- g_autofree gdouble *points = g_steal_pointer (&snap_points);
-
- g_return_if_fail (HDY_IS_SWIPE_TRACKER (self));
- g_return_if_fail (distance > 0.0);
- g_return_if_fail (points);
- g_return_if_fail (n_snap_points > 0);
- g_return_if_fail (is_sorted (points, n_snap_points));
- g_return_if_fail (current_progress >= points[0]);
- g_return_if_fail (current_progress <= points[n_snap_points - 1]);
- g_return_if_fail (cancel_progress >= points[0]);
- g_return_if_fail (cancel_progress <= points[n_snap_points - 1]);
-
- if (self->state != HDY_SWIPE_TRACKER_STATE_PREPARING) {
- gesture_cancel (self, distance);
- return;
- }
-
- g_clear_pointer (&self->snap_points, g_free);
-
- self->distance = distance;
- self->initial_progress = current_progress;
- self->progress = current_progress;
- self->velocity = 0;
- self->snap_points = g_steal_pointer (&points);
- self->n_snap_points = n_snap_points;
- self->cancel_progress = cancel_progress;
- self->state = HDY_SWIPE_TRACKER_STATE_PENDING;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]