opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
mouse_event.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace osc
9{
10 // Represents an event related to a button press or motion of a mouse.
11 //
12 // Related: `MouseWheelEvent`.
13 class MouseEvent final : public Event {
14 public:
19
24
29
30 MouseInputSource input_source() const { return input_source_; }
31 MouseButton button() const { return button_; }
32
33 // Returns the relative delta vector of the mouse motion (i.e. how much the mouse
34 // moved since the previous `MouseEvent`) in screen space and device-independent
35 // pixels.
36 Vector2 delta() const { return relative_delta_; }
37
38 // Returns the position of the mouse cursor in screen space and device-independent
39 // pixels.
40 Vector2 position() const { return position_in_window_; }
41
42 private:
43 explicit MouseEvent(
47
49 input_source_{input_source},
50 button_{button}
51 {}
52
53 explicit MouseEvent(
57
59 relative_delta_{relative_delta},
60 position_in_window_{position_in_window},
61 input_source_{input_source}
62 {}
63
64 Vector2 relative_delta_;
65 Vector2 position_in_window_;
68 };
69}
Definition event.h:13
Event()=default
Definition mouse_event.h:13
static MouseEvent button_down(MouseInputSource source, MouseButton button)
Definition mouse_event.h:15
Vector2 delta() const
Definition mouse_event.h:36
static MouseEvent button_up(MouseInputSource source, MouseButton button)
Definition mouse_event.h:20
Vector2 position() const
Definition mouse_event.h:40
static MouseEvent motion(MouseInputSource source, Vector2 relative_delta, Vector2 position_in_window)
Definition mouse_event.h:25
MouseButton button() const
Definition mouse_event.h:31
MouseInputSource input_source() const
Definition mouse_event.h:30
Definition custom_decoration_generator.h:5
Vector< float, 2 > Vector2
Definition vector.h:636
MouseButton
Definition mouse_button.h:5
EventType
Definition event_type.h:7
MouseInputSource
Definition mouse_input_source.h:5
constexpr U to(T &&value)
Definition conversion.h:56