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 module handy.SwipeableIF; 20 21 private import gobject.ObjectG; 22 private import gobject.Signals; 23 private import handy.SwipeTracker; 24 private import handy.c.functions; 25 public import handy.c.types; 26 private import std.algorithm; 27 28 29 /** */ 30 public interface SwipeableIF{ 31 /** Get the main Gtk struct */ 32 public HdySwipeable* getSwipeableStruct(bool transferOwnership = false); 33 34 /** the main Gtk struct as a void* */ 35 protected void* getStruct(); 36 37 38 /** */ 39 public static GType getType() 40 { 41 return hdy_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 public void emitChildSwitched(uint index, long duration); 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 public double getCancelProgress(); 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 public double getDistance(); 76 77 /** 78 * Gets the current progress of @self 79 * 80 * Returns: the current progress, unitless 81 * 82 * Since: 1.0 83 */ 84 public double getProgress(); 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 public double[] 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 public void getSwipeArea(HdyNavigationDirection navigationDirection, bool isDrag, out GdkRectangle rect); 118 119 /** 120 * Gets the #HdySwipeTracker used by this swipeable widget. 121 * 122 * Returns: the swipe tracker 123 * 124 * Since: 1.0 125 */ 126 public SwipeTracker getSwipeTracker(); 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 public void switchChild(uint index, long duration); 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 gulong addOnChildSwitched(void delegate(uint, long, SwipeableIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 153 }