TGUI  0.10-dev
SubwidgetContainer.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2021 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
35namespace 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
57 SubwidgetContainer(const char* typeName, bool initRenderer);
58
59
64 void setSize(const Layout2d& size) override;
65 using Widget::setSize;
66
67
76 void setFocused(bool focused) override;
77
78
84 void setTextSize(unsigned int size) override;
85
86
92
93
98 const Container* getContainer() const;
99
100
104 void leftMousePressed(Vector2f pos) override;
105
109 void leftMouseReleased(Vector2f pos) override;
110
114 void rightMousePressed(Vector2f pos) override;
115
119 void rightMouseReleased(Vector2f pos) override;
120
124 void mouseMoved(Vector2f pos) override;
125
129 void keyPressed(const Event::KeyEvent& event) override;
130
134 void textEntered(char32_t key) override;
135
139 bool mouseWheelScrolled(float delta, Vector2f pos) override;
140
144 void mouseNoLongerOnWidget() override;
145
149 void leftMouseButtonNoLongerDown() override;
150
154 void rightMouseButtonNoLongerDown() override;
155
156
159 // Shows the tool tip when the widget is located below the mouse.
160 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
161 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
163 Widget::Ptr askToolTip(Vector2f mousePos) override;
164
165
168 // This function is called every frame with the time passed since the last frame.
170 bool updateTime(Duration elapsedTime) override;
171
172
177 bool isMouseOnWidget(Vector2f pos) const override;
178
179
184 void setParent(Container* parent) override;
185
186
188 protected:
189
193 std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
194
195
199 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
200
201
208 void draw(BackendRenderTarget& target, RenderStates states) const override;
209
210
212 protected:
213
214 CopiedSharedPtr<Group> m_container;
215
216
218 };
219
220
222}
223
225
226#endif // TGUI_SUBWIDGET_CONTAINER_HPP
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Container widget.
Definition: Container.hpp:47
Definition: CopiedSharedPtr.hpp:40
Wrapper for durations.
Definition: Duration.hpp:52
Class to store the position or size of a widget.
Definition: Layout.hpp:262
Base class for widgets that consist of subwidgets that act together as if they are a single widget.
Definition: SubwidgetContainer.hpp:43
void setTextSize(unsigned int size) override
Changes the character size of all subwidgets.
void setFocused(bool focused) override
Focus or unfocus the widget.
void setSize(const Layout2d &size) override
Changes the size of the widget.
Container * getContainer()
Returns a pointer to the internal container.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the subwidgets to a render target.
std::shared_ptr< const SubwidgetContainer > ConstPtr
Shared constant widget pointer.
Definition: SubwidgetContainer.hpp:47
std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
std::shared_ptr< SubwidgetContainer > Ptr
Shared widget pointer.
Definition: SubwidgetContainer.hpp:46
const Container * getContainer() const
Returns a const pointer to the internal container.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
The parent class for every widget.
Definition: Widget.hpp:70
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:73
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
KeyPressed event parameters.
Definition: Event.hpp:167
States used for drawing.
Definition: RenderStates.hpp:39