forked from AuroraMiddleware/gtk
drag: Make API offsets based
It is generally more useful to get offsets right away, than having to calculate those from the start point.
This commit is contained in:
parent
6cd0e733f5
commit
55683c075c
@ -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,
|
|||||||
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)
|
|||||||
**/
|
**/
|
||||||
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,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,
|
|||||||
* 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,
|
|||||||
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);
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user