26#ifndef TGUI_LAYOUT_HPP
27#define TGUI_LAYOUT_HPP
29#include <TGUI/Config.hpp>
30#include <TGUI/Vector2.hpp>
89 template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
91 m_value{static_cast<float>(constant)}
126 explicit Layout(
Operation operation, std::unique_ptr<Layout> leftOperand, std::unique_ptr<Layout> rightOperand);
173 return m_operation == Operation::Value;
193 void connectWidget(
Widget* widget,
bool xAxis, std::function<
void()> valueChangedCallbackHandler);
208 void recalculateValue();
225 void resetPointers();
231 void parseBindingStringRecursive(
Widget* widget,
bool xAxis);
237 void parseBindingString(
const String& expression,
Widget* widget,
bool xAxis);
244 Layout* m_parent =
nullptr;
245 Operation m_operation = Operation::Value;
246 std::unique_ptr<Layout> m_leftOperand =
nullptr;
247 std::unique_ptr<Layout> m_rightOperand =
nullptr;
248 Widget* m_boundWidget =
nullptr;
250 std::function<void()> m_connectedWidgetCallback =
nullptr;
284 x{std::move(layoutX)},
285 y{std::move(layoutY)}
325 return {x.getValue(), y.getValue()};
337 return "(" + x.toString() +
", " + y.toString() +
")";
406 inline namespace bind_functions
Base class for the Gui.
Definition GuiBase.hpp:45
Class to store the position or size of a widget.
Definition Layout.hpp:262
Layout2d(Vector2f constant={0, 0})
Default constructor to implicitly construct from a tgui::Vector2f.
Definition Layout.hpp:270
Layout2d(Layout layoutX, Layout layoutY)
Constructor to create the Layout2d from two Layout classes.
Definition Layout.hpp:283
Layout2d(const char *expression)
Constructs the Layout2d based on a string which will be parsed to determine the value of the layouts.
Definition Layout.hpp:297
Vector2f getValue() const
Returns the cached value of the layout.
Definition Layout.hpp:323
Layout2d(const String &expression)
Constructs the Layout2d based on a string which will be parsed to determine the value of the layouts.
Definition Layout.hpp:311
Class to store the left, top, width or height of a widget.
Definition Layout.hpp:50
Layout(String expression)
Constructs the layout based on a string which will be parsed to determine the value of the layout.
Operation
The operation which the layout has to perform to find its value.
Definition Layout.hpp:55
Layout()=default
Default constructor.
float getValue() const
Return the cached value of the layout.
Definition Layout.hpp:160
Layout & operator=(Layout &&other)
Move assignment operator.
Layout(Layout &&other)
Move constructor.
Layout(T constant)
Constructor to implicitly construct from numeric constant.
Definition Layout.hpp:90
Layout(const Layout &other)
Copy constructor.
Layout(const char *expression)
Constructs the layout based on a string which will be parsed to determine the value of the layout.
Definition Layout.hpp:101
bool isConstant() const
Return whether the layout stores a constant value.
Definition Layout.hpp:171
Layout & operator=(const Layout &other)
Copy assignment operator.
Wrapper class to store strings.
Definition String.hpp:79
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
TGUI_API Layout bindRight(std::shared_ptr< Widget > widget)
Bind to the right position of the widget.
TGUI_API Layout bindHeight(std::shared_ptr< Widget > widget)
Bind to the height of the widget.
TGUI_API Layout bindTop(std::shared_ptr< Widget > widget)
Bind to the top position of the widget.
TGUI_API Layout bindPosX(std::shared_ptr< Widget > widget)
Bind to the x position of the widget (same as bindLeft unless widget origin is changed)
TGUI_API Layout2d bindInnerSize(std::shared_ptr< Container > container)
Bind to the inner size of the container widget.
TGUI_API Layout2d bindSize(std::shared_ptr< Widget > widget)
Bind to the size of the widget.
TGUI_API Layout bindMax(const Layout &value1, const Layout &value2)
Bind to the maximum value of two layouts.
TGUI_API Layout bindWidth(std::shared_ptr< Widget > widget)
Bind to the width of the widget.
TGUI_API Layout bindBottom(std::shared_ptr< Widget > widget)
Bind to the bottom of the widget.
TGUI_API Layout bindInnerHeight(std::shared_ptr< Container > container)
Bind to the inner height of the container widget.
TGUI_API Layout bindInnerWidth(std::shared_ptr< Container > container)
Bind to the inner width of the container widget.
TGUI_API Layout bindMin(const Layout &value1, const Layout &value2)
Bind to the minimum value of two layouts.
TGUI_API Layout bindLeft(std::shared_ptr< Widget > widget)
Bind to the left position of the widget.
TGUI_API Layout bindPosY(std::shared_ptr< Widget > widget)
Bind to the y position of the widget (same as bindTop unless widget origin is changed)
TGUI_API Layout2d bindPosition(std::shared_ptr< Widget > widget)
Bind to the position of the widget.