TGUI
0.9-dev
|
#include <TGUI/Gui.hpp>
Public Member Functions | |
Gui () | |
Default constructor. More... | |
Gui (sf::RenderTarget &target) | |
Constructs the gui and set the target 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... | |
void | setView (const sf::View &view) |
Changes the view that is used by the gui. More... | |
const sf::View & | getView () const |
Returns the view that is currently used by the gui. More... | |
bool | handleEvent (sf::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) | |
void | draw () |
Draws all the widgets that were added to the gui. More... | |
GuiContainer::Ptr | getContainer () const |
Returns the internal container of the Gui. More... | |
void | setFont (const Font &font) |
Changes the global font. More... | |
std::shared_ptr< sf::Font > | getFont () const |
Returns the global font. 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. More... | |
bool | focusNextWidget () |
Focuses the next widget in the gui. More... | |
bool | focusPreviousWidget () |
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. More... | |
void | moveWidgetToBack (const Widget::Ptr &widget) |
Places a widget behind all other widgets. More... | |
void | uncheckRadioButtons () |
Unchecks all the radio buttons. 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... | |
Gui class.
tgui::Gui::Gui | ( | ) |
Default constructor.
If you use this constructor then you will still have to call the setTarget yourself.
tgui::Gui::Gui | ( | sf::RenderTarget & | target | ) |
Constructs the gui and set the target on which the gui should be drawn.
target | The render target (typically sf::RenderWindow) that will be used by the gui |
If you use this constructor then you will no longer have to call setTarget yourself.
void tgui::Gui::add | ( | const Widget::Ptr & | widgetPtr, |
const String & | widgetName = "" |
||
) |
Adds a widget to the container.
widgetPtr | Pointer to the widget you would like to add |
widgetName | If you want to access the widget later then you must do this with this name |
void tgui::Gui::draw | ( | ) |
Draws all the widgets that were added to the gui.
bool tgui::Gui::focusNextWidget | ( | ) |
Focuses the next widget in the gui.
bool tgui::Gui::focusPreviousWidget | ( | ) |
Focuses the previous widget in the gui.
Widget::Ptr tgui::Gui::get | ( | const String & | widgetName | ) | const |
Returns a pointer to an earlier created widget.
widgetName | The name that was given to the widget when it was added to the container |
The gui will first search for widgets that are direct children of it, but when none of the child widgets match the given name, a recursive search will be performed.
|
inline |
Returns a pointer to an earlier created widget.
widgetName | The name that was given to the widget when it was added to the container |
The gui will first search for widgets that are direct children of it, but when none of the child widgets match the given name, a recursive search will be performed.
GuiContainer::Ptr tgui::Gui::getContainer | ( | ) | const |
Returns the internal container of the Gui.
This could be useful when having a function that should accept both the gui and e.g. a child window as parameter.
std::shared_ptr<sf::Font> tgui::Gui::getFont | ( | ) | const |
Returns the global font.
float tgui::Gui::getOpacity | ( | ) | const |
Returns the opacity of all the widgets.
sf::RenderTarget* tgui::Gui::getTarget | ( | ) | const |
Returns the render target on which the gui is being drawn.
unsigned int tgui::Gui::getTextSize | ( | ) | const |
Returns the character size for future child widgets (and for existing widgets where the size wasn't changed)
const sf::View& tgui::Gui::getView | ( | ) | const |
Returns the view that is currently used by the gui.
const std::vector<Widget::Ptr>& tgui::Gui::getWidgets | ( | ) | const |
Returns a list of all the widgets.
bool tgui::Gui::handleEvent | ( | sf::Event | event | ) |
Passes the event to the widgets.
event | The event that was polled from the gui |
You should call this function in your event loop.
void tgui::Gui::loadWidgetsFromFile | ( | const String & | filename, |
bool | replaceExisting = true |
||
) |
Loads the child widgets from a text file.
filename | Filename of the widget file |
replaceExisting | Remove existing widgets first if there are any |
void tgui::Gui::loadWidgetsFromStream | ( | std::stringstream && | stream, |
bool | replaceExisting = true |
||
) |
Loads the child widgets from a string stream.
stream | stringstream that contains the widget file |
replaceExisting | Remove existing widgets first if there are any |
void tgui::Gui::loadWidgetsFromStream | ( | std::stringstream & | stream, |
bool | replaceExisting = true |
||
) |
Loads the child widgets from a string stream.
stream | stringstream that contains the widget file |
replaceExisting | Remove existing widgets first if there are any |
void tgui::Gui::moveWidgetToBack | ( | const Widget::Ptr & | widget | ) |
Places a widget behind all other widgets.
widget | The widget that should be moved to the back |
void tgui::Gui::moveWidgetToFront | ( | const Widget::Ptr & | widget | ) |
Places a widget before all other widgets.
widget | The widget that should be moved to the front |
bool tgui::Gui::remove | ( | const Widget::Ptr & | widget | ) |
Removes a single widget that was added to the container.
widget | Pointer to the widget to remove |
void tgui::Gui::removeAllWidgets | ( | ) |
Removes all widgets that were added to the container.
void tgui::Gui::saveWidgetsToFile | ( | const String & | filename | ) |
Saves the child widgets to a text file.
filename | Filename of the widget file |
void tgui::Gui::saveWidgetsToStream | ( | std::stringstream & | stream | ) | const |
Saves this the child widgets to a text file.
stream | stringstream to which the widget file will be added |
void tgui::Gui::setOpacity | ( | float | opacity | ) |
Changes the opacity of all widgets.
opacity | The opacity of the widgets. 0 means completely transparent, while 1 (default) means fully opaque |
void tgui::Gui::setTarget | ( | sf::RenderTarget & | target | ) |
Sets the target on which the gui should be drawn.
target | The render target (typically sf::RenderWindow) that will be used by the gui |
void tgui::Gui::setTextSize | ( | unsigned int | size | ) |
Changes the character size of all existing and future child widgets.
size | The new text size |
The text size specified in this function overrides the global text size property. By default, the gui does not pass any text size to the widgets and the widgets will use the global text size as default value.
void tgui::Gui::setView | ( | const sf::View & | view | ) |
Changes the view that is used by the gui.
view | The new view |
void tgui::Gui::uncheckRadioButtons | ( | ) |
Unchecks all the radio buttons.