TGUI  0.10-beta
Inheritance diagram for tgui::BackendGuiGLFW:
tgui::BackendGui tgui::GLFW_GLES2::Gui tgui::GLFW_OPENGL3::Gui

Public Member Functions

 BackendGuiGLFW ()=default
 Default constructor. More...
 
void windowFocusCallback (int focused)
 Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs. More...
 
void sizeCallback (int width, int height)
 Inform the gui about a framebuffer size event when a callback from glfwSetFramebufferSizeCallback occurs. More...
 
void charCallback (unsigned int codepoint)
 Inform the gui about a char event when a callback from glfwSetCharCallback occurs. More...
 
void keyCallback (int key, int scancode, int action, int mods)
 Inform the gui about a key event when a callback from glfwSetKeyCallback occurs. More...
 
void scrollCallback (double xoffset, double yoffset)
 Inform the gui about a scroll event when a callback from glfwSetScrollCallback occurs. More...
 
void cursorPosCallback (double xpos, double ypos)
 Inform the gui about a cursor position event when a callback from glfwSetCursorPosCallback occurs. More...
 
void mouseButtonCallback (int button, int action, int mods)
 Inform the gui about a mouse button event when a callback from glfwSetMouseButtonCallback occurs. More...
 
void mainLoop (Color clearColor={240, 240, 240}) override
 Give the gui control over the main loop. More...
 
Optional< EventconvertWindowFocusEvent (int focused)
 
Optional< EventconvertSizeEvent (int width, int height)
 
Optional< EventconvertCharEvent (unsigned int codepoint)
 
Optional< EventconvertKeyEvent (int key, int scancode, int action, int mods)
 
Optional< EventconvertScrollEvent (double xoffset, double yoffset)
 
Optional< EventconvertCursorPosEvent (double xpos, double ypos)
 
Optional< EventconvertMouseButtonEvent (int button, int action, int mods)
 
- Public Member Functions inherited from tgui::BackendGui
 BackendGui ()
 Default constructor.
 
 BackendGui (const BackendGui &copy)=delete
 
BackendGuioperator= (const BackendGui &right)=delete
 
void setAbsoluteViewport (const FloatRect &viewport)
 Sets the part of the screen to which the gui will render in pixels. More...
 
void setRelativeViewport (const FloatRect &viewport)
 Sets the part of the screen to which the gui will render as a ratio relative to the window size. More...
 
RelFloatRect getViewport () const
 Returns to which part of the screen the gui will render. More...
 
void setAbsoluteView (const FloatRect &view)
 Sets the part of the gui that will be used to fill the viewport in pixels. More...
 
void setRelativeView (const FloatRect &view)
 Sets the part of the gui that will be used to fill the viewport. More...
 
RelFloatRect getView () const
 Returns the part of the gui that will be used to fill the viewport. More...
 
bool handleEvent (Event event)
 Passes the event to the widgets. More...
 
void setTabKeyUsageEnabled (bool enabled)
 When the tab key usage is enabled, pressing tab will focus another widget.
 
bool isTabKeyUsageEnabled () const
 Returns whether the tab key usage is enabled (if so, pressing tab will focus another widget)
 
virtual void draw ()
 Draws all the widgets that were added to the gui.
 
RootContainer::Ptr getContainer () const
 Returns the internal container of the Gui. More...
 
std::shared_ptr< BackendRenderTargetgetBackendRenderTarget () const
 Returns the backend render target that is assigned to the gui. More...
 
void setFont (const Font &font)
 Changes the global font. More...
 
Font getFont () const
 Returns the global font for this gui. More...
 
const std::vector< Widget::Ptr > & getWidgets () const
 Returns a list of all the widgets. More...
 
void add (const Widget::Ptr &widgetPtr, const String &widgetName="")
 Adds a widget to the container. More...
 
Widget::Ptr get (const String &widgetName) const
 Returns a pointer to an earlier created widget. More...
 
template<class T >
T::Ptr get (const String &widgetName) const
 Returns a pointer to an earlier created widget. More...
 
bool remove (const Widget::Ptr &widget)
 Removes a single widget that was added to the container. More...
 
void removeAllWidgets ()
 Removes all widgets that were added to the container.
 
Widget::Ptr getFocusedChild () const
 Returns the child widget that is focused inside this container. More...
 
Widget::Ptr getFocusedLeaf () const
 Returns the leaf child widget that is focused inside this container. More...
 
Widget::Ptr getWidgetAtPosition (Vector2f pos) const
 Returns the leaf child widget that is located at the given position. More...
 
Widget::Ptr getWidgetBelowMouseCursor (Vector2i mousePos) const
 Returns the leaf child widget below the mouse. More...
 
bool focusNextWidget (bool recursive=true)
 Focuses the next widget in the gui. More...
 
bool focusPreviousWidget (bool recursive=true)
 Focuses the previous widget in the gui. More...
 
void unfocusAllWidgets ()
 Unfocus all the widgets.
 
void moveWidgetToFront (const Widget::Ptr &widget)
 Places a widget before all other widgets, to the front of the z-order. More...
 
void moveWidgetToBack (const Widget::Ptr &widget)
 Places a widget behind all other widgets, to the back of the z-order. More...
 
std::size_t moveWidgetForward (const Widget::Ptr &widget)
 Places a widget one step forward in the z-order. More...
 
std::size_t moveWidgetBackward (const Widget::Ptr &widget)
 Places a widget one step backward in the z-order. More...
 
bool setWidgetIndex (const Widget::Ptr &widget, std::size_t index)
 Changes the index of a widget in this container. More...
 
int getWidgetIndex (const Widget::Ptr &widget) const
 Returns the current index of a widget in this container. More...
 
void setOpacity (float opacity)
 Changes the opacity of all widgets. More...
 
float getOpacity () const
 Returns the opacity of all the widgets. More...
 
void setTextSize (unsigned int size)
 Changes the character size of all existing and future child widgets. More...
 
unsigned int getTextSize () const
 Returns the character size for future child widgets (and for existing widgets where the size wasn't changed) More...
 
void loadWidgetsFromFile (const String &filename, bool replaceExisting=true)
 Loads the child widgets from a text file. More...
 
void saveWidgetsToFile (const String &filename)
 Saves the child widgets to a text file. More...
 
void loadWidgetsFromStream (std::stringstream &stream, bool replaceExisting=true)
 Loads the child widgets from a string stream. More...
 
void loadWidgetsFromStream (std::stringstream &&stream, bool replaceExisting=true)
 Loads the child widgets from a string stream. More...
 
void saveWidgetsToStream (std::stringstream &stream) const
 Saves this the child widgets to a text file. More...
 
void setOverrideMouseCursor (Cursor::Type type)
 Overrides which cursor gets shown. More...
 
void restoreOverrideMouseCursor ()
 Undoes the effect of the last call to setOverrideCursor. More...
 
void requestMouseCursor (Cursor::Type type)
 Function that is used by widgets to change the mouse cursor. More...
 
void setDrawingUpdatesTime (bool drawUpdatesTime)
 Sets whether drawing the gui will automatically update the internal clock or whether the user does it manually. More...
 
bool updateTime ()
 Updates the internal clock (for timers, animations and blinking edit cursors) More...
 
bool updateTime (Duration elapsedTime)
 
Vector2f mapPixelToView (int x, int y) const
 
virtual void mainLoop (Color clearColor={240, 240, 240})=0
 Give the gui control over the main loop. More...
 

Protected Member Functions

void setGuiWindow (GLFWwindow *window)
 Sets the window on which the gui should be drawn. More...
 
void updateContainerSize () override
 
virtual void updateContainerSize ()
 

Protected Attributes

GLFWwindow * m_window = nullptr
 
- Protected Attributes inherited from tgui::BackendGui
std::chrono::steady_clock::time_point m_lastUpdateTime
 
bool m_windowFocused = true
 
RootContainer::Ptr m_container = nullptr
 
Widget::Ptr m_visibleToolTip = nullptr
 
Duration m_tooltipTime
 
bool m_tooltipPossible = false
 
Vector2f m_toolTipRelativePos
 
Vector2f m_lastMousePos
 
Vector2i m_windowSize
 
RelFloatRect m_viewport {RelativeValue{0}, RelativeValue{0}, RelativeValue{1}, RelativeValue{1}}
 
RelFloatRect m_view {RelativeValue{0}, RelativeValue{0}, RelativeValue{1}, RelativeValue{1}}
 
FloatRect m_lastView
 
bool m_drawUpdatesTime = true
 
bool m_tabKeyUsageEnabled = true
 
Cursor::Type m_requestedMouseCursor = Cursor::Type::Arrow
 
std::stack< Cursor::Typem_overrideMouseCursors
 
std::shared_ptr< BackendRenderTargetm_backendRenderTarget = nullptr
 

Additional Inherited Members

- Public Attributes inherited from tgui::BackendGui
SignalFloatRect onViewChange = {"ViewChanged"}
 The view was changed. Optional parameter: new view rectangle.
 

Constructor & Destructor Documentation

◆ BackendGuiGLFW()

tgui::BackendGuiGLFW::BackendGuiGLFW ( )
default

Default constructor.

Warning
setGuiWindow has to be called by the subclass that inherits from this base class before the gui is used

Member Function Documentation

◆ charCallback()

void tgui::BackendGuiGLFW::charCallback ( unsigned int  codepoint)

Inform the gui about a char event when a callback from glfwSetCharCallback occurs.

Parameters
codepointThe Unicode code point of the character

◆ cursorPosCallback()

void tgui::BackendGuiGLFW::cursorPosCallback ( double  xpos,
double  ypos 
)

Inform the gui about a cursor position event when a callback from glfwSetCursorPosCallback occurs.

Parameters
xposThe new cursor x-coordinate, relative to the left edge of the content area
yposThe new cursor y-coordinate, relative to the top edge of the content area

◆ keyCallback()

void tgui::BackendGuiGLFW::keyCallback ( int  key,
int  scancode,
int  action,
int  mods 
)

Inform the gui about a key event when a callback from glfwSetKeyCallback occurs.

Parameters
keyThe keyboard key that was pressed or released
scancodeThe system-specific scancode of the key
actionGLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT
modsBit field describing which modifier keys were held down

◆ mainLoop()

void tgui::BackendGuiGLFW::mainLoop ( Color  clearColor = {240, 240, 240})
overridevirtual

Give the gui control over the main loop.

Parameters
clearColorbackground color of the window

This function is only intended in cases where your program only needs to respond to gui events. For multimedia applications, games, or other programs where you want a high framerate or do a lot of processing in the main loop, you should use your own main loop.

You can consider this function to execute something similar (but not identical) to the following code:

while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
gui.draw();
glfwSwapBuffers(window);
glfwWaitEvents();
}

