TGUI  1.6.1
Loading...
Searching...
No Matches
BackendGLFW.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_BACKEND_GLFW_HPP
26#define TGUI_BACKEND_GLFW_HPP
27
28#include <TGUI/Backend/Window/GLFW/BackendGuiGLFW.hpp>
29
30#if !TGUI_BUILD_AS_CXX_MODULE
31 #include <TGUI/Backend/Window/Backend.hpp>
32#endif
33
34#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
35 #include <unordered_map>
36 #include <map>
37#endif
38
40
41#if !TGUI_BUILD_AS_CXX_MODULE
42 using GLFWwindow = struct GLFWwindow;
43 using GLFWcursor = struct GLFWcursor;
44#endif
45
47
48TGUI_MODULE_EXPORT namespace tgui
49{
50 class TGUI_API BackendGLFW : public Backend
51 {
52 public:
53
57 ~BackendGLFW() override;
58
67 void setGuiWindow(BackendGui* gui, GLFWwindow* window);
68
73 void detatchGui(BackendGui* gui) override;
74
83 void setMouseCursorStyle(Cursor::Type type, const std::uint8_t* pixels, Vector2u size, Vector2u hotspot) override;
84
91
98 void setMouseCursor(BackendGui* gui, Cursor::Type type) override;
99
107 TGUI_DEPRECATED("Use gui.isKeyboardModifierPressed(modifierKey) instead") TGUI_NODISCARD bool isKeyboardModifierPressed(Event::KeyModifier modifierKey) override;
108
114 void setClipboard(const String& contents) override;
115
121 TGUI_NODISCARD String getClipboard() const override;
122
124 private:
125
127 // Helper function to create a system cursor
129 TGUI_NODISCARD GLFWcursor* createSystemCursor(Cursor::Type type);
130
132 // Helper function to update the mouse cursors on all attached guis
134 void updateMouseCursorStyle(Cursor::Type type, GLFWcursor* cursor);
135
137 // Helper function to update the mouse cursor on a window
139 void updateShownMouseCursor(GLFWwindow* window, Cursor::Type type);
140
142 // Returns a window attached to any gui, for when a function needs access to some window
144 TGUI_NODISCARD GLFWwindow* getAnyWindow() const;
145
147 private:
148
149 struct GuiResources
150 {
151 GLFWwindow* window = nullptr;
152 Cursor::Type mouseCursor = Cursor::Type::Arrow;
153 };
154
155 std::unordered_map<const BackendGui*, GuiResources> m_guiResources;
156 std::unordered_map<Cursor::Type, GLFWcursor*> m_mouseCursors;
157 };
158
160}
161
163
164#endif // TGUI_BACKEND_GLFW_HPP
Definition BackendGLFW.hpp:51
void setMouseCursor(BackendGui *gui, Cursor::Type type) override
Changes the mouse cursor when the mouse is on top of the window to which the gui is attached.
void setMouseCursorStyle(Cursor::Type type, const std::uint8_t *pixels, Vector2u size, Vector2u hotspot) override
Changes the look of a certain mouse cursor by using a bitmap.
void detatchGui(BackendGui *gui) override
Informs the backend that a gui object is being destroyed.
~BackendGLFW() override
Destructor.
void resetMouseCursorStyle(Cursor::Type type) override
Changes the look of a certain mouse cursor back to the system theme.
void setGuiWindow(BackendGui *gui, GLFWwindow *window)
Informs the backend which window belongs to the gui.
Base class for the Gui.
Definition BackendGui.hpp:47
Base class for the backend.
Definition Backend.hpp:87
Class that allows the cursor to be changed.
Definition Cursor.hpp:43
Type
List of available cursors.
Definition Cursor.hpp:50
Wrapper class to store strings.
Definition String.hpp:96
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
Definition Event.hpp:38