Made space between widgets in BoxLayoutRenderer a float instead of a Layout since a relative ratio wasn't supported anyway
parent
704fcb2c80
commit
0a08bb6c3f
|
@ -61,7 +61,7 @@ namespace tgui
|
|||
/// @param distance Amount of space between the widgets
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setSpaceBetweenWidgets(const Layout& distance);
|
||||
void setSpaceBetweenWidgets(float distance);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -70,7 +70,7 @@ namespace tgui
|
|||
/// @return Amount of space between the widgets
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Layout getSpaceBetweenWidgets() const;
|
||||
float getSpaceBetweenWidgets() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace tgui
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
|
||||
Layout m_spaceBetweenWidgetsCached;
|
||||
float m_spaceBetweenWidgetsCached;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -32,18 +32,18 @@ namespace tgui
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void BoxLayoutRenderer::setSpaceBetweenWidgets(const Layout& distance)
|
||||
void BoxLayoutRenderer::setSpaceBetweenWidgets(float distance)
|
||||
{
|
||||
setProperty("spacebetweenwidgets", ObjectConverter{distance});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Layout BoxLayoutRenderer::getSpaceBetweenWidgets() const
|
||||
float BoxLayoutRenderer::getSpaceBetweenWidgets() const
|
||||
{
|
||||
auto it = m_data->propertyValuePairs.find("spacebetweenwidgets");
|
||||
if (it != m_data->propertyValuePairs.end())
|
||||
return it->second.getLayout();
|
||||
return it->second.getNumber();
|
||||
else
|
||||
{
|
||||
it = m_data->propertyValuePairs.find("padding");
|
||||
|
|
|
@ -59,8 +59,7 @@ namespace tgui
|
|||
void HorizontalLayout::updateWidgets()
|
||||
{
|
||||
const sf::Vector2f contentSize = getContentSize();
|
||||
const float spaceBetweenWidgets = m_spaceBetweenWidgetsCached.getValue();
|
||||
const float totalSpaceBetweenWidgets = (spaceBetweenWidgets * m_widgets.size()) - spaceBetweenWidgets;
|
||||
const float totalSpaceBetweenWidgets = (m_spaceBetweenWidgetsCached * m_widgets.size()) - m_spaceBetweenWidgetsCached;
|
||||
|
||||
float currentOffset = 0;
|
||||
for (auto& widget : m_widgets)
|
||||
|
@ -81,7 +80,7 @@ namespace tgui
|
|||
}
|
||||
}
|
||||
|
||||
currentOffset += width + spaceBetweenWidgets;
|
||||
currentOffset += width + m_spaceBetweenWidgetsCached;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ namespace tgui
|
|||
void HorizontalWrap::updateWidgets()
|
||||
{
|
||||
const sf::Vector2f contentSize = getContentSize();
|
||||
const float spaceBetweenWidgets = m_spaceBetweenWidgetsCached.getValue();
|
||||
|
||||
float currentHorizontalOffset = 0;
|
||||
float currentVerticalOffset = 0;
|
||||
|
@ -70,14 +69,14 @@ namespace tgui
|
|||
|
||||
if (currentHorizontalOffset + size.x > contentSize.x)
|
||||
{
|
||||
currentVerticalOffset += lineHeight + spaceBetweenWidgets;
|
||||
currentVerticalOffset += lineHeight + m_spaceBetweenWidgetsCached;
|
||||
currentHorizontalOffset = 0;
|
||||
lineHeight = 0;
|
||||
}
|
||||
|
||||
widget->setPosition({currentHorizontalOffset, currentVerticalOffset});
|
||||
|
||||
currentHorizontalOffset += size.x + spaceBetweenWidgets;
|
||||
currentHorizontalOffset += size.x + m_spaceBetweenWidgetsCached;
|
||||
|
||||
if (lineHeight < size.y)
|
||||
lineHeight = size.y;
|
||||
|
|
|
@ -59,8 +59,7 @@ namespace tgui
|
|||
void VerticalLayout::updateWidgets()
|
||||
{
|
||||
const sf::Vector2f contentSize = getContentSize();
|
||||
const float spaceBetweenWidgets = m_spaceBetweenWidgetsCached.getValue();
|
||||
const float totalSpaceBetweenWidgets = (spaceBetweenWidgets * m_widgets.size()) - spaceBetweenWidgets;
|
||||
const float totalSpaceBetweenWidgets = (m_spaceBetweenWidgetsCached * m_widgets.size()) - m_spaceBetweenWidgetsCached;
|
||||
|
||||
float currentOffset = 0;
|
||||
for (auto& widget : m_widgets)
|
||||
|
@ -81,7 +80,7 @@ namespace tgui
|
|||
}
|
||||
}
|
||||
|
||||
currentOffset += height + spaceBetweenWidgets;
|
||||
currentOffset += height + m_spaceBetweenWidgetsCached;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue