TGUI  1.6.1
Loading...
Searching...
No Matches
BackendGuiGLFW.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_GUI_GLFW_HPP
26#define TGUI_BACKEND_GUI_GLFW_HPP
27
28#include <TGUI/Config.hpp>
29#if !TGUI_BUILD_AS_CXX_MODULE
30 #include <TGUI/Backend/Window/BackendGui.hpp>
31 #include <TGUI/Optional.hpp>
32#endif
33
35
36#if !TGUI_BUILD_AS_CXX_MODULE
37 using GLFWwindow = struct GLFWwindow;
38#endif
39
41
42TGUI_IGNORE_DEPRECATED_WARNINGS_START // Required for VS2017 due to inheriting a function that we deprecated
43
44TGUI_MODULE_EXPORT namespace tgui
45{
47
48 class TGUI_API BackendGuiGLFW : public BackendGui
49 {
50 public:
51
58
63
69 bool windowFocusCallback(int focused);
70
77 bool sizeCallback(int width, int height);
78
84 bool charCallback(unsigned int codepoint);
85
94 bool keyCallback(int key, int scancode, int action, int mods);
95
102 bool scrollCallback(double xoffset, double yoffset);
103
110 bool cursorPosCallback(double xpos, double ypos);
111
119 bool mouseButtonCallback(int button, int action, int mods);
120
126 bool cursorEnterCallback(int entered);
127
150 void mainLoop(Color clearColor = {240, 240, 240}) override;
151
158 TGUI_NODISCARD Optional<Event> convertWindowFocusEvent(int focused);
159
167 TGUI_NODISCARD Optional<Event> convertSizeEvent(int width, int height);
168
175 TGUI_NODISCARD Optional<Event> convertCharEvent(unsigned int codepoint);
176
186 TGUI_NODISCARD Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
187
195 TGUI_NODISCARD Optional<Event> convertScrollEvent(double xoffset, double yoffset);
196
204 TGUI_NODISCARD Optional<Event> convertCursorPosEvent(double xpos, double ypos);
205
214 TGUI_NODISCARD Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
215
222 TGUI_NODISCARD Optional<Event> convertCursorEnterEvent(int entered);
223
229 GLFWwindow* getWindow() const;
230
240 void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override;
241
249 TGUI_NODISCARD bool isKeyboardModifierPressed(Event::KeyModifier modifierKey) const override;
250
252 protected:
253
259 void setGuiWindow(GLFWwindow* window);
260
262 // Updates the view and changes the size of the root container when needed
264 void updateContainerSize() override;
265
267 protected:
268
269 GLFWwindow* m_window = nullptr;
270
272 };
273}
274
275TGUI_IGNORE_DEPRECATED_WARNINGS_END
276
278
279#endif // TGUI_BACKEND_GUI_GLFW_HPP
Definition BackendGuiGLFW.hpp:49
GLFWwindow * getWindow() const
Returns the window that was provided to the gui.
bool mouseButtonCallback(int button, int action, int mods)
Inform the gui about a mouse button event when a callback from glfwSetMouseButtonCallback occurs.
void setGuiWindow(GLFWwindow *window)
Sets the window on which the gui should be drawn.
bool cursorEnterCallback(int entered)
Inform the gui that the mouse has left or entered the window when a callback from glfwSetCursorEnterC...
bool scrollCallback(double xoffset, double yoffset)
Inform the gui about a scroll event when a callback from glfwSetScrollCallback occurs.
bool charCallback(unsigned int codepoint)
Inform the gui about a char event when a callback from glfwSetCharCallback occurs.
BackendGuiGLFW()
Default constructor.
bool isKeyboardModifierPressed(Event::KeyModifier modifierKey) const override
Checks the state for one of the modifier keys.
void mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override
This function is called by TGUI when the position of the caret changes in a text field (EditBox or Te...
bool keyCallback(int key, int scancode, int action, int mods)
Inform the gui about a key event when a callback from glfwSetKeyCallback occurs.
bool sizeCallback(int width, int height)
Inform the gui about a framebuffer size event when a callback from glfwSetFramebufferSizeCallback occ...
bool cursorPosCallback(double xpos, double ypos)
Inform the gui about a cursor position event when a callback from glfwSetCursorPosCallback occurs.
bool windowFocusCallback(int focused)
Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs.
~BackendGuiGLFW()
Destructor.
Base class for the Gui.
Definition BackendGui.hpp:47
Wrapper for colors.
Definition Color.hpp:73
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
KeyModifier
Modifiers keys.
Definition Event.hpp:157