26#ifndef TGUI_CONTAINER_HPP
27#define TGUI_CONTAINER_HPP
32#include <TGUI/Widget.hpp>
51 typedef std::shared_ptr<Container>
Ptr;
52 typedef std::shared_ptr<const Container>
ConstPtr;
125 virtual void add(
const Widget::Ptr& widgetPtr,
const sf::String& widgetName =
"");
155 typename T::Ptr
get(
const sf::String& widgetName,
bool recursive =
false)
const
157 return std::dynamic_pointer_cast<T>(get(widgetName, recursive));
276 return sf::Vector2f{0, 0};
319 virtual void leftMousePressed(
float x,
float y)
override;
324 virtual void leftMouseReleased(
float x,
float y)
override;
329 virtual void mouseMoved(
float x,
float y)
override;
334 virtual void keyPressed(
const sf::Event::KeyEvent& event)
override;
339 virtual void textEntered(sf::Uint32 key)
override;
344 virtual void mouseWheelMoved(
int delta,
int x,
int y)
override;
349 virtual void mouseNoLongerOnWidget()
override;
354 virtual void mouseNoLongerDown()
override;
359 virtual void widgetUnfocused()
override;
368 virtual Widget::Ptr askToolTip(sf::Vector2f mousePos)
override;
395 virtual void update(sf::Time elapsedTime)
override;
402 bool handleEvent(sf::Event& event);
409 bool focusNextWidgetInContainer();
417 bool tabKeyPressed();
430 virtual void drawWidgetContainer(sf::RenderTarget* target,
const sf::RenderStates& states = sf::RenderStates::Default)
const;
436 std::vector<Widget::Ptr> m_widgets;
437 std::vector<sf::String> m_objName;
442 std::size_t m_focusedWidget = 0;
445 bool m_handingMouseReleased =
false;
457 class TGUI_API GuiContainer :
public Container
461 typedef std::shared_ptr<GuiContainer> Ptr;
462 typedef std::shared_ptr<const GuiContainer> ConstPtr;
480 virtual void setSize(
const Layout2d& size)
override;
488 virtual bool mouseOnWidget(
float x,
float y)
const override;
506 virtual void draw(sf::RenderTarget& target, sf::RenderStates states)
const override;
512 sf::RenderTarget* m_window =
nullptr;
Container widget.
Definition: Container.hpp:48
virtual bool remove(const Widget::Ptr &widget)
Removes a single widget that was added to the container.
Container(const Container ©)
Copy constructor.
bool setWidgetName(const Widget::Ptr &widget, const std::string &name)
Changes the name of a widget.
std::shared_ptr< Container > Ptr
Shared widget pointer.
Definition: Container.hpp:51
virtual void removeAllWidgets()
Removes all widgets that were added to the container.
void focusWidget(const Widget::Ptr &widget)
Focuses a widget.
void moveWidgetToBack(Widget *const widget)
Places a widget behind all other widgets.
void saveWidgetsToStream(std::stringstream &stream)
Save the child widgets to a text file.
virtual void setFont(const Font &font) override
Changes the font of the text in the widget and its children.
virtual sf::Vector2f getChildWidgetsOffset() const
Returns the distance between the position of the container and a widget that would be drawn inside th...
Definition: Container.hpp:274
void unfocusWidgets()
Unfocus all the widgets.
T::Ptr get(const sf::String &widgetName, bool recursive=false) const
Returns a pointer to an earlier created widget.
Definition: Container.hpp:155
void saveWidgetsToFile(const std::string &filename)
Save the child widgets to a text file.
virtual void add(const Widget::Ptr &widgetPtr, const sf::String &widgetName="")
Adds a widget to the container.
Widget::Ptr get(const sf::String &widgetName, bool recursive=false) const
Returns a pointer to an earlier created widget.
virtual void setOpacity(float opacity) override
Changes the opacity of the container and all its child widgets.
void moveWidgetToFront(Widget *const widget)
Places a widget before all other widgets.
void loadWidgetsFromStream(std::stringstream &stream)
Load the child widgets from a string stream.
void uncheckRadioButtons()
Uncheck all the radio buttons.
void focusWidget(Widget *const widget)
Focuses a widget.
void loadWidgetsFromFile(const std::string &filename)
Load the child widgets from a text file.
const std::vector< sf::String > & getWidgetNames()
Returns a list of the names of all the widgets.
Definition: Container.hpp:110
std::shared_ptr< const Container > ConstPtr
Shared constant widget pointer.
Definition: Container.hpp:52
void focusNextWidget()
Focuses the next widget.
std::string getWidgetName(const Widget::Ptr &widget) const
Returns the name of a widget.
const std::vector< Widget::Ptr > & getWidgets()
Returns a list of all the widgets.
Definition: Container.hpp:98
void focusPreviousWidget()
Focuses the previous widget.
Class to store the position or size of a widget.
Definition: Layout.hpp:255
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34