3#include <Core/CoreDLL.h>
4#include <Foundation/Math/Rect.h>
5#include <Foundation/Math/Size.h>
6#include <Foundation/Math/Vec2.h>
7#include <Foundation/Strings/String.h>
8#include <Foundation/Types/UniquePtr.h>
15#if PL_ENABLED(PL_SUPPORTS_GLFW)
16# include <Core/System/Implementation/glfw/InputDevice_glfw.h>
17#elif PL_ENABLED(PL_PLATFORM_WINDOWS_DESKTOP)
18# include <Core/System/Implementation/Win/InputDevice_win32.h>
19#elif PL_ENABLED(PL_PLATFORM_WINDOWS_UWP)
20# include <Core/System/Implementation/uwp/InputDevice_uwp.h>
21#elif PL_ENABLED(PL_PLATFORM_ANDROID)
22# include <Core/System/Implementation/android/InputDevice_android.h>
24# include <Core/System/Implementation/null/InputDevice_null.h>
32#if PL_ENABLED(PL_SUPPORTS_GLFW)
36 typedef struct GLFWwindow GLFWwindow;
39# if PL_ENABLED(PL_PLATFORM_WINDOWS_DESKTOP)
40# include <Foundation/Basics/Platform/Win/MinWindows.h>
41using plWindowHandle = plMinWindows::HWND;
42using plWindowInternalHandle = GLFWwindow*;
43# define INVALID_WINDOW_HANDLE_VALUE (plWindowHandle)(0)
44# define INVALID_INTERNAL_WINDOW_HANDLE_VALUE nullptr
45# elif PL_ENABLED(PL_PLATFORM_LINUX)
49 typedef struct xcb_connection_t xcb_connection_t;
52struct plXcbWindowHandle
54 xcb_connection_t* m_pConnection;
70 GLFWwindow* glfwWindow;
71 plXcbWindowHandle xcbWindow;
74 bool operator==(plWindowHandle& rhs)
79 if (type == Type::GLFW)
81 return glfwWindow == rhs.glfwWindow;
86 return xcbWindow.m_Window == rhs.xcbWindow.m_Window;
91using plWindowInternalHandle = plWindowHandle;
92# define INVALID_WINDOW_HANDLE_VALUE \
95using plWindowHandle = GLFWwindow*;
96using plWindowInternalHandle = GLFWwindow*;
97# define INVALID_WINDOW_HANDLE_VALUE (GLFWwindow*)(0)
100#elif PL_ENABLED(PL_PLATFORM_WINDOWS_DESKTOP)
102# include <Foundation/Basics/Platform/Win/MinWindows.h>
103using plWindowHandle = plMinWindows::HWND;
104using plWindowInternalHandle = plWindowHandle;
105# define INVALID_WINDOW_HANDLE_VALUE (plWindowHandle)(0)
107#elif PL_ENABLED(PL_PLATFORM_WINDOWS_UWP)
109using plWindowHandle = IUnknown*;
110using plWindowInternalHandle = plWindowHandle;
111# define INVALID_WINDOW_HANDLE_VALUE nullptr
113#elif PL_ENABLED(PL_PLATFORM_ANDROID)
116using plWindowHandle = ANativeWindow*;
117using plWindowInternalHandle = plWindowHandle;
118# define INVALID_WINDOW_HANDLE_VALUE nullptr
122using plWindowHandle =
void*;
123using plWindowInternalHandle = plWindowHandle;
124# define INVALID_WINDOW_HANDLE_VALUE nullptr
128#ifndef INVALID_INTERNAL_WINDOW_HANDLE_VALUE
129# define INVALID_INTERNAL_WINDOW_HANDLE_VALUE INVALID_WINDOW_HANDLE_VALUE
138 virtual plSizeU32 GetClientAreaSize()
const = 0;
139 virtual plWindowHandle GetNativeWindowHandle()
const = 0;
151 virtual void ProcessWindowMessages() = 0;
153 virtual void AddReference() = 0;
154 virtual void RemoveReference() = 0;
160 using StorageType = plUInt8;
166 FullscreenBorderlessNativeResolution,
168 FullscreenFixedResolution,
171 Default = WindowFixedResolution
175 static constexpr bool IsFullscreen(
Enum e) {
return e == FullscreenBorderlessNativeResolution || e == FullscreenFixedResolution; }
188 plResult AdjustWindowSizeAndPosition();
211 plInt8 m_iMonitor = -1;
221 plUInt8 m_uiWindowNumber = 0;
225 bool m_bClipMouseCursor =
true;
229 bool m_bShowMouseCursor =
false;
232 bool m_bSetForegroundOnInit =
true;
235 bool m_bCenterWindowOnDisplay =
true;
262 virtual plWindowHandle GetNativeWindowHandle()
const override;
269 if (bOnlyProperFullscreenMode)
275 virtual bool IsVisible()
const override {
return m_bVisible; }
277 virtual void AddReference()
override { m_iReferenceCount.Increment(); }
278 virtual void RemoveReference()
override { m_iReferenceCount.Decrement(); }
284 virtual void ProcessWindowMessages()
override;
303 m_CreationDescription = creationDescription;
322 virtual void OnResize(
const plSizeU32& newWindowSize);
325 virtual void OnWindowMove(
const plInt32 iNewPosX,
const plInt32 iNewPosY) {}
337#if PL_ENABLED(PL_PLATFORM_WINDOWS)
346 virtual void OnWindowMessage(plMinWindows::HWND hWnd, plMinWindows::UINT msg, plMinWindows::WPARAM wparam, plMinWindows::LPARAM lparam);
348#elif PL_ENABLED(PL_PLATFORM_OSX)
350#elif PL_ENABLED(PL_PLATFORM_LINUX)
352#elif PL_ENABLED(PL_PLATFORM_ANDROID)
355# error "Missing code for plWindow on this platform!"
364 static plUInt8 GetNextUnusedWindowNumber();
372 bool m_bInitialized =
false;
373 bool m_bVisible =
true;
377 mutable plWindowInternalHandle m_hWindowHandle = plWindowInternalHandle();
379#if PL_ENABLED(PL_SUPPORTS_GLFW)
380 static void IconifyCallback(GLFWwindow* window,
int iconified);
381 static void SizeCallback(GLFWwindow* window,
int width,
int height);
382 static void PositionCallback(GLFWwindow* window,
int xpos,
int ypos);
383 static void CloseCallback(GLFWwindow* window);
384 static void FocusCallback(GLFWwindow* window,
int focused);
385 static void KeyCallback(GLFWwindow* window,
int key,
int scancode,
int action,
int mods);
386 static void CharacterCallback(GLFWwindow* window,
unsigned int codepoint);
387 static void CursorPositionCallback(GLFWwindow* window,
double xpos,
double ypos);
388 static void MouseButtonCallback(GLFWwindow* window,
int button,
int action,
int mods);
389 static void ScrollCallback(GLFWwindow* window,
double xoffset,
double yoffset);
393 static plUInt8 s_uiNextUnusedWindowNumber;
Represents a single 'object' in a DDL document, e.g. either a custom type or a primitives list.
Definition OpenDdlReader.h:11
An OpenDDL reader parses an entire DDL document and creates an in-memory representation of the docume...
Definition OpenDdlReader.h:118
The base class for OpenDDL writers.
Definition OpenDdlWriter.h:13
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
Base class of all window classes that have a client area and a native window handle.
Definition Window.h:134
virtual bool IsFullscreenWindow(bool bOnlyProperFullscreenMode=false) const =0
Whether the window is a fullscreen window or should be one - some platforms may enforce this via the ...
virtual bool IsVisible() const =0
Whether the window can potentially be seen by the user. Windows that are minimized or hidden are not ...
A simple abstraction for platform specific window creation.
Definition Window.h:244
virtual bool IsFullscreenWindow(bool bOnlyProperFullscreenMode=false) const override
Returns whether the window covers an entire monitor.
Definition Window.h:267
virtual void OnClickClose()
Called when the close button of the window is clicked. Does nothing by default.
Definition Window.h:334
const plWindowCreationDesc & GetCreationDescription() const
Returns the currently active description struct.
Definition Window.h:256
virtual void OnWindowMove(const plInt32 iNewPosX, const plInt32 iNewPosY)
Called when the window position is changed. Not possible on all OSes.
Definition Window.h:325
virtual plSizeU32 GetClientAreaSize() const override
Returns the size of the client area / ie. the window resolution.
Definition Window.h:259
plResult Initialize(const plWindowCreationDesc &creationDescription)
Creates a new platform specific window with the given settings.
Definition Window.h:301
virtual void OnVisibleChange(bool bVisible)
Called when the window gets focus or loses focus.
Definition Window.h:331
virtual void OnFocus(bool bHasFocus)
Called when the window gets focus or loses focus.
Definition Window.h:328
plWindowCreationDesc m_CreationDescription
Definition Window.h:369
virtual bool IsVisible() const override
Whether the window can potentially be seen by the user. Windows that are minimized or hidden are not ...
Definition Window.h:275
plStandardInputDevice * GetInputDevice() const
Returns the input device that is attached to this window and typically provides mouse / keyboard inpu...
Definition Window.h:359
bool IsInitialized() const
Gets if the window is up and running.
Definition Window.h:308
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Parameters for creating a window, such as position and resolution.
Definition Window.h:180
plEnum< plWindowMode > m_WindowMode
Defines how the window size is determined.
Definition Window.h:207
Determines how the position and resolution for a window are picked.
Definition Window.h:159
static constexpr bool IsFullscreen(Enum e)
Returns whether the window covers an entire monitor. This includes borderless windows and proper full...
Definition Window.h:175
Enum
Definition Window.h:163
@ WindowResizable
The resolution and size are what the user picked and will not be changed. Allows window resizing by t...
Definition Window.h:165
@ FullscreenFixedResolution
Definition Window.h:168
@ WindowFixedResolution
The resolution and size are what the user picked and will not be changed. The window will not be resi...
Definition Window.h:164