TGUI
0.7.8
|
#include <TGUI/Gui.hpp>
Public Member Functions | |
Gui () | |
Default constructor. More... | |
Gui (sf::RenderWindow &window) | |
Construct the gui and set the window on which the gui should be drawn. More... | |
Gui (sf::RenderTarget &window) | |
Construct the gui and set the target on which the gui should be drawn. More... | |
void | setWindow (sf::RenderWindow &window) |
Set the window on which the gui should be drawn. More... | |
void | setWindow (sf::RenderTarget &window) |
Set the target on which the gui should be drawn. More... | |
sf::RenderTarget * | getWindow () const |
Returns the window on which the gui is being drawn. More... | |
void | setView (const sf::View &view) |
Change the view that is used by the gui. More... | |
const sf::View & | getView () const |
Return the view that is currently used by the gui. More... | |
bool | handleEvent (sf::Event event) |
Passes the event to the widgets. More... | |
void | draw () |
Draws all the widgets that were added to the gui. | |
sf::Vector2f | getSize () const |
Returns the size of the container. 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 () |
Returns a list of all the widgets. More... | |
const std::vector< sf::String > & | getWidgetNames () |
Returns a list of the names of all the widgets. More... | |
void | add (const Widget::Ptr &widgetPtr, const sf::String &widgetName="") |
Adds a widget to the container. More... | |
Widget::Ptr | get (const sf::String &widgetName, bool recursive=false) const |
Returns a pointer to an earlier created widget. More... | |
template<class T > | |
T::Ptr | get (const sf::String &widgetName, bool recursive=false) 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. | |
bool | setWidgetName (const Widget::Ptr &widget, const std::string &name) |
Changes the name of a widget. More... | |
std::string | getWidgetName (const Widget::Ptr &widget) const |
Returns the name of a widget. More... | |
void | focusWidget (const Widget::Ptr &widget) |
Focuses a widget. More... | |
void | focusNextWidget () |
Focuses the next widget. More... | |
void | focusPreviousWidget () |
Focuses the previous widget. More... | |
void | unfocusWidgets () |
Unfocus all the widgets. | |
void | uncheckRadioButtons () |
Uncheck all the radio buttons. | |
void | setOpacity (float opacity) |
Changes the opacity of all widgets. More... | |
float | getOpacity () const |
Returns the opacity of all the widgets. More... | |
void | loadWidgetsFromFile (const std::string &filename) |
Load the child widgets from a text file. More... | |
void | saveWidgetsToFile (const std::string &filename) |
Save the child widgets to a text file. More... | |
void | loadWidgetsFromStream (std::stringstream &stream) |
Load the child widgets from a string stream. More... | |
void | saveWidgetsToStream (std::stringstream &stream) |
Save 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 setWindow yourself.
tgui::Gui::Gui | ( | sf::RenderWindow & | window | ) |
Construct the gui and set the window on which the gui should be drawn.
window | The sfml window that will be used by the gui. |
If you use this constructor then you will no longer have to call setWindow yourself.
tgui::Gui::Gui | ( | sf::RenderTarget & | window | ) |
Construct the gui and set the target on which the gui should be drawn.
window | The render target that will be used by the gui. |
If you use this constructor then you will no longer have to call setWindow yourself.
void tgui::Gui::add | ( | const Widget::Ptr & | widgetPtr, |
const sf::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 |
Usage example:
void tgui::Gui::focusNextWidget | ( | ) |
Focuses the next widget.
The currently focused widget will be unfocused, even if it was the only widget. When no widget was focused, the first widget in the container will be focused.
void tgui::Gui::focusPreviousWidget | ( | ) |
Focuses the previous widget.
The currently focused widget will be unfocused, even if it was the only widget. When no widget was focused, the last widget in the container will be focused.
void tgui::Gui::focusWidget | ( | const Widget::Ptr & | widget | ) |
Focuses a widget.
The previously focused widget will be unfocused.
widget | The widget that has to be focused. |
Widget::Ptr tgui::Gui::get | ( | const sf::String & | widgetName, |
bool | recursive = false |
||
) | 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. |
recursive | Should the function also search for widgets inside containers that are inside this container? |
Usage example:
|
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. |
recursive | Should the function also search for widgets inside containers that are inside this container? |
Usage example:
|
inline |
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.
|
inline |
Returns the global font.
float tgui::Gui::getOpacity | ( | ) | const |
Returns the opacity of all the widgets.
sf::Vector2f tgui::Gui::getSize | ( | ) | const |
Returns the size of the container.
This size will equal the size of the window.
|
inline |
Return the view that is currently used by the gui.
std::string tgui::Gui::getWidgetName | ( | const Widget::Ptr & | widget | ) | const |
Returns the name of a widget.
widget | Widget of which the name should be retrieved |
|
inline |
Returns a list of the names of all the widgets.
|
inline |
Returns a list of all the widgets.
|
inline |
Returns the window on which the gui is being drawn.
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 std::string & | filename | ) |
Load the child widgets from a text file.
filename | Filename of the widget file |
void tgui::Gui::loadWidgetsFromStream | ( | std::stringstream & | stream | ) |
Load the child widgets from a string stream.
stream | stringstream that contains the widget file |
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 |
Usage example:
void tgui::Gui::saveWidgetsToFile | ( | const std::string & | filename | ) |
Save the child widgets to a text file.
filename | Filename of the widget file |
void tgui::Gui::saveWidgetsToStream | ( | std::stringstream & | stream | ) |
Save this the child widgets to a text file.
stream | stringstream to which the widget file will be added |
|
inline |
Changes the global font.
font | Font to use |
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::setView | ( | const sf::View & | view | ) |
Change the view that is used by the gui.
view | The new view |
bool tgui::Gui::setWidgetName | ( | const Widget::Ptr & | widget, |
const std::string & | name | ||
) |
Changes the name of a widget.
widget | Widget of which the name should be changed |
name | New name for the widget |
void tgui::Gui::setWindow | ( | sf::RenderTarget & | window | ) |
Set the target on which the gui should be drawn.
window | The render target that will be used by the gui. |
void tgui::Gui::setWindow | ( | sf::RenderWindow & | window | ) |
Set the window on which the gui should be drawn.
window | The sfml window that will be used by the gui. |