Note that this function calls glfwSetWindowUserPointer and overwrites callback handlers.

Implements tgui::BackendGui.

◆ mouseButtonCallback()

void tgui::BackendGuiGLFW::mouseButtonCallback ( int  button,
int  action,
int  mods 
)

Inform the gui about a mouse button event when a callback from glfwSetMouseButtonCallback occurs.

Parameters
buttonThe mouse button that was pressed or released
actionOne of GLFW_PRESS or GLFW_RELEASE
modsBit field describing which modifier keys were held down

◆ scrollCallback()

void tgui::BackendGuiGLFW::scrollCallback ( double  xoffset,
double  yoffset 
)

Inform the gui about a scroll event when a callback from glfwSetScrollCallback occurs.

Parameters
xoffsetThe scroll offset along the x-axis
yoffsetThe scroll offset along the y-axis

◆ setGuiWindow()

void tgui::BackendGuiGLFW::setGuiWindow ( GLFWwindow *  window)
protected

Sets the window on which the gui should be drawn.

Parameters
windowThe GLFW window that will be used by the gui

◆ sizeCallback()

void tgui::BackendGuiGLFW::sizeCallback ( int  width,
int  height 
)

Inform the gui about a framebuffer size event when a callback from glfwSetFramebufferSizeCallback occurs.

Parameters
widthThe new width, in pixels, of the framebuffer
heightThe new height, in pixels, of the framebuffer

◆ updateContainerSize()

void tgui::BackendGuiGLFW::updateContainerSize ( )
overrideprotectedvirtual

Reimplemented from tgui::BackendGui.

◆ windowFocusCallback()

void tgui::BackendGuiGLFW::windowFocusCallback ( int  focused)

Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs.

Parameters
focusedGLFW_TRUE if the window was given input focus, or GLFW_FALSE if it lost it

The documentation for this class was generated from the following file: