TGUI  0.9.5
Loading...
Searching...
No Matches
BoxLayoutRatios.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_BOX_LAYOUT_RATIOS_HPP
27#define TGUI_BOX_LAYOUT_RATIOS_HPP
28
29#include <TGUI/Widgets/BoxLayout.hpp>
30
32
33namespace tgui
34{
39 class TGUI_API BoxLayoutRatios : public BoxLayout
40 {
41 public:
42
43 typedef std::shared_ptr<BoxLayoutRatios> Ptr;
44 typedef std::shared_ptr<const BoxLayoutRatios> ConstPtr;
45
46
54 BoxLayoutRatios(const char* typeName, bool initRenderer);
55
56
65 void add(const Widget::Ptr& widget, const String& widgetName = "") override;
66
67
75 void add(const Widget::Ptr& widget, float ratio, const String& widgetName = "");
76
77
89 void insert(std::size_t index, const Widget::Ptr& widget, const String& widgetName = "") override;
90
91
105 void insert(std::size_t index, const Widget::Ptr& widget, float ratio, const String& widgetName = "");
106
107
115 bool remove(std::size_t index) override;
116 using BoxLayout::remove;
117
118
122 void removeAllWidgets() override;
123
124
132 void addSpace(float ratio);
133
134
143 void insertSpace(std::size_t index, float ratio);
144
145
157 bool setRatio(Widget::Ptr widget, float ratio);
158
159
171 bool setRatio(std::size_t index, float ratio);
172
173
181 float getRatio(Widget::Ptr widget) const;
182
183
191 float getRatio(std::size_t index) const;
192
193
195 protected:
196
200 std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
201
202
206 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
207
208
210 protected:
211
212 std::vector<float> m_ratios;
213
214
216 };
217
218
220}
221
223
224#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(Widget::Ptr widget, float ratio)
Changes the ratio of a widget.
float getRatio(Widget::Ptr widget) const
Returns the ratio of a widget at a certain index.
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.
void addSpace(float ratio)
Add an extra space after the last widget.
std::shared_ptr< const BoxLayoutRatios > ConstPtr
Shared constant widget pointer.
Definition BoxLayoutRatios.hpp:44
void insert(std::size_t index, const Widget::Ptr &widget, float ratio, const String &widgetName="")
Inserts a widget to the layout.
float getRatio(std::size_t index) const
Returns the ratio of a widget at a certain index.
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 insertSpace(std::size_t index, float ratio)
Insert an extra space between widgets.
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:79
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:73
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36