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.GestureZoom;
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.c.functions;
32 public  import gtk.c.types;
33 private import std.algorithm;
34 
35 
36 /**
37  * `GtkGestureZoom` is a `GtkGesture` for 2-finger pinch/zoom gestures.
38  * 
39  * Whenever the distance between both tracked sequences changes, the
40  * [signal@Gtk.GestureZoom::scale-changed] signal is emitted to report
41  * the scale factor.
42  */
43 public class GestureZoom : Gesture
44 {
45 	/** the main Gtk struct */
46 	protected GtkGestureZoom* gtkGestureZoom;
47 
48 	/** Get the main Gtk struct */
49 	public GtkGestureZoom* getGestureZoomStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return gtkGestureZoom;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gtkGestureZoom;
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (GtkGestureZoom* gtkGestureZoom, bool ownedRef = false)
66 	{
67 		this.gtkGestureZoom = gtkGestureZoom;
68 		super(cast(GtkGesture*)gtkGestureZoom, ownedRef);
69 	}
70 
71 
72 	/** */
73 	public static GType getType()
74 	{
75 		return gtk_gesture_zoom_get_type();
76 	}
77 
78 	/**
79 	 * Returns a newly created `GtkGesture` that recognizes
80 	 * pinch/zoom gestures.
81 	 *
82 	 * Returns: a newly created `GtkGestureZoom`
83 	 *
84 	 * Throws: ConstructionException GTK+ fails to create the object.
85 	 */
86 	public this()
87 	{
88 		auto __p = gtk_gesture_zoom_new();
89 
90 		if(__p is null)
91 		{
92 			throw new ConstructionException("null returned by new");
93 		}
94 
95 		this(cast(GtkGestureZoom*) __p, true);
96 	}
97 
98 	/**
99 	 * Gets the scale delta.
100 	 *
101 	 * If @gesture is active, this function returns the zooming
102 	 * difference since the gesture was recognized (hence the
103 	 * starting point is considered 1:1). If @gesture is not
104 	 * active, 1 is returned.
105 	 *
106 	 * Returns: the scale delta
107 	 */
108 	public double getScaleDelta()
109 	{
110 		return gtk_gesture_zoom_get_scale_delta(gtkGestureZoom);
111 	}
112 
113 	/**
114 	 * Emitted whenever the distance between both tracked sequences changes.
115 	 *
116 	 * Params:
117 	 *     scale = Scale delta, taking the initial state as 1:1
118 	 */
119 	gulong addOnScaleChanged(void delegate(double, GestureZoom) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
120 	{
121 		return Signals.connect(this, "scale-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
122 	}
123 }