PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
window_events.h
1#pragma once
2
3#include "pixelbullet/core/event.h"
4
5#include <sstream>
6#include <string>
7
8namespace pixelbullet::window
9{
10class WindowResizeEvent : public core::Event
11{
12public:
13 WindowResizeEvent(unsigned int width, unsigned int height)
14 : width_(width)
15 , height_(height)
16 {
17 }
18
19 [[nodiscard]] unsigned int width() const
20 {
21 return width_;
22 }
23 [[nodiscard]] unsigned int height() const
24 {
25 return height_;
26 }
27
28 [[nodiscard]] std::string to_string() const override
29 {
30 std::stringstream ss;
31 ss << "WindowResizeEvent: " << width_ << ", " << height_;
32 return ss.str();
33 }
34
35 PB_EVENT_TYPE(WindowResize)
36 PB_EVENT_CATEGORIES(core::EventCategory::Window)
37
38private:
39 unsigned int width_, height_;
40};
41
42class WindowCloseEvent : public core::Event
43{
44public:
45 WindowCloseEvent() = default;
46
47 PB_EVENT_TYPE(WindowClose)
48 PB_EVENT_CATEGORIES(core::EventCategory::Window)
49};
50
51class WindowFocusEvent : public core::Event
52{
53public:
54 WindowFocusEvent() = default;
55
56 PB_EVENT_TYPE(WindowFocus)
57 PB_EVENT_CATEGORIES(core::EventCategory::Window)
58};
59
60class WindowLostFocusEvent : public core::Event
61{
62public:
63 WindowLostFocusEvent() = default;
64
65 PB_EVENT_TYPE(WindowLostFocus)
66 PB_EVENT_CATEGORIES(core::EventCategory::Window)
67};
68
69class WindowMovedEvent : public core::Event
70{
71public:
72 WindowMovedEvent(int x, int y)
73 : x_(x)
74 , y_(y)
75 {
76 }
77
78 [[nodiscard]] int x() const
79 {
80 return x_;
81 }
82 [[nodiscard]] int y() const
83 {
84 return y_;
85 }
86
87 [[nodiscard]] std::string to_string() const override
88 {
89 std::stringstream ss;
90 ss << "WindowMovedEvent: " << x_ << ", " << y_;
91 return ss.str();
92 }
93
94 PB_EVENT_TYPE(WindowMoved)
95 PB_EVENT_CATEGORIES(core::EventCategory::Window)
96
97private:
98 int x_ = 0;
99 int y_ = 0;
100};
101
102} // namespace pixelbullet::window
Definition event.h:107