TGUI  1.3-dev
Loading...
Searching...
No Matches
BoxLayoutRatios.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
26#ifndef TGUI_BOX_LAYOUT_RATIOS_HPP
27#define TGUI_BOX_LAYOUT_RATIOS_HPP
28
29#include <TGUI/Widgets/BoxLayout.hpp>
30
32
33TGUI_MODULE_EXPORT namespace tgui
34{
39 class TGUI_API BoxLayoutRatios : public BoxLayout
40 {
41 public:
42
43 using Ptr = std::shared_ptr<BoxLayoutRatios>;
44 using ConstPtr = std::shared_ptr<const BoxLayoutRatios>;
45
46
54 BoxLayoutRatios(const char* typeName, bool initRenderer);
55
56
70 void add(const Widget::Ptr& widget, const String& widgetName = "") override;
71
72
85 void add(const Widget::Ptr& widget, float ratio, const String& widgetName = "");
86
87
104 void insert(std::size_t index, const Widget::Ptr& widget, const String& widgetName = "") override;
105
106
125 void insert(std::size_t index, const Widget::Ptr& widget, float ratio, const String& widgetName = "");
126
127
135 bool remove(std::size_t index) override;
136 using BoxLayout::remove;
137
138
142 void removeAllWidgets() override;
143
144
152 void addSpace(float ratio);
153
154
163 void insertSpace(std::size_t index, float ratio);
164
165
177 bool setRatio(const Widget::Ptr& widget, float ratio);
178
179
191 bool setRatio(std::size_t index, float ratio);
192
193
201 TGUI_NODISCARD float getRatio(const Widget::Ptr& widget) const;
202
203
211 TGUI_NODISCARD float getRatio(std::size_t index) const;
212
213
215 protected:
216
220 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
221
222
226 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
227
228
230 protected:
231
232 std::vector<float> m_ratios;
233
234
236 };
237
238
240}
241
243
244#endif // TGUI_BOX_LAYOUT_RATIOS_HPP
Abstract class for box layout containers.
Definition BoxLayoutRatios.hpp:40
bool remove(std::size_t index) override
Removes a single widget that was added to the container.
bool setRatio(std::size_t index, float ratio)
Changes the ratio of a widget at a certain index.
void add(const Widget::Ptr &widget, float ratio, const String &widgetName="")
Adds a widget at the end of the layout.
bool setRatio(const Widget::Ptr &widget, float ratio)
Changes the ratio of a widget.
void insert(std::size_t index, const Widget::Ptr &widget, const String &widgetName="") override
Inserts a widget to the layout.
std::shared_ptr< BoxLayoutRatios > Ptr
Shared widget pointer.
Definition BoxLayoutRatios.hpp:43
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
void removeAllWidgets() override
Removes all widgets that were added to the container.
TGUI_NODISCARD float getRatio(std::size_t index) const
Returns the ratio of a widget at a certain index.
void addSpace(float ratio)
Add an extra space after the last widget.
TGUI_NODISCARD 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.
void insert(std::size_t index, const Widget::Ptr &widget, float ratio, const String &widgetName="")
Inserts a widget to the layout.
void insertSpace(std::size_t index, float ratio)
Insert an extra space between widgets.
TGUI_NODISCARD float getRatio(const Widget::Ptr &widget) const
Returns the ratio of a widget at a certain index.
std::shared_ptr< const BoxLayoutRatios > ConstPtr
Shared constant widget pointer.
Definition BoxLayoutRatios.hpp:44
void add(const Widget::Ptr &widget, const String &widgetName="") override
Adds a widget at the end of the layout.
Abstract class for box layout containers.
Definition BoxLayout.hpp:41
Wrapper class to store strings.
Definition String.hpp:101
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:87
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39