Berserk
EventWindow.hpp
Go to the documentation of this file.
1 /**********************************************************************************/
2 /* This file is part of Berserk Engine project */
3 /* https://github.com/EgorOrachyov/Berserk */
4 /**********************************************************************************/
5 /* MIT License */
6 /* */
7 /* Copyright (c) 2018 - 2021 Egor Orachyov */
8 /* */
9 /* Permission is hereby granted, free of charge, to any person obtaining a copy */
10 /* of this software and associated documentation files (the "Software"), to deal */
11 /* in the Software without restriction, including without limitation the rights */
12 /* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
13 /* copies of the Software, and to permit persons to whom the Software is */
14 /* furnished to do so, subject to the following conditions: */
15 /* */
16 /* The above copyright notice and this permission notice shall be included in all */
17 /* copies or substantial portions of the Software. */
18 /* */
19 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
20 /* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
21 /* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
22 /* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
23 /* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
24 /* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
25 /* SOFTWARE. */
26 /**********************************************************************************/
27 
28 #ifndef BERSERK_EVENTWINDOW_HPP
29 #define BERSERK_EVENTWINDOW_HPP
30 
31 #include <core/Config.hpp>
32 #include <core/event/Event.hpp>
33 #include <core/math/TVecN.hpp>
34 #include <core/templates/Ref.hpp>
35 #include <platform/Window.hpp>
36 
38 
48 class EventWindow final : public Event {
49 public:
51  enum class Type {
53  Resized = 0,
57  Moved,
61  FocusLost,
63  Minimized,
65  Maximized,
67  Restored,
73  Unknown
74  };
75 
76  BRK_API EventWindow() = default;
77  BRK_API ~EventWindow() override = default;
78 
80  BRK_API const EventType &GetEventType() const override;
82  BRK_API static const EventType &GetEventTypeStatic();
83 
84  BRK_API void SetWindow(Ref<Window> window);
85  BRK_API void SetWindowSize(const Size2i &size);
86  BRK_API void SetFramebufferSize(const Size2i &size);
87  BRK_API void SetPosition(const Point2i &position);
88  BRK_API void SetPixelRatio(const Vec2f &ratio);
89  BRK_API void SetFocus(bool focus);
90  BRK_API void SetType(Type type);
91 
92  BRK_API const Ref<Window> &GetWindow() const;
93  BRK_API const Size2i &GetWindowSize() const;
94  BRK_API const Size2i &GetFramebufferSize() const;
95  BRK_API const Point2i &GetPosition() const;
96  BRK_API const Vec2f &GetPixelRatio() const;
97  BRK_API bool GetFocus() const;
98  BRK_API Type GetType() const;
99 
100 private:
101  Ref<Window> mWindow;
102  Size2i mWindowSize{};
103  Size2i mFramebufferSize{};
104  Point2i mPosition{};
105  Vec2f mPixelRatio{};
106  bool mFocus = false;
107  Type mEventType = Type::Unknown;
108 };
109 
115 
116 #endif//BERSERK_EVENTWINDOW_HPP
#define BRK_NS_END
Definition: Config.hpp:48
#define BRK_API
Definition: Config.hpp:32
StringName based event type.
Event dispatched when window state changed.
Definition: EventWindow.hpp:48
BRK_API const Vec2f & GetPixelRatio() const
Definition: EventWindow.cpp:88
BRK_API void SetPixelRatio(const Vec2f &ratio)
Definition: EventWindow.cpp:60
BRK_API void SetFocus(bool focus)
Definition: EventWindow.cpp:64
BRK_API const Point2i & GetPosition() const
Definition: EventWindow.cpp:84
BRK_API void SetFramebufferSize(const Size2i &size)
Definition: EventWindow.cpp:52
BRK_API Type GetType() const
Definition: EventWindow.cpp:96
BRK_API ~EventWindow() override=default
BRK_API const Ref< Window > & GetWindow() const
Definition: EventWindow.cpp:72
BRK_API const Size2i & GetWindowSize() const
Definition: EventWindow.cpp:76
BRK_API void SetPosition(const Point2i &position)
Definition: EventWindow.cpp:56
BRK_API const Size2i & GetFramebufferSize() const
Definition: EventWindow.cpp:80
static BRK_API const EventType & GetEventTypeStatic()
Definition: EventWindow.cpp:38
BRK_API void SetWindow(Ref< Window > window)
Definition: EventWindow.cpp:43
BRK_API bool GetFocus() const
Definition: EventWindow.cpp:92
BRK_API void SetWindowSize(const Size2i &size)
Definition: EventWindow.cpp:48
BRK_API EventWindow()=default
BRK_API void SetType(Type type)
Definition: EventWindow.cpp:68
BRK_API const EventType & GetEventType() const override
Definition: EventWindow.cpp:34
Type
Definition: EventWindow.hpp:51
Base class for any engine event.
Definition: Event.hpp:56
Definition: GLDevice.cpp:46