1 /** 2 Base input event type for mouse events. 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.inputeventmouse; 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.inputeventwithmodifiers; 23 import godot.inputevent; 24 import godot.resource; 25 import godot.reference; 26 /** 27 Base input event type for mouse events. 28 29 Stores general mouse events information. 30 */ 31 @GodotBaseClass struct InputEventMouse 32 { 33 enum string _GODOT_internal_name = "InputEventMouse"; 34 public: 35 @nogc nothrow: 36 union { godot_object _godot_object; InputEventWithModifiers _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct _classBinding 41 { 42 __gshared: 43 @GodotName("set_button_mask") GodotMethod!(void, long) setButtonMask; 44 @GodotName("get_button_mask") GodotMethod!(long) getButtonMask; 45 @GodotName("set_position") GodotMethod!(void, Vector2) setPosition; 46 @GodotName("get_position") GodotMethod!(Vector2) getPosition; 47 @GodotName("set_global_position") GodotMethod!(void, Vector2) setGlobalPosition; 48 @GodotName("get_global_position") GodotMethod!(Vector2) getGlobalPosition; 49 } 50 bool opEquals(in InputEventMouse other) const { return _godot_object.ptr is other._godot_object.ptr; } 51 InputEventMouse opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 52 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 53 mixin baseCasts; 54 static InputEventMouse _new() 55 { 56 static godot_class_constructor constructor; 57 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InputEventMouse"); 58 if(constructor is null) return typeof(this).init; 59 return cast(InputEventMouse)(constructor()); 60 } 61 @disable new(size_t s); 62 /** 63 64 */ 65 void setButtonMask(in long button_mask) 66 { 67 checkClassBinding!(typeof(this))(); 68 ptrcall!(void)(_classBinding.setButtonMask, _godot_object, button_mask); 69 } 70 /** 71 72 */ 73 long getButtonMask() const 74 { 75 checkClassBinding!(typeof(this))(); 76 return ptrcall!(long)(_classBinding.getButtonMask, _godot_object); 77 } 78 /** 79 80 */ 81 void setPosition(in Vector2 position) 82 { 83 checkClassBinding!(typeof(this))(); 84 ptrcall!(void)(_classBinding.setPosition, _godot_object, position); 85 } 86 /** 87 88 */ 89 Vector2 getPosition() const 90 { 91 checkClassBinding!(typeof(this))(); 92 return ptrcall!(Vector2)(_classBinding.getPosition, _godot_object); 93 } 94 /** 95 96 */ 97 void setGlobalPosition(in Vector2 global_position) 98 { 99 checkClassBinding!(typeof(this))(); 100 ptrcall!(void)(_classBinding.setGlobalPosition, _godot_object, global_position); 101 } 102 /** 103 104 */ 105 Vector2 getGlobalPosition() const 106 { 107 checkClassBinding!(typeof(this))(); 108 return ptrcall!(Vector2)(_classBinding.getGlobalPosition, _godot_object); 109 } 110 /** 111 Mouse button mask identifier, one of or a bitwise combination of the BUTTON_MASK_* constants in $(D @GlobalScope). 112 */ 113 @property long buttonMask() 114 { 115 return getButtonMask(); 116 } 117 /// ditto 118 @property void buttonMask(long v) 119 { 120 setButtonMask(v); 121 } 122 /** 123 Mouse local position relative to the $(D Viewport). If used in $(D Control._guiInput) the position is relative to the current $(D Control) which is under the mouse. 124 */ 125 @property Vector2 position() 126 { 127 return getPosition(); 128 } 129 /// ditto 130 @property void position(Vector2 v) 131 { 132 setPosition(v); 133 } 134 /** 135 Mouse position relative to the current $(D Viewport) when used in $(D Control._guiInput), otherwise is at 0,0. 136 */ 137 @property Vector2 globalPosition() 138 { 139 return getGlobalPosition(); 140 } 141 /// ditto 142 @property void globalPosition(Vector2 v) 143 { 144 setGlobalPosition(v); 145 } 146 }