1 /** 2 Input event type for mouse motion 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.inputeventmousemotion; 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.inputeventmouse; 25 import godot.inputeventwithmodifiers; 26 /** 27 Input event type for mouse motion events. 28 29 Contains mouse and pen motion information. Supports relative, absolute positions and speed. See $(D Node._input). 30 $(B Note:) By default, this event is only emitted once per frame rendered at most. If you need more precise input reporting, call $(D Input.setUseAccumulatedInput) with `false` to make events emitted as often as possible. If you use InputEventMouseMotion to draw lines, consider implementing $(D url=https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm)Bresenham's line algorithm$(D /url) as well to avoid visible gaps in lines if the user is moving the mouse quickly. 31 */ 32 @GodotBaseClass struct InputEventMouseMotion 33 { 34 package(godot) enum string _GODOT_internal_name = "InputEventMouseMotion"; 35 public: 36 @nogc nothrow: 37 union { /** */ godot_object _godot_object; /** */ InputEventMouse _GODOT_base; } 38 alias _GODOT_base this; 39 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 40 package(godot) __gshared bool _classBindingInitialized = false; 41 package(godot) static struct GDNativeClassBinding 42 { 43 __gshared: 44 @GodotName("get_pressure") GodotMethod!(double) getPressure; 45 @GodotName("get_relative") GodotMethod!(Vector2) getRelative; 46 @GodotName("get_speed") GodotMethod!(Vector2) getSpeed; 47 @GodotName("get_tilt") GodotMethod!(Vector2) getTilt; 48 @GodotName("set_pressure") GodotMethod!(void, double) setPressure; 49 @GodotName("set_relative") GodotMethod!(void, Vector2) setRelative; 50 @GodotName("set_speed") GodotMethod!(void, Vector2) setSpeed; 51 @GodotName("set_tilt") GodotMethod!(void, Vector2) setTilt; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in InputEventMouseMotion other) const 55 { return _godot_object.ptr is other._godot_object.ptr; } 56 /// 57 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 58 { _godot_object.ptr = n; return null; } 59 /// 60 pragma(inline, true) bool opEquals(typeof(null) n) const 61 { return _godot_object.ptr is n; } 62 /// 63 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 64 mixin baseCasts; 65 /// Construct a new instance of InputEventMouseMotion. 66 /// Note: use `memnew!InputEventMouseMotion` instead. 67 static InputEventMouseMotion _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InputEventMouseMotion"); 71 if(constructor is null) return typeof(this).init; 72 return cast(InputEventMouseMotion)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 77 */ 78 double getPressure() const 79 { 80 checkClassBinding!(typeof(this))(); 81 return ptrcall!(double)(GDNativeClassBinding.getPressure, _godot_object); 82 } 83 /** 84 85 */ 86 Vector2 getRelative() const 87 { 88 checkClassBinding!(typeof(this))(); 89 return ptrcall!(Vector2)(GDNativeClassBinding.getRelative, _godot_object); 90 } 91 /** 92 93 */ 94 Vector2 getSpeed() const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(Vector2)(GDNativeClassBinding.getSpeed, _godot_object); 98 } 99 /** 100 101 */ 102 Vector2 getTilt() const 103 { 104 checkClassBinding!(typeof(this))(); 105 return ptrcall!(Vector2)(GDNativeClassBinding.getTilt, _godot_object); 106 } 107 /** 108 109 */ 110 void setPressure(in double pressure) 111 { 112 checkClassBinding!(typeof(this))(); 113 ptrcall!(void)(GDNativeClassBinding.setPressure, _godot_object, pressure); 114 } 115 /** 116 117 */ 118 void setRelative(in Vector2 relative) 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(GDNativeClassBinding.setRelative, _godot_object, relative); 122 } 123 /** 124 125 */ 126 void setSpeed(in Vector2 speed) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(GDNativeClassBinding.setSpeed, _godot_object, speed); 130 } 131 /** 132 133 */ 134 void setTilt(in Vector2 tilt) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(GDNativeClassBinding.setTilt, _godot_object, tilt); 138 } 139 /** 140 Represents the pressure the user puts on the pen. Ranges from `0.0` to `1.0`. 141 */ 142 @property double pressure() 143 { 144 return getPressure(); 145 } 146 /// ditto 147 @property void pressure(double v) 148 { 149 setPressure(v); 150 } 151 /** 152 The mouse position relative to the previous position (position at the last frame). 153 $(B Note:) Since $(D InputEventMouseMotion) is only emitted when the mouse moves, the last event won't have a relative position of `Vector2(0, 0)` when the user stops moving the mouse. 154 */ 155 @property Vector2 relative() 156 { 157 return getRelative(); 158 } 159 /// ditto 160 @property void relative(Vector2 v) 161 { 162 setRelative(v); 163 } 164 /** 165 The mouse speed in pixels per second. 166 */ 167 @property Vector2 speed() 168 { 169 return getSpeed(); 170 } 171 /// ditto 172 @property void speed(Vector2 v) 173 { 174 setSpeed(v); 175 } 176 /** 177 Represents the angles of tilt of the pen. Positive X-coordinate value indicates a tilt to the right. Positive Y-coordinate value indicates a tilt toward the user. Ranges from `-1.0` to `1.0` for both axes. 178 */ 179 @property Vector2 tilt() 180 { 181 return getTilt(); 182 } 183 /// ditto 184 @property void tilt(Vector2 v) 185 { 186 setTilt(v); 187 } 188 }