TGUI  1.0-beta
Loading...
Searching...
No Matches
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 using Ptr = std::shared_ptr<SubwidgetContainer>;
47 using ConstPtr = std::shared_ptr<const SubwidgetContainer>;
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
86 void setEnabled(bool enabled) override;
87
88
94
95
100 const Container* getContainer() const;
101
102
106 void leftMousePressed(Vector2f pos) override;
107
111 void leftMouseReleased(Vector2f pos) override;
112
116 void rightMousePressed(Vector2f pos) override;
117
121 void rightMouseReleased(Vector2f pos) override;
122
126 void mouseMoved(Vector2f pos) override;
127
131 void keyPressed(const Event::KeyEvent& event) override;
132
136 void textEntered(char32_t key) override;
137
141 bool mouseWheelScrolled(float delta, Vector2f pos) override;
142
146 void mouseNoLongerOnWidget() override;
147
151 void leftMouseButtonNoLongerDown() override;
152
156 void rightMouseButtonNoLongerDown() override;
157
158
161 // Shows the tool tip when the widget is located below the mouse.
162 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
163 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
165 Widget::Ptr askToolTip(Vector2f mousePos) override;
166
167
170 // This function is called every frame with the time passed since the last frame.
172 bool updateTime(Duration elapsedTime) override;
173
174
179 bool isMouseOnWidget(Vector2f pos) const override;
180
181
186 void setParent(Container* parent) override;
187
188
190 protected:
191
197 void rendererChanged(const String& property) override;
198
199
203 std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
204
205
209 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
210
211
215 void updateTextSize() override;
216
217
224 void draw(BackendRenderTarget& target, RenderStates states) const override;
225
226
228 protected:
229
230 CopiedSharedPtr<Group> m_container;
231
232
234 };
235
236
238}
239
241
242#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
Wrapper class to store strings.
Definition: String.hpp:79
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 rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
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< SubwidgetContainer > Ptr
Shared widget pointer.
Definition: SubwidgetContainer.hpp:46
void setEnabled(bool enabled) override
Enables or disables the widget.
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.
const Container * getContainer() const
Returns a const pointer to the internal container.
std::shared_ptr< const SubwidgetContainer > ConstPtr
Shared constant widget pointer.
Definition: SubwidgetContainer.hpp:47
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
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