Skip to content

Commit

Permalink
[SUTK] Fixes related to container resizes
Browse files Browse the repository at this point in the history
 - inside RenderRectFill::onContainerResize
  • Loading branch information
ravi688 committed Aug 2, 2024
1 parent 0759e3a commit 3a9d67d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sutk/source/RenderRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ namespace SUTK

void RenderRectFill::onContainerResize(Rect2Df rect, bool isPositionChanged, bool isSizeChanged) noexcept
{
if(m_isSizeDirty)
if(isSizeChanged)
{
// The rect for this RenderRect is in local coordinates of the RenderRectContainer for this RenderRect.
// Therefore, the position would always be { 0, 0 } for this rect.
Expand Down
8 changes: 5 additions & 3 deletions sutk/source/tests/AnchorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ namespace SUTK
FullWindowContainer* rootContainer = m_uiDriver->createContainer<FullWindowContainer>(NULL);
Container* emptyContainer = m_uiDriver->createContainer<Container>(rootContainer);
emptyContainer->setRect({ 1.0f, 1.0f, 7.0f, 7.0f });
AnchorRect* anchor = emptyContainer->getAnchorRect();
anchor->setTopLeft({ 0, 0 });
anchor->setBottomRight({ 1, 1 });
m_renderRectContainer = m_uiDriver->createContainer<RenderRectContainer>(emptyContainer);
m_renderRectContainer->setRect({ 1.0f, 1.0f, 5, 5 });
AnchorRect* anchor = m_renderRectContainer->getAnchorRect();
anchor->setTopLeft({ 0, 0 });
anchor = m_renderRectContainer->getAnchorRect();
anchor->setTopLeft({ 1, 1 });
anchor->setBottomRight({ 1, 1 });
emptyContainer->setRect({ 1.0f, 1.0f, 9.0f, 7.0f });
emptyContainer->setRect({ 1.0f, 1.0f, 11.0f, 7.0f });
// Expected size of m_renderRectContainer, { 1.0f, 1.0f, 9.0f, 5.0f }
m_renderRect = m_uiDriver->createRenderRect<RenderRectFill>(m_renderRectContainer);
m_renderRect->setColor(Color3::green());

Expand Down
2 changes: 1 addition & 1 deletion sutk/source/tests/MouseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace SUTK
m_renderRectContainer->setRect({ 1.0f, 1.0f, 1.0f, 1.0f });
AnchorRect* anchor = m_renderRectContainer->getAnchorRect();
anchor->setTopLeft({ 0, 0 });
anchor->setBottomRight({ 1, 1 });
anchor->setBottomRight({ 0, 0 });
m_renderRect = m_uiDriver->createRenderRect<RenderRectFill>(m_renderRectContainer);
m_renderRect->setColor(Color3::green());
}
Expand Down

0 comments on commit 3a9d67d

Please sign in to comment.