Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
MouseEvent.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef ENIGMA_MOUSE_EVENT_H
3 #define ENIGMA_MOUSE_EVENT_H
4 
5 #include <Core/Core.hpp>
6 #include <Core/Types.hpp>
8 #include <sstream>
9 
10 #include "Event.hpp"
11 
13 
15 class MouseMotionEvent : public Event {
16  public:
17  MouseMotionEvent(const float x, const float y)
18  : m_mouseX(x),
19  m_mouseY(y) {}
20 
21  float GetX() const noexcept { return m_mouseX; }
22  float GetY() const noexcept { return m_mouseY; }
23 
24  std::string ToString() const override {
25  std::ostringstream ss;
26  ss << "MouseMotionEvent: " << m_mouseX << ", " << m_mouseY;
27  return ss.str();
28  }
29 
32 
33  private:
34  float m_mouseX, m_mouseY;
35 };
36 
38 class MouseWheelEvent : public Event {
39  public:
40  MouseWheelEvent(const float xOffset, const float yOffset)
41  : m_XOffset(xOffset),
42  m_YOffset(yOffset) {}
43 
44  float GetXOffset() const noexcept { return m_XOffset; }
45  float GetYOffset() const noexcept { return m_YOffset; }
46 
47  std::string ToString() const override {
48  std::ostringstream ss;
49  ss << "MouseWheelEvent: " << m_XOffset << ", " << m_YOffset;
50  return ss.str();
51  }
52 
55 
56  private:
57  float m_XOffset, m_YOffset;
58 };
59 
61 class MouseButtonEvent : public Event {
62  public:
63  MouseCode GetMouseButton() const noexcept { return m_button; }
64 
65  virtual std::string ToString() const override = 0;
66 
68  protected:
69  explicit MouseButtonEvent(const MouseCode button)
70  : m_button(button) {}
71 
73 };
74 
77  public:
78  explicit MouseButtonPressedEvent(const MouseCode button)
79  : MouseButtonEvent(button) {}
80 
81  std::string ToString() const override {
82  std::ostringstream ss;
83  ss << "MouseButtonPressedEvent: " << m_button;
84  return ss.str();
85  }
86 
88 };
89 
92  public:
93  explicit MouseButtonReleasedEvent(const MouseCode button)
94  : MouseButtonEvent(button) {}
95 
96  std::string ToString() const override {
97  std::ostringstream ss;
98  ss << "MouseButtonReleasedEvent: " << m_button;
99  return ss.str();
100  }
101 
103 };
104 
106 
107 #endif // !ENIGMA_MOUSE_EVENT_H
#define EVENT_CLASS_TYPE(type)
Definition: Event.hpp:59
#define EVENT_CLASS_CATEGORY(category)
Definition: Event.hpp:63
@ MOUSE_BUTTON_PRESSED
@ MOUSE_BUTTON_RELEASED
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition: Macros.hpp:13
#define NS_ENIGMA_END
Definition: Macros.hpp:14
MouseCode
Definition: MouseCodes.hpp:11
Definition: Event.hpp:66
MouseButtonEvent(const MouseCode button)
Definition: MouseEvent.hpp:69
virtual std::string ToString() const override=0
MouseCode GetMouseButton() const noexcept
Definition: MouseEvent.hpp:63
MouseCode m_button
Definition: MouseEvent.hpp:72
MouseButtonPressedEvent(const MouseCode button)
Definition: MouseEvent.hpp:78
std::string ToString() const override
Definition: MouseEvent.hpp:81
std::string ToString() const override
Definition: MouseEvent.hpp:96
MouseButtonReleasedEvent(const MouseCode button)
Definition: MouseEvent.hpp:93
float GetY() const noexcept
Definition: MouseEvent.hpp:22
MouseMotionEvent(const float x, const float y)
Definition: MouseEvent.hpp:17
std::string ToString() const override
Definition: MouseEvent.hpp:24
float GetX() const noexcept
Definition: MouseEvent.hpp:21
float GetYOffset() const noexcept
Definition: MouseEvent.hpp:45
float GetXOffset() const noexcept
Definition: MouseEvent.hpp:44
std::string ToString() const override
Definition: MouseEvent.hpp:47
MouseWheelEvent(const float xOffset, const float yOffset)
Definition: MouseEvent.hpp:40