TGUI  0.10-beta
SubwidgetContainer.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2022 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
85
90 const Container* getContainer() const;
91
92
96 void leftMousePressed(Vector2f pos) override;
97
101 void leftMouseReleased(Vector2f pos) override;
102
106 void rightMousePressed(Vector2f pos) override;
107
111 void rightMouseReleased(Vector2f pos) override;
112
116 void mouseMoved(Vector2f pos) override;
117
121 void keyPressed(const Event::KeyEvent& event) override;
122
126 void textEntered(char32_t key) override;
127
131 bool mouseWheelScrolled(float delta, Vector2f pos) override;
132
136 void mouseNoLongerOnWidget() override;
137
141 void leftMouseButtonNoLongerDown() override;
142
146 void rightMouseButtonNoLongerDown() override;
147
148
151 // Shows the tool tip when the widget is located below the mouse.
152 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
153 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
155 Widget::Ptr askToolTip(Vector2f mousePos) override;
156
157
160 // This function is called every frame with the time passed since the last frame.
162 bool updateTime(Duration elapsedTime) override;
163
164
169 bool isMouseOnWidget(Vector2f pos) const override;
170
171
176 void setParent(Container* parent) override;
177
178
180 protected:
181
185 std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
186
187
191 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
192
193
197 void updateTextSize() override;
198
199
206 void draw(BackendRenderTarget& target, RenderStates states) const override;
207
208
210 protected:
211
212 CopiedSharedPtr<Group> m_container;
213
214
216 };
217
218
220}
221
223
224#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:284
Base class for widgets that consist of subwidgets that act together as if they are a single widget.
Definition: SubwidgetContainer.hpp:43
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 updateTextSize() override
Called when the text size is changed (either by setTextSize or via the renderer)
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