Commit 55683c07 authored by Carlos Garnacho's avatar Carlos Garnacho

drag: Make API offsets based

It is generally more useful to get offsets right away,
than having to calculate those from the start point.
parent 6cd0e733
...@@ -48,9 +48,15 @@ gtk_gesture_drag_begin (GtkGesture *gesture, ...@@ -48,9 +48,15 @@ gtk_gesture_drag_begin (GtkGesture *gesture,
GdkEventSequence *sequence) GdkEventSequence *sequence)
{ {
GtkGestureDragPrivate *priv; GtkGestureDragPrivate *priv;
GdkEventSequence *current;
current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
priv = gtk_gesture_drag_get_instance_private (GTK_GESTURE_DRAG (gesture)); priv = gtk_gesture_drag_get_instance_private (GTK_GESTURE_DRAG (gesture));
gtk_gesture_get_point (gesture, sequence, &priv->start_x, &priv->start_y); gtk_gesture_get_point (gesture, current, &priv->start_x, &priv->start_y);
priv->last_x = priv->start_x;
priv->last_y = priv->start_y;
g_signal_emit (gesture, signals[DRAG_BEGIN], 0, priv->start_x, priv->start_y); g_signal_emit (gesture, signals[DRAG_BEGIN], 0, priv->start_x, priv->start_y);
} }
...@@ -74,10 +80,13 @@ gtk_gesture_drag_end (GtkGesture *gesture, ...@@ -74,10 +80,13 @@ gtk_gesture_drag_end (GtkGesture *gesture,
GdkEventSequence *sequence) GdkEventSequence *sequence)
{ {
GtkGestureDragPrivate *priv; GtkGestureDragPrivate *priv;
GdkEventSequence *current;
gdouble x, y; gdouble x, y;
current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
priv = gtk_gesture_drag_get_instance_private (GTK_GESTURE_DRAG (gesture)); priv = gtk_gesture_drag_get_instance_private (GTK_GESTURE_DRAG (gesture));
gtk_gesture_get_point (gesture, sequence, &priv->last_x, &priv->last_y); gtk_gesture_get_point (gesture, current, &priv->last_x, &priv->last_y);
x = priv->last_x - priv->start_x; x = priv->last_x - priv->start_x;
y = priv->last_y - priv->start_y; y = priv->last_y - priv->start_y;
...@@ -155,8 +164,8 @@ gtk_gesture_drag_new (GtkWidget *widget) ...@@ -155,8 +164,8 @@ gtk_gesture_drag_new (GtkWidget *widget)
**/ **/
gboolean gboolean
gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture, gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
gint *x, gdouble *x,
gint *y) gdouble *y)
{ {
GtkGestureDragPrivate *priv; GtkGestureDragPrivate *priv;
...@@ -175,10 +184,10 @@ gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture, ...@@ -175,10 +184,10 @@ gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
} }
/** /**
* gtk_gesture_drag_get_current_point: * gtk_gesture_drag_get_offset:
* @gesture: a #GtkGesture * @gesture: a #GtkGesture
* @x: X coordinate for the current point * @x: X offset for the current point
* @y: Y coordinate for the current point * @y: Y offset for the current point
* *
* If the @gesture is active, this function returns %TRUE and * If the @gesture is active, this function returns %TRUE and
* fills in @x and @y with the coordinates of the current point, * fills in @x and @y with the coordinates of the current point,
...@@ -189,9 +198,9 @@ gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture, ...@@ -189,9 +198,9 @@ gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
* Since: 3.14 * Since: 3.14
**/ **/
gboolean gboolean
gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture, gtk_gesture_drag_get_offset (GtkGestureDrag *gesture,
gint *x, gdouble *x,
gint *y) gdouble *y)
{ {
GtkGestureDragPrivate *priv; GtkGestureDragPrivate *priv;
...@@ -201,10 +210,10 @@ gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture, ...@@ -201,10 +210,10 @@ gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture,
priv = gtk_gesture_drag_get_instance_private (gesture); priv = gtk_gesture_drag_get_instance_private (gesture);
if (x) if (x)
*x = priv->last_x; *x = priv->last_x - priv->start_x;
if (y) if (y)
*y = priv->last_y; *y = priv->last_y - priv->start_y;
return TRUE; return TRUE;
} }
...@@ -68,12 +68,12 @@ GtkGesture * gtk_gesture_drag_new (GtkWidget *widget); ...@@ -68,12 +68,12 @@ GtkGesture * gtk_gesture_drag_new (GtkWidget *widget);
GDK_AVAILABLE_IN_3_14 GDK_AVAILABLE_IN_3_14
gboolean gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture, gboolean gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
gint *x, gdouble *x,
gint *y); gdouble *y);
GDK_AVAILABLE_IN_3_14 GDK_AVAILABLE_IN_3_14
gboolean gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture, gboolean gtk_gesture_drag_get_offset (GtkGestureDrag *gesture,
gint *x, gdouble *x,
gint *y); gdouble *y);
G_END_DECLS G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment