diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 1cda9d63d..3560dfcc9 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -30,7 +30,7 @@ namespace Nz { public: RenderWindow() = default; - RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); + RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); RenderWindow(const RenderWindow&) = delete; RenderWindow(RenderWindow&&) = delete; ///TODO @@ -39,7 +39,7 @@ namespace Nz bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const; bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); + bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); void Display(); diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 9390b7991..2c162cd7d 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -7,6 +7,8 @@ #ifndef NAZARA_ENUMS_UTILITY_HPP #define NAZARA_ENUMS_UTILITY_HPP +#include + namespace Nz { enum AnimationType @@ -430,20 +432,29 @@ namespace Nz WindowEventType_Max = WindowEventType_TextEntered }; - enum WindowStyleFlags + enum WindowStyle { - WindowStyle_None = 0x0, ///< Window has no border nor titlebar. - WindowStyle_Fullscreen = 0x1, ///< At the window creation, the OS tries to set it in fullscreen. + WindowStyle_None, ///< Window has no border nor titlebar. + WindowStyle_Fullscreen, ///< At the window creation, the OS tries to set it in fullscreen. - WindowStyle_Closable = 0x2, ///< Allows the window to be closed by a button in the titlebar, generating a Quit event. - WindowStyle_Resizable = 0x4, ///< Allows the window to be resized by dragging its corners or by a button of the titlebar. - WindowStyle_Titlebar = 0x8, ///< Adds a titlebar to the window, this option is automatically enabled if buttons of the titlebar are enabled. + WindowStyle_Closable, ///< Allows the window to be closed by a button in the titlebar, generating a Quit event. + WindowStyle_Resizable, ///< Allows the window to be resized by dragging its corners or by a button of the titlebar. + WindowStyle_Titlebar, ///< Adds a titlebar to the window, this option is automatically enabled if buttons of the titlebar are enabled. - WindowStyle_Threaded = 0x10, ///< Runs the window into a thread, allowing the application to keep updating while resizing/dragging the window. + WindowStyle_Threaded, ///< Runs the window into a thread, allowing the application to keep updating while resizing/dragging the window. - WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar, - WindowStyle_Max = WindowStyle_Threaded*2-1 + WindowStyle_Max = WindowStyle_Threaded }; + + template<> + struct EnableFlagsOperators + { + static constexpr bool value = true; + }; + + using WindowStyleFlags = Flags; + + constexpr WindowStyleFlags WindowStyle_Default = WindowStyle_Closable | WindowStyle_Resizable | WindowStyle_Titlebar; } #endif // NAZARA_ENUMS_UTILITY_HPP diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index 0f7688a81..5ecabd8dd 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -36,7 +36,7 @@ namespace Nz public: inline Window(); - inline Window(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); + inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default); inline Window(WindowHandle handle); Window(const Window&) = delete; inline Window(Window&& window) noexcept; @@ -44,7 +44,7 @@ namespace Nz inline void Close(); - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); + bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default); bool Create(WindowHandle handle); void Destroy(); @@ -62,7 +62,7 @@ namespace Nz unsigned int GetHeight() const; Vector2i GetPosition() const; Vector2ui GetSize() const; - UInt32 GetStyle() const; + WindowStyleFlags GetStyle() const; String GetTitle() const; unsigned int GetWidth() const; diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index cceefebef..0fce86ba6 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -21,7 +21,7 @@ namespace Nz { } - inline Window::Window(VideoMode mode, const String& title, UInt32 style) : + inline Window::Window(VideoMode mode, const String& title, WindowStyleFlags style) : Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index a9effa622..61131d9f1 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -15,7 +15,7 @@ namespace Nz { - RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style, const ContextParameters& parameters) : + RenderWindow::RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style, const ContextParameters& parameters) : RenderTarget(), Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -121,7 +121,7 @@ namespace Nz return true; } - bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style, const ContextParameters& parameters) + bool RenderWindow::Create(VideoMode mode, const String& title, WindowStyleFlags style, const ContextParameters& parameters) { m_parameters = parameters; return Window::Create(mode, title, style); diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 558a44ddb..e32caf95f 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -81,7 +81,7 @@ namespace Nz { } - bool WindowImpl::Create(const VideoMode& mode, const String& title, UInt32 style) + bool WindowImpl::Create(const VideoMode& mode, const String& title, WindowStyleFlags style) { bool async = (style & WindowStyle_Threaded) != 0; bool fullscreen = (style & WindowStyle_Fullscreen) != 0; @@ -259,7 +259,7 @@ namespace Nz return m_size; } - UInt32 WindowImpl::GetStyle() const + WindowStyleFlags WindowImpl::GetStyle() const { return m_style; } diff --git a/src/Nazara/Utility/Win32/WindowImpl.hpp b/src/Nazara/Utility/Win32/WindowImpl.hpp index bb718738a..ae08e42ad 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.hpp +++ b/src/Nazara/Utility/Win32/WindowImpl.hpp @@ -37,7 +37,7 @@ namespace Nz WindowImpl(WindowImpl&&) = delete; ///TODO? ~WindowImpl() = default; - bool Create(const VideoMode& mode, const String& title, UInt32 style); + bool Create(const VideoMode& mode, const String& title, WindowStyleFlags style); bool Create(WindowHandle handle); void Destroy(); @@ -49,7 +49,7 @@ namespace Nz unsigned int GetHeight() const; Vector2i GetPosition() const; Vector2ui GetSize() const; - UInt32 GetStyle() const; + WindowStyleFlags GetStyle() const; String GetTitle() const; unsigned int GetWidth() const; @@ -93,7 +93,7 @@ namespace Nz HCURSOR m_cursor; HWND m_handle; LONG_PTR m_callback; - UInt32 m_style; + WindowStyleFlags m_style; Vector2i m_maxSize; Vector2i m_minSize; Vector2i m_mousePos; diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 803badb85..73c91168a 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -34,7 +34,7 @@ namespace Nz Destroy(); } - bool Window::Create(VideoMode mode, const String& title, UInt32 style) + bool Window::Create(VideoMode mode, const String& title, WindowStyleFlags style) { // Si la fenêtre est déjà ouverte, nous conservons sa position bool opened = IsOpen(); @@ -228,7 +228,7 @@ namespace Nz return m_impl->GetSize(); } - UInt32 Window::GetStyle() const + WindowStyleFlags Window::GetStyle() const { #if NAZARA_UTILITY_SAFE if (!m_impl)