1 /*
2 * This file is part of d-handy.
3 *
4 * d-handy 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 * d-handy 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 d-handy; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18 */19 modulehandy.SwipeableIF;
20 21 privateimportgobject.ObjectG;
22 privateimportgobject.Signals;
23 privateimporthandy.SwipeTracker;
24 privateimporthandy.c.functions;
25 publicimporthandy.c.types;
26 privateimportstd.algorithm;
27 28 29 /** */30 publicinterfaceSwipeableIF{
31 /** Get the main Gtk struct */32 publicHdySwipeable* getSwipeableStruct(booltransferOwnership = false);
33 34 /** the main Gtk struct as a void* */35 protectedvoid* getStruct();
36 37 38 /** */39 publicstaticGTypegetType()
40 {
41 returnhdy_swipeable_get_type();
42 }
43 44 /**
45 * Emits HdySwipeable::child-switched signal. This should be called when the
46 * widget switches visible child widget.
47 *
48 * @duration can be 0 if the child is switched without animation.
49 *
50 * Params:
51 * index = the index of the child to switch to
52 * duration = Animation duration in milliseconds
53 *
54 * Since: 1.0
55 */56 publicvoidemitChildSwitched(uintindex, longduration);
57 58 /**
59 * Gets the progress @self will snap back to after the gesture is canceled.
60 *
61 * Returns: the cancel progress, unitless
62 *
63 * Since: 1.0
64 */65 publicdoublegetCancelProgress();
66 67 /**
68 * Gets the swipe distance of @self. This corresponds to how many pixels
69 * 1 unit represents.
70 *
71 * Returns: the swipe distance in pixels
72 *
73 * Since: 1.0
74 */75 publicdoublegetDistance();
76 77 /**
78 * Gets the current progress of @self
79 *
80 * Returns: the current progress, unitless
81 *
82 * Since: 1.0
83 */84 publicdoublegetProgress();
85 86 /**
87 * Gets the snap points of @self. Each snap point represents a progress value
88 * that is considered acceptable to end the swipe on.
89 *
90 * Returns: the snap points of
91 * @self. The array must be freed with g_free().
92 *
93 * Since: 1.0
94 */95 publicdouble[] getSnapPoints();
96 97 /**
98 * Gets the area @self can start a swipe from for the given direction and
99 * gesture type.
100 * This can be used to restrict swipes to only be possible from a certain area,
101 * for example, to only allow edge swipes, or to have a draggable element and
102 * ignore swipes elsewhere.
103 *
104 * Swipe area is only considered for direct swipes (as in, not initiated by
105 * #HdySwipeGroup).
106 *
107 * If not implemented, the default implementation returns the allocation of
108 * @self, allowing swipes from anywhere.
109 *
110 * Params:
111 * navigationDirection = the direction of the swipe
112 * isDrag = whether the swipe is caused by a dragging gesture
113 * rect = a pointer to a #GdkRectangle to store the swipe area
114 *
115 * Since: 1.0
116 */117 publicvoidgetSwipeArea(HdyNavigationDirectionnavigationDirection, boolisDrag, outGdkRectanglerect);
118 119 /**
120 * Gets the #HdySwipeTracker used by this swipeable widget.
121 *
122 * Returns: the swipe tracker
123 *
124 * Since: 1.0
125 */126 publicSwipeTrackergetSwipeTracker();
127 128 /**
129 * See HdySwipeable::child-switched.
130 *
131 * Params:
132 * index = the index of the child to switch to
133 * duration = Animation duration in milliseconds
134 *
135 * Since: 1.0
136 */137 publicvoidswitchChild(uintindex, longduration);
138 139 /**
140 * This signal should be emitted when the widget's visible child is changed.
141 *
142 * @duration can be 0 if the child is switched without animation.
143 *
144 * This is used by #HdySwipeGroup, applications should not connect to it.
145 *
146 * Params:
147 * index = the index of the child to switch to
148 * duration = Animation duration in milliseconds
149 *
150 * Since: 1.0
151 */152 gulongaddOnChildSwitched(voiddelegate(uint, long, SwipeableIF) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0);
153 }