Skip to content

Commit

Permalink
Scrollbar width is incorrectly reported in ScrollablePanel when the p…
Browse files Browse the repository at this point in the history
…anel is too small (e.g. when it hasn't been added to the gui yet and has size 0,0)
  • Loading branch information
texus committed Aug 9, 2024
1 parent a99df09 commit 3309650
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Widgets/ScrollablePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,35 +810,37 @@ namespace tgui
}

const bool horizontalScrollbarVisible = m_horizontalScrollbar->isShown();
const float minVerticalScrollbarHeight = m_verticalScrollbar->getSize().x;
const float minHorizontalScrollbarWidth = m_horizontalScrollbar->getSize().y;
if (horizontalScrollbarVisible)
{
m_verticalScrollbar->setSize(m_verticalScrollbar->getSize().x, scrollbarSpace.y - m_horizontalScrollbar->getSize().y);
m_verticalScrollbar->setSize(m_verticalScrollbar->getSize().x, std::max(minVerticalScrollbarHeight, scrollbarSpace.y - m_horizontalScrollbar->getSize().y));
m_verticalScrollbar->setViewportSize(static_cast<unsigned int>(m_verticalScrollbar->getViewportSize() - m_horizontalScrollbar->getSize().y));

if (m_verticalScrollbar->isShown())
{
m_horizontalScrollbar->setViewportSize(static_cast<unsigned int>(m_horizontalScrollbar->getViewportSize() - m_verticalScrollbar->getSize().x));
m_horizontalScrollbar->setSize(scrollbarSpace.x - m_verticalScrollbar->getSize().x, m_horizontalScrollbar->getSize().y);
m_horizontalScrollbar->setSize(std::max(minHorizontalScrollbarWidth, scrollbarSpace.x - m_verticalScrollbar->getSize().x), m_horizontalScrollbar->getSize().y);
}
else
m_horizontalScrollbar->setSize(scrollbarSpace.x, m_horizontalScrollbar->getSize().y);
m_horizontalScrollbar->setSize(std::max(minHorizontalScrollbarWidth, scrollbarSpace.x), m_horizontalScrollbar->getSize().y);
}
else
{
m_verticalScrollbar->setSize(m_verticalScrollbar->getSize().x, scrollbarSpace.y);
m_verticalScrollbar->setSize(m_verticalScrollbar->getSize().x, std::max(minVerticalScrollbarHeight, scrollbarSpace.y));
if (m_verticalScrollbar->isShown())
{
m_horizontalScrollbar->setSize(scrollbarSpace.x - m_verticalScrollbar->getSize().x, m_horizontalScrollbar->getSize().y);
m_horizontalScrollbar->setSize(std::max(minHorizontalScrollbarWidth, scrollbarSpace.x - m_verticalScrollbar->getSize().x), m_horizontalScrollbar->getSize().y);
m_horizontalScrollbar->setViewportSize(static_cast<unsigned int>(m_horizontalScrollbar->getViewportSize() - m_verticalScrollbar->getSize().x));

if (m_horizontalScrollbar->isShown())
{
m_verticalScrollbar->setSize(m_verticalScrollbar->getSize().x, scrollbarSpace.y - m_horizontalScrollbar->getSize().y);
m_verticalScrollbar->setSize(m_verticalScrollbar->getSize().x, std::max(minVerticalScrollbarHeight, scrollbarSpace.y - m_horizontalScrollbar->getSize().y));
m_verticalScrollbar->setViewportSize(static_cast<unsigned int>(m_verticalScrollbar->getViewportSize() - m_horizontalScrollbar->getSize().y));
}
}
else
m_horizontalScrollbar->setSize(scrollbarSpace.x, m_horizontalScrollbar->getSize().y);
m_horizontalScrollbar->setSize(std::max(minHorizontalScrollbarWidth, scrollbarSpace.x), m_horizontalScrollbar->getSize().y);
}

m_verticalScrollbar->setPosition(m_bordersCached.getLeft() + scrollbarSpace.x - m_verticalScrollbar->getSize().x, m_bordersCached.getTop());
Expand Down

0 comments on commit 3309650

Please sign in to comment.