26#ifndef TGUI_LAYOUT_HPP
27#define TGUI_LAYOUT_HPP
29#include <SFML/System/Vector2.hpp>
30#include <TGUI/Config.hpp>
48 class TGUI_API LayoutImpl :
public std::enable_shared_from_this<LayoutImpl>
90 float parseLayoutString(std::string expression);
93 float parseWidgetName(
const std::string& expression, Widget* widget,
const std::string& alreadyParsedPart =
"");
99 std::set<Layout*> attachedLayouts;
100 std::set<LayoutImpl*> parents;
102 Operation operation = Operation::Value;
103 std::vector<std::shared_ptr<LayoutImpl>> operands;
106 std::string stringExpression;
107 Widget* parentWidget =
nullptr;
110 std::set<std::string> boundCallbacks;
137 template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
140 m_impl->value =
static_cast<float>(constant);
198 void connectUpdateCallback(
const std::function<
void()>& callbackFunction);
216 std::shared_ptr<LayoutImpl> getImpl()
const;
243 std::shared_ptr<LayoutImpl> m_impl = std::make_shared<LayoutImpl>();
244 std::function<void()> m_callbackFunction;
472 #define TGUI_IMPORT_LAYOUT_BIND_FUNCTIONS \
473 using tgui::bindLeft; \
474 using tgui::bindTop; \
475 using tgui::bindWidth; \
476 using tgui::bindHeight; \
477 using tgui::bindRight; \
478 using tgui::bindBottom; \
479 using tgui::bindPosition; \
480 using tgui::bindSize; \
481 using tgui::bindMin; \
482 using tgui::bindMax; \
483 using tgui::bindRange; \
484 using tgui::bindIf; \
485 using tgui::bindStr; \
486 using tgui::bindStr2d;
Gui class.
Definition: Gui.hpp:43
Class to store the position or size of a widget.
Definition: Layout.hpp:255
Layout2d operator*=(Layout right)
*= operator for the Layout2d class
Layout2d operator-()
Unary minus operator for the Layout class.
Layout2d operator%=(Layout right)
%= operator for the Layout2d class (floating point modulo)
Layout2d operator+()
Unary plus operator for the Layout class.
Layout2d(Layout layoutX, Layout layoutY)
Constructor to create the Layout2d from two Layout classes.
Layout2d operator/=(Layout right)
/= operator for the Layout2d class
Layout y
Layout to store the y component.
Definition: Layout.hpp:327
Layout2d(const char *expression)
Construct the layout based on a string which will be parsed to determine the value of the layout.
Layout2d operator-=(Layout2d right)
-= operator for the Layout2d class
Layout x
Layout to store the x component.
Definition: Layout.hpp:326
Layout2d(const std::string &expression)
Constructs the layout based on a string which will be parsed to determine the value of the layout.
sf::Vector2f getValue() const
Return the cached value of the layout.
Layout2d operator+=(Layout2d right)
+= operator for the Layout2d class
Layout2d(sf::Vector2f constant={0, 0})
Default constructor to implicitly construct from an sf::Vector2f.
Class to store the left, top, width or height of a widget.
Definition: Layout.hpp:121
Layout operator/=(Layout right)
/= operator for the Layout class
float getValue() const
Return the cached value of the layout.
Layout operator-=(Layout right)
-= operator for the Layout class
Layout operator*=(Layout right)
*= operator for the Layout class
Layout()
Default constructor.
Layout & operator=(const Layout &right)
Overload of assignment operator.
Layout operator%=(Layout right)
%= operator for the Layout class (floating point modulo)
Layout(const std::string &expression)
Construct the layout based on a string which will be parsed to determine the value of the layout.
Layout operator-()
Unary minus operator for the Layout class.
Layout(T constant)
Constructor to implicitly construct from numeric constant.
Definition: Layout.hpp:138
Layout(const char *expression)
Construct the layout based on a string which will be parsed to determine the value of the layout.
Layout operator+()
Unary plus operator for the Layout class.
Layout operator+=(Layout right)
+= operator for the Layout class
Layout(const Layout ©)
Copy constructor.
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34
TGUI_API Layout bindRight(std::shared_ptr< Widget > widget)
Bind to the right position 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 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 operator>(Layout left, Layout right)
> operator for the Layout class
TGUI_API Layout bindMax(Layout value1, Layout value2)
Bind to the maximum of two values.
TGUI_API Layout2d bindStr2d(const std::string &expression)
Bind a string for a layout (you can also just create the layout directly with the string)
TGUI_API Layout operator*(Layout left, Layout right)
operator for the Layout class
TGUI_API Layout bindIf(Layout condition, Layout trueExpr, Layout falseExpr)
Bind conditionally to one of the two layouts.
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 bindTop(std::shared_ptr< Widget > widget)
Bind to the y position of the widget.
TGUI_API Layout bindWidth(std::shared_ptr< Widget > widget)
Bind to the width of the widget.
TGUI_API Layout2d bindSize(std::shared_ptr< Widget > widget)
Bind to the size of the widget.
TGUI_API Layout bindStr(const std::string &expression)
Bind a string for a layout (you can also just create the layout directly with the string)
TGUI_API Layout bindHeight(std::shared_ptr< Widget > widget)
Bind to the height 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 bindRange(Layout minimum, Layout maximum, Layout value)
Bind to a value that remains between the minimum and maximum.
TGUI_API Layout operator!=(Layout left, Layout right)
!= operator for the Layout class
TGUI_API Layout bindMin(Layout value1, Layout value2)
Bind to the minimum of two values.
TGUI_API Layout operator%(Layout left, Layout right)
% operator for the Layout class
TGUI_API Layout bindBottom(std::shared_ptr< Widget > widget)
Bind to the bottom of the widget.
TGUI_API Layout bindLeft(std::shared_ptr< Widget > widget)
Bind to the x position of the widget.
TGUI_API Layout operator==(Layout left, Layout right)
== operator for the Layout class
TGUI_API Layout2d bindPosition(std::shared_ptr< Widget > widget)
Bind to the position of the widget.