QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
WindowEvent.h
Go to the documentation of this file.
1#pragma once
2
7
9
10#include <spdlog/fmt/fmt.h>
11
12#include <cstdint>
13#include <string>
14
15namespace Quasar
16{
18 class WindowCloseEvent final : public EventOf<EventType::WindowClose, EventCategory::Window>
19 {
20 };
21
26 class WindowResizeEvent final : public EventOf<EventType::WindowResize, EventCategory::Window>
27 {
28 public:
30 WindowResizeEvent(std::uint32_t width, std::uint32_t height) : m_Width(width), m_Height(height) {}
31
33 std::uint32_t GetWidth() const { return m_Width; }
34
36 std::uint32_t GetHeight() const { return m_Height; }
37
39 std::string ToString() const override { return fmt::format("{}: {}x{}", GetName(), m_Width, m_Height); }
40
41 private:
42 std::uint32_t m_Width = 0;
43 std::uint32_t m_Height = 0;
44 };
45
47 class WindowFocusEvent final : public EventOf<EventType::WindowFocus, EventCategory::Window>
48 {
49 public:
52 explicit WindowFocusEvent(bool focused) : m_Focused(focused) {}
53
55 bool IsFocused() const { return m_Focused; }
56
58 std::string ToString() const override { return fmt::format("{}: {}", GetName(), m_Focused ? "gained" : "lost"); }
59
60 private:
61 bool m_Focused = false;
62 };
63
68 class WindowMinimizeEvent final : public EventOf<EventType::WindowMinimize, EventCategory::Window>
69 {
70 public:
73 explicit WindowMinimizeEvent(bool minimized) : m_Minimized(minimized) {}
74
76 bool IsMinimized() const { return m_Minimized; }
77
79 std::string ToString() const override { return fmt::format("{}: {}", GetName(), m_Minimized ? "minimized" : "restored"); }
80
81 private:
82 bool m_Minimized = false;
83 };
84}
Base class of all events, with their types and categories.
Base class of each event class, which gives the event its type and its categories.
Definition Event.h:148
const char * GetName() const
Returns the name of the type of the event, for example "KeyPressed".
Definition Event.h:112
Sent when the user asks to close the window, for example with the close button.
Definition WindowEvent.h:19
std::string ToString() const override
Returns the event with the change, for example "WindowFocus: gained".
Definition WindowEvent.h:58
WindowFocusEvent(bool focused)
Creates the event.
Definition WindowEvent.h:52
bool IsFocused() const
Returns true if the window gained the focus, false if it lost it.
Definition WindowEvent.h:55
WindowMinimizeEvent(bool minimized)
Creates the event.
Definition WindowEvent.h:73
bool IsMinimized() const
Returns true if the window was minimized, false if it was restored.
Definition WindowEvent.h:76
std::string ToString() const override
Returns the event with the change, for example "WindowMinimize: minimized".
Definition WindowEvent.h:79
std::uint32_t GetWidth() const
Returns the new width, in pixels.
Definition WindowEvent.h:33
std::string ToString() const override
Returns the event with its size, for example "WindowResize: 1280x720".
Definition WindowEvent.h:39
WindowResizeEvent(std::uint32_t width, std::uint32_t height)
Creates the event with the new size, in pixels.
Definition WindowEvent.h:30
std::uint32_t GetHeight() const
Returns the new height, in pixels.
Definition WindowEvent.h:36
Contains all the engine code.