TGUI 1.13
Loading...
Searching...
No Matches
SubwidgetContainer.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 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#ifndef TGUI_SUBWIDGET_CONTAINER_HPP
26#define TGUI_SUBWIDGET_CONTAINER_HPP
27
28#include <TGUI/CopiedSharedPtr.hpp>
29#include <TGUI/Widgets/Group.hpp>
30
32
33namespace tgui
34{
40 class TGUI_API SubwidgetContainer : public Widget
41 {
42 public:
43 using Ptr = std::shared_ptr<SubwidgetContainer>;
44 using ConstPtr = std::shared_ptr<const SubwidgetContainer>;
45
53 SubwidgetContainer(const char* typeName, bool initRenderer);
54
59 void setSize(const Layout2d& size) override;
60 using Widget::setSize;
61
70 void setFocused(bool focused) override;
71
79 void setEnabled(bool enabled) override;
80
85 [[nodiscard]] Container* getContainer();
86
91 [[nodiscard]] const Container* getContainer() const;
92
96 bool 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 scrolled(float delta, Vector2f pos, bool touch) override;
132
136 void mouseNoLongerOnWidget() override;
137
141 void leftMouseButtonNoLongerDown() override;
142
146 void rightMouseButtonNoLongerDown() override;
147
150 // Shows the tool tip when the widget is located below the mouse.
151 // Returns its tool tip or the tool tip from a child widget if the mouse is on top of the widget.
152 // A nullptr is returned when the mouse is not on top of the widget or when the tool tip is empty.
154 [[nodiscard]] Widget::Ptr askToolTip(Vector2f mousePos) override;
155
158 // This function is called every frame with the time passed since the last frame.
160 bool updateTime(Duration elapsedTime) override;
161
166 [[nodiscard]] bool isMouseOnWidget(Vector2f pos) const override;
167
172 void setParent(Container* parent) override;
173
175
176 protected:
182 void rendererChanged(const String& property) override;
183
187 [[nodiscard]] std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
188
192 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
193
197 void updateTextSize() override;
198
205 void draw(BackendRenderTarget& target, RenderStates states) const override;
206
208
209 protected:
210 CopiedSharedPtr<Group> m_container;
211 };
212} // namespace tgui
213
214#endif // TGUI_SUBWIDGET_CONTAINER_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Definition CopiedSharedPtr.hpp:40
Wrapper for durations.
Definition Duration.hpp:52
Class to store the position or size of a widget.
Definition Layout.hpp:320
Wrapper class to store strings.
Definition String.hpp:94
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:43
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:44
bool scrolled(float delta, Vector2f pos, bool touch) override
Called by the parent on scroll event (either from mouse wheel of from two finger scrolling on a touch...
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...
bool leftMousePressed(Vector2f pos) override
Called by the parent when the left mouse button goes down on top of the widget.
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:85
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
KeyPressed event parameters.
Definition Event.hpp:166
States used for drawing.
Definition RenderStates.hpp:38