Karma Engine
Loading...
Searching...
No Matches
MouseEvent.h
1#pragma once
2
3#include "krpch.h"
4
5#include "Event.h"
6
7namespace Karma
8{
9 class KARMA_API MouseMovedEvent : public Event
10 {
11 public:
12 MouseMovedEvent(float x, float y) : m_MouseX(x), m_MouseY(y)
13 {
14 }
15 inline float GetX() const { return m_MouseX; }
16 inline float GetY() const { return m_MouseY; }
17 std::string ToString() const override
18 {
19 std::stringstream ss;
20 ss << "MouseMovedEvent: " << m_MouseX << ", " << m_MouseY;
21 return ss.str();
22 }
23
24 EVENT_CLASS_TYPE(MouseMoved)
25 EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput)
26
27 private:
28 float m_MouseX, m_MouseY;
29 };
30
31 class KARMA_API MouseScrolledEvent : public Event
32 {
33 public:
34 MouseScrolledEvent(float xOffset, float yOffset) : m_XOffset(xOffset),
35 m_YOffset(yOffset)
36 {
37 }
38 inline float GetXOffset() const { return m_XOffset; }
39 inline float GetYOffset() const { return m_YOffset; }
40 std::string ToString() const override
41 {
42 std::stringstream ss;
43 ss << "MouseScrolledEvent: " << m_XOffset << ", " << m_YOffset;
44 return ss.str();
45 }
46
47 EVENT_CLASS_TYPE(MouseScrolled)
48 EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput)
49 private:
50 float m_XOffset, m_YOffset;
51 };
52
53 class KARMA_API MouseButtonEvent : public Event
54 {
55 public:
56 inline int GetMouseButton() const { return m_Button; }
57
58 EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput)
59 protected:
60 MouseButtonEvent(int button) : m_Button(button)
61 {
62 }
63 int m_Button;
64 };
65
67 {
68 public:
69 MouseButtonPressedEvent(int button) : MouseButtonEvent(button)
70 {
71 }
72 std::string ToString() const override
73 {
74 std::stringstream ss;
75 ss << "MouseButtonPressedEvent: " << m_Button;
76 return ss.str();
77 }
78
79 EVENT_CLASS_TYPE(MouseButtonPressed)
80 };
81
83 {
84 public:
85 MouseButtonReleasedEvent(int button) : MouseButtonEvent(button)
86 {
87 }
88 std::string ToString() const override
89 {
90 std::stringstream ss;
91 ss << "MouseButtonReleasedEvent: " << m_Button;
92 return ss.str();
93 }
94
95 EVENT_CLASS_TYPE(MouseButtonReleased)
96 };
97}
Definition Event.h:35
Definition MouseEvent.h:54
Definition MouseEvent.h:67
Definition MouseEvent.h:83
Definition MouseEvent.h:10
Definition MouseEvent.h:32