TGUI  0.8.6
SubwidgetContainer.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2019 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_SUBWIDGET_CONTAINER_HPP
27 #define TGUI_SUBWIDGET_CONTAINER_HPP
28 
29 
30 #include <TGUI/Widgets/Group.hpp>
31 #include <TGUI/CopiedSharedPtr.hpp>
32 
34 
35 namespace tgui
36 {
42  class TGUI_API SubwidgetContainer : public Widget
43  {
44  public:
45 
46  typedef std::shared_ptr<SubwidgetContainer> Ptr;
47  typedef std::shared_ptr<const SubwidgetContainer> ConstPtr;
48 
49 
51  // Default constructor
54 
55 
60  void setSize(const Layout2d& size) override;
61  using Widget::setSize;
62 
63 
67  void leftMousePressed(Vector2f pos) override;
68 
72  void leftMouseReleased(Vector2f pos) override;
73 
77  void rightMousePressed(Vector2f pos) override;
78 
82  void rightMouseReleased(Vector2f pos) override;
83 
87  void mouseMoved(Vector2f pos) override;
88 
92  void keyPressed(const sf::Event::KeyEvent& event) override;
93 
97  void textEntered(std::uint32_t key) override;
98 
102  bool mouseWheelScrolled(float delta, Vector2f pos) override;
103 
107  void mouseNoLongerOnWidget() override;
108 
112  void leftMouseButtonNoLongerDown() override;
113 
117  void rightMouseButtonNoLongerDown() override;
118 
119 
122  // Shows the tool tip when the widget is located below the mouse.
123  // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
124  // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
126  Widget::Ptr askToolTip(Vector2f mousePos) override;
127 
128 
131  // This function is called every frame with the time passed since the last frame.
133  void update(sf::Time elapsedTime) override;
134 
135 
137  protected:
138 
142  std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
143 
144 
148  void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
149 
150 
157  void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
158 
159 
161  protected:
162 
163  CopiedSharedPtr<Group> m_container;
164 
165 
167  };
168 
169 
171 }
172 
174 
175 #endif // TGUI_SUBWIDGET_CONTAINER_HPP
Definition: CopiedSharedPtr.hpp:39
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:77
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Base class for widgets that consist of subwidgets that act together as if they are a single widget.
Definition: SubwidgetContainer.hpp:42
Class to store the position or size of a widget.
Definition: Layout.hpp:258
std::shared_ptr< SubwidgetContainer > Ptr
Shared widget pointer.
Definition: SubwidgetContainer.hpp:46
Definition: Vector2f.hpp:38
The parent class for every widget.
Definition: Widget.hpp:73
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
std::shared_ptr< const SubwidgetContainer > ConstPtr
Shared constant widget pointer.
Definition: SubwidgetContainer.hpp:47