TGUI  0.10-dev
BackendGuiGLFW.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2021 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
26#ifndef TGUI_BACKEND_GUI_GLFW_HPP
27#define TGUI_BACKEND_GUI_GLFW_HPP
28
29#include <TGUI/Backend/Window/BackendGui.hpp>
30#include <TGUI/Optional.hpp>
31
33
34typedef struct GLFWwindow GLFWwindow;
35
37
38namespace tgui
39{
41
42 class TGUI_API BackendGuiGLFW : public BackendGui
43 {
44 public:
45
51 BackendGuiGLFW() = default;
52
53
58 void windowFocusCallback(int focused);
59
60
66 void sizeCallback(int width, int height);
67
68
73 void charCallback(unsigned int codepoint);
74
75
83 void keyCallback(int key, int scancode, int action, int mods);
84
85
91 void scrollCallback(double xoffset, double yoffset);
92
93
99 void cursorPosCallback(double xpos, double ypos);
100
101
108 void mouseButtonCallback(int button, int action, int mods);
109
110
131 void mainLoop() override;
132
133
140 Optional<Event> convertWindowFocusEvent(int focused);
141
142
150 Optional<Event> convertSizeEvent(int width, int height);
151
152
159 Optional<Event> convertCharEvent(unsigned int codepoint);
160
161
171 Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
172
173
181 Optional<Event> convertScrollEvent(double xoffset, double yoffset);
182
183
191 Optional<Event> convertCursorPosEvent(double xpos, double ypos);
192
193
202 Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
203
204
206 protected:
207
213 void setGuiWindow(GLFWwindow* window);
214
215
217 // Updates the view and changes the size of the root container when needed
219 void updateContainerSize() override;
220
221
223 protected:
224
225 GLFWwindow* m_window = nullptr;
226
228 };
229}
230
232
233#endif // TGUI_BACKEND_GUI_GLFW_HPP
Definition: BackendGuiGLFW.hpp:43
void keyCallback(int key, int scancode, int action, int mods)
Inform the gui about a key event when a callback from glfwSetKeyCallback occurs.
void setGuiWindow(GLFWwindow *window)
Sets the window on which the gui should be drawn.
void windowFocusCallback(int focused)
Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs.
BackendGuiGLFW()=default
Default constructor.
void charCallback(unsigned int codepoint)
Inform the gui about a char event when a callback from glfwSetCharCallback occurs.
void sizeCallback(int width, int height)
Inform the gui about a framebuffer size event when a callback from glfwSetFramebufferSizeCallback occ...
void mainLoop() override
Give the gui control over the main loop.
void mouseButtonCallback(int button, int action, int mods)
Inform the gui about a mouse button event when a callback from glfwSetMouseButtonCallback occurs.
void cursorPosCallback(double xpos, double ypos)
Inform the gui about a cursor position event when a callback from glfwSetCursorPosCallback occurs.
void scrollCallback(double xoffset, double yoffset)
Inform the gui about a scroll event when a callback from glfwSetScrollCallback occurs.
Base class for the Gui.
Definition: BackendGui.hpp:45
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36