[gtk+/gestures: 45/202] drag: Make API offsets based
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gestures: 45/202] drag: Make API offsets based
- Date: Fri, 23 May 2014 18:00:09 +0000 (UTC)
commit 55683c075c932aa1327cf293da753b03317b0484
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 25 13:22:51 2014 +0100
drag: Make API offsets based
It is generally more useful to get offsets right away,
than having to calculate those from the start point.
gtk/gtkgesturedrag.c | 33 +++++++++++++++++++++------------
gtk/gtkgesturedrag.h | 10 +++++-----
2 files changed, 26 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkgesturedrag.c b/gtk/gtkgesturedrag.c
index 268b945..c14c10f 100644
--- a/gtk/gtkgesturedrag.c
+++ b/gtk/gtkgesturedrag.c
@@ -48,9 +48,15 @@ gtk_gesture_drag_begin (GtkGesture *gesture,
GdkEventSequence *sequence)
{
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));
- 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);
}
@@ -74,10 +80,13 @@ gtk_gesture_drag_end (GtkGesture *gesture,
GdkEventSequence *sequence)
{
GtkGestureDragPrivate *priv;
+ GdkEventSequence *current;
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));
- 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;
y = priv->last_y - priv->start_y;
@@ -155,8 +164,8 @@ gtk_gesture_drag_new (GtkWidget *widget)
**/
gboolean
gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
- gint *x,
- gint *y)
+ gdouble *x,
+ gdouble *y)
{
GtkGestureDragPrivate *priv;
@@ -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
- * @x: X coordinate for the current point
- * @y: Y coordinate for the current point
+ * @x: X offset for the current point
+ * @y: Y offset for the current point
*
* If the @gesture is active, this function returns %TRUE and
* fills in @x and @y with the coordinates of the current point,
@@ -189,9 +198,9 @@ gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
* Since: 3.14
**/
gboolean
-gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture,
- gint *x,
- gint *y)
+gtk_gesture_drag_get_offset (GtkGestureDrag *gesture,
+ gdouble *x,
+ gdouble *y)
{
GtkGestureDragPrivate *priv;
@@ -201,10 +210,10 @@ gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture,
priv = gtk_gesture_drag_get_instance_private (gesture);
if (x)
- *x = priv->last_x;
+ *x = priv->last_x - priv->start_x;
if (y)
- *y = priv->last_y;
+ *y = priv->last_y - priv->start_y;
return TRUE;
}
diff --git a/gtk/gtkgesturedrag.h b/gtk/gtkgesturedrag.h
index 1d0f706..c2f76e6 100644
--- a/gtk/gtkgesturedrag.h
+++ b/gtk/gtkgesturedrag.h
@@ -68,12 +68,12 @@ GtkGesture * gtk_gesture_drag_new (GtkWidget *widget);
GDK_AVAILABLE_IN_3_14
gboolean gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture,
- gint *x,
- gint *y);
+ gdouble *x,
+ gdouble *y);
GDK_AVAILABLE_IN_3_14
-gboolean gtk_gesture_drag_get_current_point (GtkGestureDrag *gesture,
- gint *x,
- gint *y);
+gboolean gtk_gesture_drag_get_offset (GtkGestureDrag *gesture,
+ gdouble *x,
+ gdouble *y);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]