26#ifndef TGUI_LAYOUT_HPP
27#define TGUI_LAYOUT_HPP
29#include <TGUI/Config.hpp>
30#include <TGUI/Vector2f.hpp>
87 template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
89 m_value{static_cast<float>(constant)}
100 Layout{std::string{expression}}
124 explicit Layout(
Operation operation, std::unique_ptr<Layout> leftOperand, std::unique_ptr<Layout> rightOperand);
171 return m_operation == Operation::Value;
181 std::string toString()
const;
191 void connectWidget(
Widget* widget,
bool xAxis, std::function<
void()> valueChangedCallbackHandler);
206 void recalculateValue();
223 void resetPointers();
229 void parseBindingStringRecursive(
Widget* widget,
bool xAxis);
235 void parseBindingString(
const std::string& expression,
Widget* widget,
bool xAxis);
242 Layout* m_parent =
nullptr;
243 Operation m_operation = Operation::Value;
244 std::unique_ptr<Layout> m_leftOperand =
nullptr;
245 std::unique_ptr<Layout> m_rightOperand =
nullptr;
246 Widget* m_boundWidget =
nullptr;
247 std::string m_boundString;
248 std::function<void()> m_connectedWidgetCallback =
nullptr;
294 x{std::move(layoutX)},
295 y{std::move(layoutY)}
335 return {x.getValue(), y.getValue()};
345 std::string toString()
const
347 return "(" + x.toString() +
", " + y.toString() +
")";
416 inline namespace bind_functions
Gui class.
Definition: Gui.hpp:43
Class to store the position or size of a widget.
Definition: Layout.hpp:260
Layout2d(Vector2f constant={0, 0})
Default constructor to implicitly construct from a tgui::Vector2f.
Definition: Layout.hpp:268
Layout2d(Layout layoutX, Layout layoutY)
Constructor to create the Layout2d from two Layout classes.
Definition: Layout.hpp:293
Layout2d(sf::Vector2f constant)
Default constructor to implicitly construct from a sf::Vector2f.
Definition: Layout.hpp:280
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:307
Vector2f getValue() const
Returns the cached value of the layout.
Definition: Layout.hpp:333
Layout2d(const std::string &expression)
Constructs the Layout2d based on a string which will be parsed to determine the value of the layouts.
Definition: Layout.hpp:321
Class to store the left, top, width or height of a widget.
Definition: Layout.hpp:50
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:158
Layout & operator=(Layout &&other)
Move assignment operator.
Layout(Layout &&other)
Move constructor.
Layout(std::string expression)
Constructs the layout based on a string which will be parsed to determine the value of the layout.
Layout(T constant)
Constructor to implicitly construct from numeric constant.
Definition: Layout.hpp:88
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:99
bool isConstant() const
Return whether the layout stores a constant value.
Definition: Layout.hpp:169
Layout & operator=(const Layout &other)
Copy assignment operator.
Definition: Vector2f.hpp:39
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:37
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 y position of the widget.
TGUI_API Layout2d bindInnerSize(std::shared_ptr< Container > container)
Bind to the inner size of the container widget.
TGUI_API Layout operator+(Layout left, Layout right)
operator for the Layout class
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 operator/(Layout left, Layout right)
/ operator for the Layout class
TGUI_API Layout operator*(Layout left, Layout right)
operator for the Layout class
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 operator-(Layout right)
Unary minus operator for the Layout class.
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 x position of the widget.
TGUI_API Layout2d bindPosition(std::shared_ptr< Widget > widget)
Bind to the position of the widget.