1 /** 2 Button for touch screen devices. 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.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.node2d; 24 import godot.texture; 25 import godot.bitmap; 26 import godot.shape2d; 27 import godot.inputevent; 28 import godot.canvasitem; 29 import godot.node; 30 /** 31 Button for touch screen devices. 32 33 You can set it to be visible on all screens, or only on touch devices. 34 */ 35 @GodotBaseClass struct TouchScreenButton 36 { 37 enum string _GODOT_internal_name = "TouchScreenButton"; 38 public: 39 @nogc nothrow: 40 union { godot_object _godot_object; Node2D _GODOT_base; } 41 alias _GODOT_base this; 42 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 43 package(godot) __gshared bool _classBindingInitialized = false; 44 package(godot) static struct _classBinding 45 { 46 __gshared: 47 @GodotName("set_texture") GodotMethod!(void, Texture) setTexture; 48 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 49 @GodotName("set_texture_pressed") GodotMethod!(void, Texture) setTexturePressed; 50 @GodotName("get_texture_pressed") GodotMethod!(Texture) getTexturePressed; 51 @GodotName("set_bitmask") GodotMethod!(void, BitMap) setBitmask; 52 @GodotName("get_bitmask") GodotMethod!(BitMap) getBitmask; 53 @GodotName("set_shape") GodotMethod!(void, Shape2D) setShape; 54 @GodotName("get_shape") GodotMethod!(Shape2D) getShape; 55 @GodotName("set_shape_centered") GodotMethod!(void, bool) setShapeCentered; 56 @GodotName("is_shape_centered") GodotMethod!(bool) isShapeCentered; 57 @GodotName("set_shape_visible") GodotMethod!(void, bool) setShapeVisible; 58 @GodotName("is_shape_visible") GodotMethod!(bool) isShapeVisible; 59 @GodotName("set_action") GodotMethod!(void, String) setAction; 60 @GodotName("get_action") GodotMethod!(String) getAction; 61 @GodotName("set_visibility_mode") GodotMethod!(void, long) setVisibilityMode; 62 @GodotName("get_visibility_mode") GodotMethod!(TouchScreenButton.VisibilityMode) getVisibilityMode; 63 @GodotName("set_passby_press") GodotMethod!(void, bool) setPassbyPress; 64 @GodotName("is_passby_press_enabled") GodotMethod!(bool) isPassbyPressEnabled; 65 @GodotName("is_pressed") GodotMethod!(bool) isPressed; 66 @GodotName("_input") GodotMethod!(void, InputEvent) _input; 67 } 68 bool opEquals(in TouchScreenButton other) const { return _godot_object.ptr is other._godot_object.ptr; } 69 TouchScreenButton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 70 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 71 mixin baseCasts; 72 static TouchScreenButton _new() 73 { 74 static godot_class_constructor constructor; 75 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TouchScreenButton"); 76 if(constructor is null) return typeof(this).init; 77 return cast(TouchScreenButton)(constructor()); 78 } 79 @disable new(size_t s); 80 /// 81 enum VisibilityMode : int 82 { 83 /** 84 Always visible. 85 */ 86 visibilityAlways = 0, 87 /** 88 Visible on touch screens only. 89 */ 90 visibilityTouchscreenOnly = 1, 91 } 92 /// 93 enum Constants : int 94 { 95 visibilityAlways = 0, 96 visibilityTouchscreenOnly = 1, 97 } 98 /** 99 100 */ 101 void setTexture(Texture texture) 102 { 103 checkClassBinding!(typeof(this))(); 104 ptrcall!(void)(_classBinding.setTexture, _godot_object, texture); 105 } 106 /** 107 108 */ 109 Ref!Texture getTexture() const 110 { 111 checkClassBinding!(typeof(this))(); 112 return ptrcall!(Texture)(_classBinding.getTexture, _godot_object); 113 } 114 /** 115 116 */ 117 void setTexturePressed(Texture texture_pressed) 118 { 119 checkClassBinding!(typeof(this))(); 120 ptrcall!(void)(_classBinding.setTexturePressed, _godot_object, texture_pressed); 121 } 122 /** 123 124 */ 125 Ref!Texture getTexturePressed() const 126 { 127 checkClassBinding!(typeof(this))(); 128 return ptrcall!(Texture)(_classBinding.getTexturePressed, _godot_object); 129 } 130 /** 131 132 */ 133 void setBitmask(BitMap bitmask) 134 { 135 checkClassBinding!(typeof(this))(); 136 ptrcall!(void)(_classBinding.setBitmask, _godot_object, bitmask); 137 } 138 /** 139 140 */ 141 Ref!BitMap getBitmask() const 142 { 143 checkClassBinding!(typeof(this))(); 144 return ptrcall!(BitMap)(_classBinding.getBitmask, _godot_object); 145 } 146 /** 147 148 */ 149 void setShape(Shape2D shape) 150 { 151 checkClassBinding!(typeof(this))(); 152 ptrcall!(void)(_classBinding.setShape, _godot_object, shape); 153 } 154 /** 155 156 */ 157 Ref!Shape2D getShape() const 158 { 159 checkClassBinding!(typeof(this))(); 160 return ptrcall!(Shape2D)(_classBinding.getShape, _godot_object); 161 } 162 /** 163 164 */ 165 void setShapeCentered(in bool _bool) 166 { 167 checkClassBinding!(typeof(this))(); 168 ptrcall!(void)(_classBinding.setShapeCentered, _godot_object, _bool); 169 } 170 /** 171 172 */ 173 bool isShapeCentered() const 174 { 175 checkClassBinding!(typeof(this))(); 176 return ptrcall!(bool)(_classBinding.isShapeCentered, _godot_object); 177 } 178 /** 179 180 */ 181 void setShapeVisible(in bool _bool) 182 { 183 checkClassBinding!(typeof(this))(); 184 ptrcall!(void)(_classBinding.setShapeVisible, _godot_object, _bool); 185 } 186 /** 187 188 */ 189 bool isShapeVisible() const 190 { 191 checkClassBinding!(typeof(this))(); 192 return ptrcall!(bool)(_classBinding.isShapeVisible, _godot_object); 193 } 194 /** 195 196 */ 197 void setAction(StringArg0)(in StringArg0 action) 198 { 199 checkClassBinding!(typeof(this))(); 200 ptrcall!(void)(_classBinding.setAction, _godot_object, action); 201 } 202 /** 203 204 */ 205 String getAction() const 206 { 207 checkClassBinding!(typeof(this))(); 208 return ptrcall!(String)(_classBinding.getAction, _godot_object); 209 } 210 /** 211 212 */ 213 void setVisibilityMode(in long mode) 214 { 215 checkClassBinding!(typeof(this))(); 216 ptrcall!(void)(_classBinding.setVisibilityMode, _godot_object, mode); 217 } 218 /** 219 220 */ 221 TouchScreenButton.VisibilityMode getVisibilityMode() const 222 { 223 checkClassBinding!(typeof(this))(); 224 return ptrcall!(TouchScreenButton.VisibilityMode)(_classBinding.getVisibilityMode, _godot_object); 225 } 226 /** 227 228 */ 229 void setPassbyPress(in bool enabled) 230 { 231 checkClassBinding!(typeof(this))(); 232 ptrcall!(void)(_classBinding.setPassbyPress, _godot_object, enabled); 233 } 234 /** 235 236 */ 237 bool isPassbyPressEnabled() const 238 { 239 checkClassBinding!(typeof(this))(); 240 return ptrcall!(bool)(_classBinding.isPassbyPressEnabled, _godot_object); 241 } 242 /** 243 Returns `true` if this button is currently pressed. 244 */ 245 bool isPressed() const 246 { 247 checkClassBinding!(typeof(this))(); 248 return ptrcall!(bool)(_classBinding.isPressed, _godot_object); 249 } 250 /** 251 252 */ 253 void _input(InputEvent arg0) 254 { 255 Array _GODOT_args = Array.empty_array; 256 _GODOT_args.append(arg0); 257 String _GODOT_method_name = String("_input"); 258 this.callv(_GODOT_method_name, _GODOT_args); 259 } 260 /** 261 The button's texture for the normal state. 262 */ 263 @property Texture normal() 264 { 265 return getTexture(); 266 } 267 /// ditto 268 @property void normal(Texture v) 269 { 270 setTexture(v); 271 } 272 /** 273 The button's texture for the pressed state. 274 */ 275 @property Texture pressed() 276 { 277 return getTexturePressed(); 278 } 279 /// ditto 280 @property void pressed(Texture v) 281 { 282 setTexturePressed(v); 283 } 284 /** 285 The button's bitmask. 286 */ 287 @property BitMap bitmask() 288 { 289 return getBitmask(); 290 } 291 /// ditto 292 @property void bitmask(BitMap v) 293 { 294 setBitmask(v); 295 } 296 /** 297 The button's shape. 298 */ 299 @property Shape2D shape() 300 { 301 return getShape(); 302 } 303 /// ditto 304 @property void shape(Shape2D v) 305 { 306 setShape(v); 307 } 308 /** 309 If `true` the button's shape is centered. 310 */ 311 @property bool shapeCentered() 312 { 313 return isShapeCentered(); 314 } 315 /// ditto 316 @property void shapeCentered(bool v) 317 { 318 setShapeCentered(v); 319 } 320 /** 321 If `true` the button's shape is visible. 322 */ 323 @property bool shapeVisible() 324 { 325 return isShapeVisible(); 326 } 327 /// ditto 328 @property void shapeVisible(bool v) 329 { 330 setShapeVisible(v); 331 } 332 /** 333 If `true` passby presses are enabled. 334 */ 335 @property bool passbyPress() 336 { 337 return isPassbyPressEnabled(); 338 } 339 /// ditto 340 @property void passbyPress(bool v) 341 { 342 setPassbyPress(v); 343 } 344 /** 345 The button's action. Actions can be handled with $(D InputEventAction). 346 */ 347 @property String action() 348 { 349 return getAction(); 350 } 351 /// ditto 352 @property void action(String v) 353 { 354 setAction(v); 355 } 356 /** 357 The button's visibility mode. See `VISIBILITY_*` constants. 358 */ 359 @property TouchScreenButton.VisibilityMode visibilityMode() 360 { 361 return getVisibilityMode(); 362 } 363 /// ditto 364 @property void visibilityMode(long v) 365 { 366 setVisibilityMode(v); 367 } 368 }