Layouts now translate '100%' to '&.size' instead of '1 * &.size'

0.8
Bruno Van de Velde 2017-09-20 13:16:17 +02:00
parent 693573d841
commit 2b0993885c
1 changed files with 11 additions and 3 deletions

View File

@ -52,9 +52,17 @@ namespace tgui
if (expression.back() == '%')
{
// We don't know if we have to bind the width or height, so bind "size" and let the connectWidget function figure it out later
*this = Layout{Layout::Operation::Multiplies,
make_unique<Layout>(tgui::stof(expression.substr(0, expression.length()-1)) / 100.f),
make_unique<Layout>("&.size")};
if (expression == "100%")
{
m_boundString = "&.size";
m_operation = Operation::BindingString;
}
else // value is a fraction of parent size
{
*this = Layout{Layout::Operation::Multiplies,
make_unique<Layout>(tgui::stof(expression.substr(0, expression.length()-1)) / 100.f),
make_unique<Layout>("&.size")};
}
}
else
{