TGUI  1.6.1
Loading...
Searching...
No Matches
BoxLayout.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 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_BOX_LAYOUT_HPP
26#define TGUI_BOX_LAYOUT_HPP
27
28#include <TGUI/Widgets/Group.hpp>
29#include <TGUI/Renderers/BoxLayoutRenderer.hpp>
30
32
33TGUI_MODULE_EXPORT namespace tgui
34{
39 class TGUI_API BoxLayout : public Group
40 {
41 public:
42
43 using Ptr = std::shared_ptr<BoxLayout>;
44 using ConstPtr = std::shared_ptr<const BoxLayout>;
45
53 BoxLayout(const char* typeName, bool initRenderer);
54
59 TGUI_NODISCARD BoxLayoutRenderer* getSharedRenderer() override;
60 TGUI_NODISCARD const BoxLayoutRenderer* getSharedRenderer() const override;
61
67 TGUI_NODISCARD BoxLayoutRenderer* getRenderer() override;
68
74 void setSize(const Layout2d& size) override;
75 using Widget::setSize;
76
88 void add(const Widget::Ptr& widget, const String& widgetName = "") override;
89
104 virtual void insert(std::size_t index, const Widget::Ptr& widget, const String& widgetName = "");
105
113 bool remove(const Widget::Ptr& widget) override;
114
122 virtual bool remove(std::size_t index);
123
131 TGUI_NODISCARD Widget::Ptr get(std::size_t index) const;
132 using Container::get;
133
144 virtual bool setWidgetIndex(const Widget::Ptr& widget, std::size_t index) override;
145
147 protected:
148
154 void rendererChanged(const String& property) override;
155
157 // @brief Repositions and resize the widgets
159 virtual void updateWidgets() = 0;
160
162 protected:
163
164 float m_spaceBetweenWidgetsCached = 0;
165
167 };
168
170}
171
173
174#endif // TGUI_BOX_LAYOUT_HPP
Definition BoxLayoutRenderer.hpp:35
Abstract class for box layout containers.
Definition BoxLayout.hpp:40
BoxLayoutRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void add(const Widget::Ptr &widget, const String &widgetName="") override
Adds a widget at the end of the layout.
virtual void insert(std::size_t index, const Widget::Ptr &widget, const String &widgetName="")
Inserts a widget to the layout.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
bool remove(const Widget::Ptr &widget) override
Removes a single widget that was added to the container.
Widget::Ptr get(std::size_t index) const
Returns the widget at the given index in the layout.
virtual bool remove(std::size_t index)
Removes a single widget that was added to the container.
std::shared_ptr< const BoxLayout > ConstPtr
Shared constant widget pointer.
Definition BoxLayout.hpp:44
std::shared_ptr< BoxLayout > Ptr
Shared widget pointer.
Definition BoxLayout.hpp:43
BoxLayoutRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setSize(const Layout2d &size) override
Changes the size of the group.
virtual bool setWidgetIndex(const Widget::Ptr &widget, std::size_t index) override
Changes the index of a widget in this container.
Group widget.
Definition Group.hpp:42
Class to store the position or size of a widget.
Definition Layout.hpp:323
Wrapper class to store strings.
Definition String.hpp:96
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:86
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38