cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
IWindow.hpp
Go to the documentation of this file.
1///
2/// @file IWindow.hpp
3/// @brief This file contains the Window interface
4/// @namespace cae
5///
6
7#pragma once
8
11
13
14namespace cae
15{
16
17 ///
18 /// @struct WindowSize
19 /// @brief Struct for window size
20 /// @namespace cae
21 ///
23 {
24 uint16_t width;
25 uint16_t height;
26 };
27
28 ///
29 /// @struct NativeWindowHandle
30 /// @brief Struct for native window handle
31 /// @namespace cae
32 ///
34 {
35 void *window;
36 void *display;
37 };
38
39 ///
40 /// @enum WindowEventType
41 /// @brief Enum for window event types
42 /// @namespace cae
43 ///
44 enum class WindowEventType : uint8_t
45 {
46 KeyDown,
47 KeyUp,
52 Resize,
53 Focus,
54 Close
55 };
56
57 ///
58 /// @struct WindowEvent
59 /// @brief Struct for window events
60 /// @namespace cae
61 ///
63 {
65
66 union
67 {
68 struct
69 {
71 } key;
72 struct
73 {
74 int x, y;
76 struct
77 {
80 struct
81 {
82 float x, y;
84 struct
85 {
86 uint16_t w, h;
88 };
89 };
90
91 ///
92 /// @interface IWindow
93 /// @brief Interface for window
94 /// @namespace cae
95 ///
96 class IWindow : public utl::IPlugin
97 {
98
99 public:
100 ~IWindow() override = default;
101
102 ///
103 /// @param name Window name
104 /// @param size Window size
105 /// @return True if the window was created successfully
106 /// @brief Create a window with the given name and size
107 ///
108 virtual bool create(const std::string &name, WindowSize size) = 0;
109
110 ///
111 /// @brief Close the window
112 ///
113 virtual void close() = 0;
114
115 ///
116 /// @return Native window handle
117 /// @brief Get the native window handle
118 ///
120
121 ///
122 /// @return Current window size
123 /// @brief Get the current window size
124 ///
125 virtual WindowSize getWindowSize() const = 0;
126
127 ///
128 /// @param path Path to the icon image
129 /// @return True if the icon was set successfully
130 /// @brief Set the window icon from the given image path
131 ///
132 virtual void setIcon(const std::string &path) const = 0;
133
134 ///
135 /// @return True if the window should close
136 /// @brief Check if the window should close
137 ///
138 virtual bool shouldClose() const = 0;
139
140 ///
141 /// @brief Poll window events
142 ///
143 virtual void pollEvents() = 0;
144
145 ///
146 /// @param outEvent Event to be filled
147 /// @return True if an event was polled
148 /// @brief Poll window events into outEvent
149 ///
150 virtual bool pollEvent(WindowEvent &outEvent) = 0;
151
152 ///
153 /// @return True if the window was resized
154 /// @brief Check if the window was resized
155 ///
156 virtual bool wasResized() const = 0;
157
158 ///
159 /// @brief Reset the resized flag
160 ///
161 virtual void resetResizedFlag() = 0;
162
163 // virtual bool isFullScreen() const = 0;
164 // virtual void setFullScreen(bool fullScreen) const = 0;
165
166 }; // interface IWindow
167
168} // namespace cae
This file contains the plugin interface.
This file contains the keyboard keys.
This file contains the mouse keys.
Abstract class for window.
Definition IWindow.hpp:97
virtual void close()=0
Close the window.
virtual WindowSize getWindowSize() const =0
Get the current window size.
virtual void setIcon(const std::string &path) const =0
Set the window icon from the given image path.
virtual bool shouldClose() const =0
Check if the window should close.
~IWindow() override=default
virtual bool wasResized() const =0
Check if the window was resized.
virtual void resetResizedFlag()=0
Reset the resized flag.
virtual NativeWindowHandle getNativeHandle() const =0
Get the native window handle.
virtual void pollEvents()=0
Poll window events.
virtual bool pollEvent(WindowEvent &outEvent)=0
Poll window events into outEvent.
virtual bool create(const std::string &name, WindowSize size)=0
Create a window with the given name and size.
Interface for plugins.
Definition IPlugin.hpp:46
WindowEventType
Enum for window event types.
Definition IWindow.hpp:45
KeyCode
Definition Keyboard.hpp:23
MouseButton
Definition Mouse.hpp:14
Struct for native window handle.
Definition IWindow.hpp:34
Struct for window events.
Definition IWindow.hpp:63
struct cae::WindowEvent::@0::@6 resize
WindowEventType type
Definition IWindow.hpp:64
MouseButton button
Definition IWindow.hpp:78
struct cae::WindowEvent::@0::@4 mouseButton
struct cae::WindowEvent::@0::@5 scroll
struct cae::WindowEvent::@0::@3 mouseMove
Struct for window size.
Definition IWindow.hpp:23
uint16_t height
Definition IWindow.hpp:25
uint16_t width
Definition IWindow.hpp:24