Debian Codegraph @

include/imousetoolevent.h

raw
1 #pragma once
2
3 #include "icameraview.h"
4 #include "iorthoview.h"
5 #include "math/Vector2.h"
6
7 namespace ui
8 {
9
10 // Base class for a generic event to be handled by the MouseTool implementation
11 class MouseToolEvent
12 {
13 private:
14 // The device position, normalised within [-1..+1]
15 Vector2 _devicePosition;
16
17 // The device delta for tools using a frozen mouse pointer
18 Vector2 _deviceDelta;
19
20 IInteractiveView& _view;
21
22 public:
23 MouseToolEvent(IInteractiveView& view, const Vector2& devicePosition) :
24 _devicePosition(devicePosition),
25 _deviceDelta(0, 0),
26 _view(view)
27 {}
28
29 MouseToolEvent(IInteractiveView& view, const Vector2& devicePosition, const Vector2& delta) :
30 _devicePosition(devicePosition),
31 _deviceDelta(delta),
32 _view(view)
33 {}
34
35 virtual ~MouseToolEvent() {}
36
37 // Returns the mouse position in normalised device coordinates (x,y in [-1..+1])
38 const Vector2& getDevicePosition() const
39 {
40 return _devicePosition;
41 }
42
43 // Used by MouseMove events, this contains the delta
44 // in device coordinates since the last mousemove event
45 const Vector2& getDeviceDelta() const
46 {
47 return _deviceDelta;
48 }
49
50 IInteractiveView& getInteractiveView()
51 {
52 return _view;
53 }
54 };
55
56 class OrthoViewMouseToolEvent :
57 public MouseToolEvent
58 {
59 private:
60 IOrthoViewBase& _orthoView;
61
62 public:
63 OrthoViewMouseToolEvent(IOrthoViewBase& view, const Vector2& devicePosition) :
64 MouseToolEvent(view, devicePosition),
65 _orthoView(view)
66 {}
67
68 OrthoViewMouseToolEvent(IOrthoViewBase& view, const Vector2& devicePosition, const Vector2& delta) :
69 MouseToolEvent(view, devicePosition, delta),
70 _orthoView(view)
71 {}
72
73 virtual ~OrthoViewMouseToolEvent() {}
74
75 IOrthoViewBase& getOrthoView()
76 {
77 return _orthoView;
78 }
79 };
80
81 } // namespace