Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 98a0f22

Browse files
committed
Add function for cursor
Fix compilation
1 parent 9f6b140 commit 98a0f22

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

module/includes/window/Window.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace sw
4040
static Vector2i m_position;
4141
static std::string m_title;
4242
static unsigned int m_flags;
43+
static bool m_cursorHidden;
4344

4445
static void resizeCallBack(GLFWwindow* window, int width, int height);
4546
static void input_callback(GLFWwindow* window, int key, int scancode, int action, [[maybe_unused]] int mods);
@@ -72,10 +73,12 @@ namespace sw
7273
static void SetMaxSize(sw::Vector2i size);
7374
static void SetSize(sw::Vector2i size);
7475
static void SetSize(int with, int height);
76+
static void SetVisibleCursor(bool visible);
7577

7678
static bool IsFullScreen();
7779
static bool IsReady();
7880
static bool IsOpen();
81+
static bool IsCursorVisible();
7982

8083
static Vector2i GetSize();
8184
static std::string GetTitle();

module/sources/window/Window.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
#include "Window.hpp"
1010
#include "Monitors.hpp"
1111
#include "utils/Inputs.hpp"
12-
#include "Buffer.hpp"
1312

1413
SW_GRAPH_MODULE_EXPORT bool sw::Window::m_ready(false);
1514
SW_GRAPH_MODULE_EXPORT GLFWwindow* sw::Window::m_window(nullptr);
1615
SW_GRAPH_MODULE_EXPORT bool sw::Window::m_fullScreen(false);
1716
SW_GRAPH_MODULE_EXPORT sw::Vector2i sw::Window::m_size({1920, 1080});
17+
SW_GRAPH_MODULE_EXPORT sw::Vector2i sw::Window::m_maxSize({1920, 1080});
1818
SW_GRAPH_MODULE_EXPORT sw::Vector2i sw::Window::m_position({0, 0});
1919
SW_GRAPH_MODULE_EXPORT std::string sw::Window::m_title("ShipWreck Engine");
2020
SW_GRAPH_MODULE_EXPORT unsigned int sw::Window::m_flags(0);
21+
SW_GRAPH_MODULE_EXPORT bool sw::Window::m_cursorHidden(true);
2122

2223
sw::Window::Window()
2324
= default;
@@ -141,7 +142,7 @@ void sw::Window::SetMinSize(sw::Vector2i size)
141142
void sw::Window::SetMaxSize(int with, int height)
142143
{
143144
m_maxSize.x = with;
144-
m_maxSize.y = height
145+
m_maxSize.y = height;
145146
}
146147

147148
void sw::Window::SetMaxSize(sw::Vector2i size)
@@ -159,6 +160,12 @@ void sw::Window::SetSize(sw::Vector2i size)
159160
SetMinSize(size.x, size.y);
160161
}
161162

163+
void sw::Window::SetVisibleCursor(bool visible)
164+
{
165+
m_cursorHidden = visible;
166+
glfwSetInputMode(m_window, GLFW_CURSOR, (visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN));
167+
}
168+
162169
bool sw::Window::HasFlag(sw::WindowFlags flags)
163170
{
164171
return (m_flags & flags);
@@ -192,4 +199,9 @@ bool sw::Window::IsOpen()
192199
bool sw::Window::IsReady()
193200
{
194201
return (m_ready);
202+
}
203+
204+
bool sw::Window::IsCursorVisible()
205+
{
206+
return (m_cursorHidden);
195207
}

0 commit comments

Comments
 (0)