TGUI  0.9-dev
tgui::SFML_GRAPHICS::Gui Class Reference

Gui class for SFML (using sfml-graphics module for rendering and font) More...

#include </home/texus/Documents/TGUI-0.9/include/TGUI/Backend/SFML-Graphics.hpp>

Inheritance diagram for tgui::SFML_GRAPHICS::Gui:
tgui::BackendGuiSFML tgui::BackendGui

Public Member Functions

 Gui ()=default
 Default constructor. More...
 
 Gui (sf::RenderWindow &window)
 Constructor that immediately sets the window on which the gui should be drawn. More...
 
 Gui (sf::RenderTarget &target)
 Constructor that immediately sets the render target on which the gui should be drawn. More...
 
void setWindow (sf::RenderWindow &window)
 Sets the window on which the gui should be drawn. More...
 
void setWindow (sf::Window &window) override
 Sets the window which the gui should use. More...
 
void setTarget (sf::RenderWindow &window)
 Sets the window on which the gui should be drawn. More...
 
void setTarget (sf::RenderTarget &target)
 Sets the target on which the gui should be drawn. More...
 
sf::RenderTarget * getTarget () const
 Returns the render target on which the gui is being drawn. More...
 
- Public Member Functions inherited from tgui::BackendGuiSFML
 BackendGuiSFML ()=default
 Default constructor. More...
 
 BackendGuiSFML (sf::Window &window)
 Constructs the gui and set the window on which the gui should be drawn. More...
 
bool handleEvent (sf::Event event)
 Passes the event to the widgets. More...
 
void mainLoop () override
 Give the gui control over the main loop. More...
 
bool convertEvent (const sf::Event &eventSFML, Event &eventTGUI)
 Helper function that converts an SFML event to a TGUI event. More...
 
bool handleEvent (Event event)
 Passes the event to the widgets. More...
 
- Public Member Functions inherited from tgui::BackendGui
 BackendGui ()
 Default constructor.
 
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...
 

Additional Inherited Members

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

Detailed Description

Gui class for SFML (using sfml-graphics module for rendering and font)

Constructor & Destructor Documentation

◆ Gui() [1/3]

tgui::SFML_GRAPHICS::Gui::Gui ( )
default

Default constructor.

Warning
You must still call setWindow (or setTarget) on the Gui before using any TGUI functions

◆ Gui() [2/3]

tgui::SFML_GRAPHICS::Gui::Gui ( sf::RenderWindow &  window)
inline

Constructor that immediately sets the window on which the gui should be drawn.

Parameters
windowThe SFML window that will be used by the gui

◆ Gui() [3/3]

tgui::SFML_GRAPHICS::Gui::Gui ( sf::RenderTarget &  target)
inline

Constructor that immediately sets the render target on which the gui should be drawn.

Parameters
targetThe SFML render target that will be used by the gui
Warning
If the target isn't an sf::RenderWindow (which it isn't if this constructor is called) then window-related functionality such as changing the mouse pointer won't work. You can still call setWindow later with a regular sf::Window (not an sf::RenderWindow) to enable this functionality while still rendering to the target that is passed here.

Member Function Documentation

◆ getTarget()

sf::RenderTarget * tgui::SFML_GRAPHICS::Gui::getTarget ( ) const

Returns the render target on which the gui is being drawn.

Returns
The sfml render target that is used by the gui

◆ setTarget() [1/2]

void tgui::SFML_GRAPHICS::Gui::setTarget ( sf::RenderTarget &  target)

Sets the target on which the gui should be drawn.

Parameters
targetThe SFML render target that will be used by the gui
Warning
If the target isn't an sf::RenderWindow (which it isn't if this function overload is called) then window-related functionality such as changing the mouse pointer won't work. You can still call setWindow later with a regular sf::Window (not an sf::RenderWindow) to enable this functionality while still rendering to the target that is passed here.
See also
setTarget(sf::RenderWindow)

◆ setTarget() [2/2]

void tgui::SFML_GRAPHICS::Gui::setTarget ( sf::RenderWindow &  window)

Sets the window on which the gui should be drawn.

Parameters
windowThe SFML window that will be used by the gui

Calling setWindow or setTarget with an sf::RenderWindow does the exact same thing.

◆ setWindow() [1/2]

void tgui::SFML_GRAPHICS::Gui::setWindow ( sf::RenderWindow &  window)

Sets the window on which the gui should be drawn.

Parameters
windowThe SFML window that will be used by the gui

Calling setWindow or setTarget with an sf::RenderWindow does the exact same thing.

◆ setWindow() [2/2]

void tgui::SFML_GRAPHICS::Gui::setWindow ( sf::Window &  window)
overridevirtual

Sets the window which the gui should use.

Parameters
windowThe SFML window that will be used by the gui
Warning
If the window isn't an sf::RenderWindow (which it isn't if this function overload is called) then the window can't be used to render on and is only used for enabling window-specific functionality such as changing the mouse cursor. You still have to call setTarget to tell the gui what to render on.
This function overload shouldn't be used when passing a sf::RenderWindow to setTarget.
See also
setWindow(sf::RenderWindow)

Reimplemented from tgui::BackendGuiSFML.


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