Skip to content

Commit

Permalink
Change default max size to be large but not maximum of type, etc...
Browse files Browse the repository at this point in the history
Change default max size to be large but not maximum of type (dGr0K5oxVE),
Fixed image atlas auto test
  • Loading branch information
Neko-Box-Coder committed Jul 23, 2023
1 parent 9281ca9 commit 62e4c8b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Include/ssGUI/DataClasses/Transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ssGUI
GlobalPosition(0, 0),
Size(25, 25),
MinSize(25, 25),
MaxSize(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()),
MaxSize(9999, 9999),
Anchor(ssGUI::Enums::AnchorType::TOP_LEFT),
CurrentHierarchy(nullptr),
CurrentRenderer(nullptr),
Expand Down
2 changes: 1 addition & 1 deletion Old/IndexedList.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SSGUI_INDEXED_LIST
#define SSGUI_INDEXED_LIST

#include "ssGUI//DebugAndBuild//ssGUIBuildAndDebugConfig.hpp"
//#include "ssGUI/DebugAndBuild/ssGUIBuildAndDebugConfig.hpp"
#include <list>
#include <map>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion Src/Tests/AutoTests/BackendTests/DynamicAtlasTest_Auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int main()

ssTEST_OUTPUT_ASSERT("Validate Pos", getImgInfo.LocationInPixel == glm::ivec3() &&
getImgInfo2.LocationInPixel == glm::ivec3(0, 200, 0) &&
getImgInfo3.LocationInPixel == glm::ivec3(350, 0, 0));
getImgInfo3.LocationInPixel == glm::ivec3(400, 0, 0));
};


Expand Down
2 changes: 1 addition & 1 deletion Src/ssGUI/DataClasses/Transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ssGUI
GlobalPosition(0, 0),
Size(25, 25),
MinSize(25, 25),
MaxSize(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()),
MaxSize(9999, 9999),
Anchor(ssGUI::Enums::AnchorType::TOP_LEFT),
CurrentHierarchy(nullptr),
CurrentRenderer(nullptr),
Expand Down
42 changes: 11 additions & 31 deletions Src/ssGUI/Extensions/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace Extensions
{
float minSizeTotalX = 0;
float maxSizeTotalX = 0;
float minMaxY = std::numeric_limits<float>::max();
float minMaxY = 9999;
float maxMinY = -1;

Container->StashChildrenIterator();
Expand All @@ -330,15 +330,8 @@ namespace Extensions
if(!Container->IsChildrenIteratorLast())
minSizeTotalX += GetSpacing();

//Don't need to do anything if maxSizeTotalX is max
if(maxSizeTotalX != std::numeric_limits<float>::max())
{
if(Container->GetCurrentChild()->GetMaxSize().x == std::numeric_limits<float>::max())
maxSizeTotalX = std::numeric_limits<float>::max();
else
maxSizeTotalX += Container->GetCurrentChild()->GetMaxSize().x;
}

maxSizeTotalX += Container->GetCurrentChild()->GetMaxSize().x;

if(Container->GetCurrentChild()->GetMaxSize().y < minMaxY)
minMaxY = Container->GetCurrentChild()->GetMaxSize().y;

Expand All @@ -356,21 +349,18 @@ namespace Extensions
float spacingTotalX = (Container->GetChildrenCount() - ObjectsToExclude.size() - 1) * GetSpacing();

minSizeTotalX += paddingTotalX + spacingTotalX;
maxSizeTotalX = maxSizeTotalX == std::numeric_limits<float>::max() ? std::numeric_limits<float>::max() :
maxSizeTotalX + paddingTotalX + spacingTotalX;
maxSizeTotalX += paddingTotalX + spacingTotalX;

if( Container->GetType() == ssGUI::Enums::GUIObjectType::WINDOW &&
Container->GetType() != ssGUI::Enums::GUIObjectType::MAIN_WINDOW &&
dynamic_cast<ssGUI::Window*>(Container)->HasTitlebar())
{
minMaxY = minMaxY == std::numeric_limits<float>::max() ? std::numeric_limits<float>::max() :
minMaxY + dynamic_cast<ssGUI::Window*>(Container)->GetTitlebarHeight() + GetPadding();
minMaxY += dynamic_cast<ssGUI::Window*>(Container)->GetTitlebarHeight() + GetPadding();
maxMinY += dynamic_cast<ssGUI::Window*>(Container)->GetTitlebarHeight() + GetPadding();
}
else
{
minMaxY = minMaxY == std::numeric_limits<float>::max() ? std::numeric_limits<float>::max() :
minMaxY + GetPadding() * 2;
minMaxY += GetPadding() * 2;
maxMinY += GetPadding() * 2;
}

Expand All @@ -396,7 +386,7 @@ namespace Extensions
{
float minSizeTotalY = 0;
float maxSizeTotalY = 0;
float minMaxX = std::numeric_limits<float>::max();
float minMaxX = 9999;
float maxMinX = -1;

Container->StashChildrenIterator();
Expand All @@ -418,15 +408,8 @@ namespace Extensions
if(!Container->IsChildrenIteratorLast())
minSizeTotalY += GetSpacing();

//Don't need to do anything if maxSizeTotalY is max
if(maxSizeTotalY != std::numeric_limits<float>::max())
{
if(Container->GetCurrentChild()->GetMaxSize().y == std::numeric_limits<float>::max())
maxSizeTotalY = std::numeric_limits<float>::max();
else
maxSizeTotalY += Container->GetCurrentChild()->GetMaxSize().y;
}

maxSizeTotalY += Container->GetCurrentChild()->GetMaxSize().y;

if(Container->GetCurrentChild()->GetMaxSize().x < minMaxX)
minMaxX = Container->GetCurrentChild()->GetMaxSize().x;

Expand All @@ -450,13 +433,10 @@ namespace Extensions
float spacingTotalY = (Container->GetChildrenCount() - ObjectsToExclude.size() - 1) * GetSpacing();

minSizeTotalY += paddingTotalY + spacingTotalY;
maxSizeTotalY = maxSizeTotalY == std::numeric_limits<float>::max() ? std::numeric_limits<float>::max() :
maxSizeTotalY + paddingTotalY + spacingTotalY;
maxSizeTotalY += paddingTotalY + spacingTotalY;

minMaxX = minMaxX == std::numeric_limits<float>::max() ? std::numeric_limits<float>::max() :
minMaxX + GetPadding() * 2;
minMaxX += GetPadding() * 2;
maxMinX += GetPadding() * 2;


//Check if we want to use container's min max or children's min max
maxMinX = maxMinX > Container->GetMinSize().x ? maxMinX : Container->GetMinSize().x;
Expand Down

0 comments on commit 62e4c8b

Please sign in to comment.