diff --git a/modules/window/include/window/windows/window.hpp b/modules/window/include/window/windows/window.hpp index a2c9e27..6b62cb7 100644 --- a/modules/window/include/window/windows/window.hpp +++ b/modules/window/include/window/windows/window.hpp @@ -16,18 +16,23 @@ public: ~wWindow() override; + wWindow(wWindow &&) = delete; + + wWindow(const wWindow &) = delete; + + auto operator=(wWindow &&) -> wWindow & = delete; + + auto operator=(const wWindow &) -> wWindow & = delete; + void poll_events() override; void on_event(const Event &event) override; - void set_properties( - const WindowProperties &properties, - bool overrideVisibility = false - ) override; + void set_properties(const Properties &properties, bool overrideVisibility = false) override; void set_title(const std::string &title) override; - void set_size(const glm::uvec2 &size, bool additive = false) override; + void set_size(const math::uvec2 &size) override; void set_v_sync(bool vsync, bool toggle = false) override; @@ -39,13 +44,17 @@ public: } private: + void on_window_resize(const WindowResizedEvent &event); + + void bind_glfw_events(); + GLFWwindow *m_handle { nullptr }; std::function m_event_callback; - void on_window_resize(const WindowResizedEvent &event); + Properties m_properties {}; - void bind_glfw_events(); + bool b_Closed {}; }; } // namespace lt diff --git a/modules/window/src/windows/window.cpp b/modules/window/src/windows/window.cpp index c3f960a..1323fba 100644 --- a/modules/window/src/windows/window.cpp +++ b/modules/window/src/windows/window.cpp @@ -8,9 +8,7 @@ namespace lt { -Window::~Window() -{ -} +Window::~Window() = default; auto Window::create(const std::function &callback) -> Scope { @@ -20,17 +18,16 @@ auto Window::create(const std::function &callback) -> Scope callback) : m_event_callback(std::move(std::move(callback))) { - // init glfw - ensure(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'"); + ensure(glfwInit(), "Failed to initialize 'glfw'"); - // create window glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); + // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer) m_handle = glfwCreateWindow(1u, 1u, "", nullptr, nullptr); - ensure(m_handle, "wWindow::wWindow: failed to create 'GLFWwindow'"); + ensure(m_handle, "Failed to create 'GLFWwindow'"); glfwSetWindowUserPointer(m_handle, &m_event_callback); bind_glfw_events(); @@ -57,6 +54,8 @@ void wWindow::on_event(const Event &event) case EventType::WindowResized: on_window_resize(dynamic_cast(event)); break; + + default: break; } } @@ -65,8 +64,7 @@ void wWindow::on_window_resize(const WindowResizedEvent &event) m_properties.size = event.get_size(); } -void wWindow:: - set_properties(const WindowProperties &properties, bool overrideVisibility /* = false */) +void wWindow::set_properties(const Properties &properties, bool overrideVisibility /* = false */) { // save the visibility status and re-assign if 'overrideVisibility' is false auto visible = overrideVisibility ? properties.visible : m_properties.visible; @@ -87,17 +85,10 @@ void wWindow::set_title(const std::string &title) glfwSetWindowTitle(m_handle, title.c_str()); } -void wWindow::set_size(const glm::uvec2 &size, bool additive /* = false */) +void wWindow::set_size(const math::uvec2 &size) { - m_properties.size.x = size.x == 0u ? m_properties.size.x : - additive ? m_properties.size.x + size.x : - size.x; - m_properties.size.y = size.y == 0u ? m_properties.size.y : - additive ? m_properties.size.y + size.y : - size.y; - - - glfwSetWindowSize(m_handle, size.x, size.y); + m_properties.size = size; + glfwSetWindowSize(m_handle, static_cast(size.x), static_cast(size.y)); } void wWindow::set_v_sync(bool vsync, bool toggle /* = false */)