1 /**
2 Button for touch screen devices for gameplay use.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.touchscreenbutton;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.node2d;
25 import godot.canvasitem;
26 import godot.node;
27 import godot.inputevent;
28 import godot.bitmap;
29 import godot.shape2d;
30 import godot.texture;
31 /**
32 Button for touch screen devices for gameplay use.
33 
34 TouchScreenButton allows you to create on-screen buttons for touch devices. It's intended for gameplay use, such as a unit you have to touch to move. Unlike $(D Button), TouchScreenButton supports multitouch out of the box. Several TouchScreenButtons can be pressed at the same time with touch input.
35 This node inherits from $(D Node2D). Unlike with $(D Control) nodes, you cannot set anchors on it. If you want to create menus or user interfaces, you may want to use $(D Button) nodes instead. To make button nodes react to touch events, you can enable the Emulate Mouse option in the Project Settings.
36 You can configure TouchScreenButton to be visible only on touch devices, helping you develop your game both for desktop and mobile devices.
37 */
38 @GodotBaseClass struct TouchScreenButton
39 {
40 	package(godot) enum string _GODOT_internal_name = "TouchScreenButton";
41 public:
42 @nogc nothrow:
43 	union { /** */ godot_object _godot_object; /** */ Node2D _GODOT_base; }
44 	alias _GODOT_base this;
45 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
46 	package(godot) __gshared bool _classBindingInitialized = false;
47 	package(godot) static struct GDNativeClassBinding
48 	{
49 		__gshared:
50 		@GodotName("_input") GodotMethod!(void, InputEvent) _input;
51 		@GodotName("get_action") GodotMethod!(String) getAction;
52 		@GodotName("get_bitmask") GodotMethod!(BitMap) getBitmask;
53 		@GodotName("get_shape") GodotMethod!(Shape2D) getShape;
54 		@GodotName("get_texture") GodotMethod!(Texture) getTexture;
55 		@GodotName("get_texture_pressed") GodotMethod!(Texture) getTexturePressed;
56 		@GodotName("get_visibility_mode") GodotMethod!(TouchScreenButton.VisibilityMode) getVisibilityMode;
57 		@GodotName("is_passby_press_enabled") GodotMethod!(bool) isPassbyPressEnabled;
58 		@GodotName("is_pressed") GodotMethod!(bool) isPressed;
59 		@GodotName("is_shape_centered") GodotMethod!(bool) isShapeCentered;
60 		@GodotName("is_shape_visible") GodotMethod!(bool) isShapeVisible;
61 		@GodotName("set_action") GodotMethod!(void, String) setAction;
62 		@GodotName("set_bitmask") GodotMethod!(void, BitMap) setBitmask;
63 		@GodotName("set_passby_press") GodotMethod!(void, bool) setPassbyPress;
64 		@GodotName("set_shape") GodotMethod!(void, Shape2D) setShape;
65 		@GodotName("set_shape_centered") GodotMethod!(void, bool) setShapeCentered;
66 		@GodotName("set_shape_visible") GodotMethod!(void, bool) setShapeVisible;
67 		@GodotName("set_texture") GodotMethod!(void, Texture) setTexture;
68 		@GodotName("set_texture_pressed") GodotMethod!(void, Texture) setTexturePressed;
69 		@GodotName("set_visibility_mode") GodotMethod!(void, long) setVisibilityMode;
70 	}
71 	/// 
72 	pragma(inline, true) bool opEquals(in TouchScreenButton other) const
73 	{ return _godot_object.ptr is other._godot_object.ptr; }
74 	/// 
75 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
76 	{ _godot_object.ptr = n; return null; }
77 	/// 
78 	pragma(inline, true) bool opEquals(typeof(null) n) const
79 	{ return _godot_object.ptr is n; }
80 	/// 
81 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
82 	mixin baseCasts;
83 	/// Construct a new instance of TouchScreenButton.
84 	/// Note: use `memnew!TouchScreenButton` instead.
85 	static TouchScreenButton _new()
86 	{
87 		static godot_class_constructor constructor;
88 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TouchScreenButton");
89 		if(constructor is null) return typeof(this).init;
90 		return cast(TouchScreenButton)(constructor());
91 	}
92 	@disable new(size_t s);
93 	/// 
94 	enum VisibilityMode : int
95 	{
96 		/**
97 		Always visible.
98 		*/
99 		visibilityAlways = 0,
100 		/**
101 		Visible on touch screens only.
102 		*/
103 		visibilityTouchscreenOnly = 1,
104 	}
105 	/// 
106 	enum Constants : int
107 	{
108 		visibilityAlways = 0,
109 		visibilityTouchscreenOnly = 1,
110 	}
111 	/**
112 	
113 	*/
114 	void _input(InputEvent arg0)
115 	{
116 		Array _GODOT_args = Array.make();
117 		_GODOT_args.append(arg0);
118 		String _GODOT_method_name = String("_input");
119 		this.callv(_GODOT_method_name, _GODOT_args);
120 	}
121 	/**
122 	
123 	*/
124 	String getAction() const
125 	{
126 		checkClassBinding!(typeof(this))();
127 		return ptrcall!(String)(GDNativeClassBinding.getAction, _godot_object);
128 	}
129 	/**
130 	
131 	*/
132 	Ref!BitMap getBitmask() const
133 	{
134 		checkClassBinding!(typeof(this))();
135 		return ptrcall!(BitMap)(GDNativeClassBinding.getBitmask, _godot_object);
136 	}
137 	/**
138 	
139 	*/
140 	Ref!Shape2D getShape() const
141 	{
142 		checkClassBinding!(typeof(this))();
143 		return ptrcall!(Shape2D)(GDNativeClassBinding.getShape, _godot_object);
144 	}
145 	/**
146 	
147 	*/
148 	Ref!Texture getTexture() const
149 	{
150 		checkClassBinding!(typeof(this))();
151 		return ptrcall!(Texture)(GDNativeClassBinding.getTexture, _godot_object);
152 	}
153 	/**
154 	
155 	*/
156 	Ref!Texture getTexturePressed() const
157 	{
158 		checkClassBinding!(typeof(this))();
159 		return ptrcall!(Texture)(GDNativeClassBinding.getTexturePressed, _godot_object);
160 	}
161 	/**
162 	
163 	*/
164 	TouchScreenButton.VisibilityMode getVisibilityMode() const
165 	{
166 		checkClassBinding!(typeof(this))();
167 		return ptrcall!(TouchScreenButton.VisibilityMode)(GDNativeClassBinding.getVisibilityMode, _godot_object);
168 	}
169 	/**
170 	
171 	*/
172 	bool isPassbyPressEnabled() const
173 	{
174 		checkClassBinding!(typeof(this))();
175 		return ptrcall!(bool)(GDNativeClassBinding.isPassbyPressEnabled, _godot_object);
176 	}
177 	/**
178 	Returns `true` if this button is currently pressed.
179 	*/
180 	bool isPressed() const
181 	{
182 		checkClassBinding!(typeof(this))();
183 		return ptrcall!(bool)(GDNativeClassBinding.isPressed, _godot_object);
184 	}
185 	/**
186 	
187 	*/
188 	bool isShapeCentered() const
189 	{
190 		checkClassBinding!(typeof(this))();
191 		return ptrcall!(bool)(GDNativeClassBinding.isShapeCentered, _godot_object);
192 	}
193 	/**
194 	
195 	*/
196 	bool isShapeVisible() const
197 	{
198 		checkClassBinding!(typeof(this))();
199 		return ptrcall!(bool)(GDNativeClassBinding.isShapeVisible, _godot_object);
200 	}
201 	/**
202 	
203 	*/
204 	void setAction(in String action)
205 	{
206 		checkClassBinding!(typeof(this))();
207 		ptrcall!(void)(GDNativeClassBinding.setAction, _godot_object, action);
208 	}
209 	/**
210 	
211 	*/
212 	void setBitmask(BitMap bitmask)
213 	{
214 		checkClassBinding!(typeof(this))();
215 		ptrcall!(void)(GDNativeClassBinding.setBitmask, _godot_object, bitmask);
216 	}
217 	/**
218 	
219 	*/
220 	void setPassbyPress(in bool enabled)
221 	{
222 		checkClassBinding!(typeof(this))();
223 		ptrcall!(void)(GDNativeClassBinding.setPassbyPress, _godot_object, enabled);
224 	}
225 	/**
226 	
227 	*/
228 	void setShape(Shape2D shape)
229 	{
230 		checkClassBinding!(typeof(this))();
231 		ptrcall!(void)(GDNativeClassBinding.setShape, _godot_object, shape);
232 	}
233 	/**
234 	
235 	*/
236 	void setShapeCentered(in bool _bool)
237 	{
238 		checkClassBinding!(typeof(this))();
239 		ptrcall!(void)(GDNativeClassBinding.setShapeCentered, _godot_object, _bool);
240 	}
241 	/**
242 	
243 	*/
244 	void setShapeVisible(in bool _bool)
245 	{
246 		checkClassBinding!(typeof(this))();
247 		ptrcall!(void)(GDNativeClassBinding.setShapeVisible, _godot_object, _bool);
248 	}
249 	/**
250 	
251 	*/
252 	void setTexture(Texture texture)
253 	{
254 		checkClassBinding!(typeof(this))();
255 		ptrcall!(void)(GDNativeClassBinding.setTexture, _godot_object, texture);
256 	}
257 	/**
258 	
259 	*/
260 	void setTexturePressed(Texture texture_pressed)
261 	{
262 		checkClassBinding!(typeof(this))();
263 		ptrcall!(void)(GDNativeClassBinding.setTexturePressed, _godot_object, texture_pressed);
264 	}
265 	/**
266 	
267 	*/
268 	void setVisibilityMode(in long mode)
269 	{
270 		checkClassBinding!(typeof(this))();
271 		ptrcall!(void)(GDNativeClassBinding.setVisibilityMode, _godot_object, mode);
272 	}
273 	/**
274 	The button's action. Actions can be handled with $(D InputEventAction).
275 	*/
276 	@property String action()
277 	{
278 		return getAction();
279 	}
280 	/// ditto
281 	@property void action(String v)
282 	{
283 		setAction(v);
284 	}
285 	/**
286 	The button's bitmask.
287 	*/
288 	@property BitMap bitmask()
289 	{
290 		return getBitmask();
291 	}
292 	/// ditto
293 	@property void bitmask(BitMap v)
294 	{
295 		setBitmask(v);
296 	}
297 	/**
298 	The button's texture for the normal state.
299 	*/
300 	@property Texture normal()
301 	{
302 		return getTexture();
303 	}
304 	/// ditto
305 	@property void normal(Texture v)
306 	{
307 		setTexture(v);
308 	}
309 	/**
310 	If `true`, the $(D pressed) and $(D released) signals are emitted whenever a pressed finger goes in and out of the button, even if the pressure started outside the active area of the button.
311 	$(B Note:) this is a "pass-by" (not "bypass") press mode.
312 	*/
313 	@property bool passbyPress()
314 	{
315 		return isPassbyPressEnabled();
316 	}
317 	/// ditto
318 	@property void passbyPress(bool v)
319 	{
320 		setPassbyPress(v);
321 	}
322 	/**
323 	The button's texture for the pressed state.
324 	*/
325 	@property Texture pressed()
326 	{
327 		return getTexturePressed();
328 	}
329 	/// ditto
330 	@property void pressed(Texture v)
331 	{
332 		setTexturePressed(v);
333 	}
334 	/**
335 	The button's shape.
336 	*/
337 	@property Shape2D shape()
338 	{
339 		return getShape();
340 	}
341 	/// ditto
342 	@property void shape(Shape2D v)
343 	{
344 		setShape(v);
345 	}
346 	/**
347 	If `true`, the button's shape is centered in the provided texture. If no texture is used, this property has no effect.
348 	*/
349 	@property bool shapeCentered()
350 	{
351 		return isShapeCentered();
352 	}
353 	/// ditto
354 	@property void shapeCentered(bool v)
355 	{
356 		setShapeCentered(v);
357 	}
358 	/**
359 	If `true`, the button's shape is visible.
360 	*/
361 	@property bool shapeVisible()
362 	{
363 		return isShapeVisible();
364 	}
365 	/// ditto
366 	@property void shapeVisible(bool v)
367 	{
368 		setShapeVisible(v);
369 	}
370 	/**
371 	The button's visibility mode. See $(D visibilitymode) for possible values.
372 	*/
373 	@property TouchScreenButton.VisibilityMode visibilityMode()
374 	{
375 		return getVisibilityMode();
376 	}
377 	/// ditto
378 	@property void visibilityMode(long v)
379 	{
380 		setVisibilityMode(v);
381 	}
382 }