1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.GestureSwipe;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Gesture;
31 private import gtk.GestureSingle;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 private import std.algorithm;
35 
36 
37 /**
38  * `GtkGestureSwipe` is a `GtkGesture` for swipe gestures.
39  * 
40  * After a press/move/.../move/release sequence happens, the
41  * [signal@Gtk.GestureSwipe::swipe] signal will be emitted,
42  * providing the velocity and directionality of the sequence
43  * at the time it was lifted.
44  * 
45  * If the velocity is desired in intermediate points,
46  * [method@Gtk.GestureSwipe.get_velocity] can be called in a
47  * [signal@Gtk.Gesture::update] handler.
48  * 
49  * All velocities are reported in pixels/sec units.
50  */
51 public class GestureSwipe : GestureSingle
52 {
53 	/** the main Gtk struct */
54 	protected GtkGestureSwipe* gtkGestureSwipe;
55 
56 	/** Get the main Gtk struct */
57 	public GtkGestureSwipe* getGestureSwipeStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gtkGestureSwipe;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gtkGestureSwipe;
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GtkGestureSwipe* gtkGestureSwipe, bool ownedRef = false)
74 	{
75 		this.gtkGestureSwipe = gtkGestureSwipe;
76 		super(cast(GtkGestureSingle*)gtkGestureSwipe, ownedRef);
77 	}
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gtk_gesture_swipe_get_type();
84 	}
85 
86 	/**
87 	 * Returns a newly created `GtkGesture` that recognizes swipes.
88 	 *
89 	 * Returns: a newly created `GtkGestureSwipe`
90 	 *
91 	 * Throws: ConstructionException GTK+ fails to create the object.
92 	 */
93 	public this()
94 	{
95 		auto __p = gtk_gesture_swipe_new();
96 
97 		if(__p is null)
98 		{
99 			throw new ConstructionException("null returned by new");
100 		}
101 
102 		this(cast(GtkGestureSwipe*) __p, true);
103 	}
104 
105 	/**
106 	 * Gets the current velocity.
107 	 *
108 	 * If the gesture is recognized, this function returns %TRUE and fills
109 	 * in @velocity_x and @velocity_y with the recorded velocity, as per the
110 	 * last events processed.
111 	 *
112 	 * Params:
113 	 *     velocityX = return value for the velocity in the X axis, in pixels/sec
114 	 *     velocityY = return value for the velocity in the Y axis, in pixels/sec
115 	 *
116 	 * Returns: whether velocity could be calculated
117 	 */
118 	public bool getVelocity(out double velocityX, out double velocityY)
119 	{
120 		return gtk_gesture_swipe_get_velocity(gtkGestureSwipe, &velocityX, &velocityY) != 0;
121 	}
122 
123 	/**
124 	 * Emitted when the recognized gesture is finished.
125 	 *
126 	 * Velocity and direction are a product of previously recorded events.
127 	 *
128 	 * Params:
129 	 *     velocityX = velocity in the X axis, in pixels/sec
130 	 *     velocityY = velocity in the Y axis, in pixels/sec
131 	 */
132 	gulong addOnSwipe(void delegate(double, double, GestureSwipe) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
133 	{
134 		return Signals.connect(this, "swipe", dlg, connectFlags ^ ConnectFlags.SWAPPED);
135 	}
136 }