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.EventControllerScroll; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.EventController; 31 private import gtk.Widget; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 public import gtkc.gtktypes; 35 private import std.algorithm; 36 37 38 /** 39 * #GtkEventControllerScroll is an event controller meant to handle 40 * scroll events from mice and touchpads. It is capable of handling 41 * both discrete and continuous scroll events, abstracting them both 42 * on the #GtkEventControllerScroll::scroll signal (deltas in the 43 * discrete case are multiples of 1). 44 * 45 * In the case of continuous scroll events, #GtkEventControllerScroll 46 * encloses all #GtkEventControllerScroll::scroll events between two 47 * #GtkEventControllerScroll::scroll-begin and #GtkEventControllerScroll::scroll-end 48 * signals. 49 * 50 * The behavior of the event controller can be modified by the 51 * flags given at creation time, or modified at a later point through 52 * gtk_event_controller_scroll_set_flags() (e.g. because the scrolling 53 * conditions of the widget changed). 54 * 55 * The controller can be set up to emit motion for either/both vertical 56 * and horizontal scroll events through #GTK_EVENT_CONTROLLER_SCROLL_VERTICAL, 57 * #GTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL and #GTK_EVENT_CONTROLLER_SCROLL_BOTH. 58 * If any axis is disabled, the respective #GtkEventControllerScroll::scroll 59 * delta will be 0. Vertical scroll events will be translated to horizontal 60 * motion for the devices incapable of horizontal scrolling. 61 * 62 * The event controller can also be forced to emit discrete events on all devices 63 * through #GTK_EVENT_CONTROLLER_SCROLL_DISCRETE. This can be used to implement 64 * discrete actions triggered through scroll events (e.g. switching across 65 * combobox options). 66 * 67 * The #GTK_EVENT_CONTROLLER_SCROLL_KINETIC flag toggles the emission of the 68 * #GtkEventControllerScroll::decelerate signal, emitted at the end of scrolling 69 * with two X/Y velocity arguments that are consistent with the motion that 70 * was received. 71 * 72 * This object was added in 3.24. 73 */ 74 public class EventControllerScroll : EventController 75 { 76 /** the main Gtk struct */ 77 protected GtkEventControllerScroll* gtkEventControllerScroll; 78 79 /** Get the main Gtk struct */ 80 public GtkEventControllerScroll* getEventControllerScrollStruct(bool transferOwnership = false) 81 { 82 if (transferOwnership) 83 ownedRef = false; 84 return gtkEventControllerScroll; 85 } 86 87 /** the main Gtk struct as a void* */ 88 protected override void* getStruct() 89 { 90 return cast(void*)gtkEventControllerScroll; 91 } 92 93 /** 94 * Sets our main struct and passes it to the parent class. 95 */ 96 public this (GtkEventControllerScroll* gtkEventControllerScroll, bool ownedRef = false) 97 { 98 this.gtkEventControllerScroll = gtkEventControllerScroll; 99 super(cast(GtkEventController*)gtkEventControllerScroll, ownedRef); 100 } 101 102 103 /** */ 104 public static GType getType() 105 { 106 return gtk_event_controller_scroll_get_type(); 107 } 108 109 /** 110 * Creates a new event controller that will handle scroll events 111 * for the given @widget. 112 * 113 * Params: 114 * widget = a #GtkWidget 115 * flags = behavior flags 116 * 117 * Returns: a new #GtkEventControllerScroll 118 * 119 * Since: 3.24 120 * 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this(Widget widget, GtkEventControllerScrollFlags flags) 124 { 125 auto p = gtk_event_controller_scroll_new((widget is null) ? null : widget.getWidgetStruct(), flags); 126 127 if(p is null) 128 { 129 throw new ConstructionException("null returned by new"); 130 } 131 132 this(cast(GtkEventControllerScroll*) p, true); 133 } 134 135 /** 136 * Gets the flags conditioning the scroll controller behavior. 137 * 138 * Returns: the controller flags. 139 * 140 * Since: 3.24 141 */ 142 public GtkEventControllerScrollFlags getFlags() 143 { 144 return gtk_event_controller_scroll_get_flags(gtkEventControllerScroll); 145 } 146 147 /** 148 * Sets the flags conditioning scroll controller behavior. 149 * 150 * Params: 151 * flags = behavior flags 152 * 153 * Since: 3.24 154 */ 155 public void setFlags(GtkEventControllerScrollFlags flags) 156 { 157 gtk_event_controller_scroll_set_flags(gtkEventControllerScroll, flags); 158 } 159 160 /** 161 * Emitted after scroll is finished if the #GTK_EVENT_CONTROLLER_SCROLL_KINETIC 162 * flag is set. @vel_x and @vel_y express the initial velocity that was 163 * imprinted by the scroll events. @vel_x and @vel_y are expressed in 164 * pixels/ms. 165 * 166 * Params: 167 * velX = X velocity 168 * velY = Y velocity 169 */ 170 gulong addOnDecelerate(void delegate(double, double, EventControllerScroll) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 171 { 172 return Signals.connect(this, "decelerate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 173 } 174 175 /** 176 * Signals that the widget should scroll by the 177 * amount specified by @dx and @dy. 178 * 179 * Params: 180 * dx = X delta 181 * dy = Y delta 182 */ 183 gulong addOnScroll(void delegate(double, double, EventControllerScroll) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 184 { 185 return Signals.connect(this, "scroll", dlg, connectFlags ^ ConnectFlags.SWAPPED); 186 } 187 188 /** 189 * Signals that a new scrolling operation has begun. It will 190 * only be emitted on devices capable of it. 191 */ 192 gulong addOnScrollBegin(void delegate(EventControllerScroll) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 193 { 194 return Signals.connect(this, "scroll-begin", dlg, connectFlags ^ ConnectFlags.SWAPPED); 195 } 196 197 /** 198 * Signals that a new scrolling operation has finished. It will 199 * only be emitted on devices capable of it. 200 */ 201 gulong addOnScrollEnd(void delegate(EventControllerScroll) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 202 { 203 return Signals.connect(this, "scroll-end", dlg, connectFlags ^ ConnectFlags.SWAPPED); 204 } 205 }