Files
UnrealEngine/Engine/Plugins/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/SMutableConstrainedBox.cpp
2025-05-18 13:04:45 +08:00

39 lines
846 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MuCOE/SMutableConstrainedBox.h"
void SMutableConstrainedBox::Construct(const FArguments& InArgs)
{
MinWidth = InArgs._MinWidth;
MaxWidth = InArgs._MaxWidth;
ChildSlot
[
InArgs._Content.Widget
];
}
FVector2D SMutableConstrainedBox::ComputeDesiredSize(float LayoutScaleMultiplier) const
{
const float MinWidthVal = MinWidth.Get().Get(0.0f);
const float MaxWidthVal = MaxWidth.Get().Get(0.0f);
if (MinWidthVal == 0.0f && MaxWidthVal == 0.0f)
{
return SCompoundWidget::ComputeDesiredSize(LayoutScaleMultiplier);
}
else
{
FVector2D ChildSize = ChildSlot.GetWidget()->GetDesiredSize();
float XVal = FMath::Max(MinWidthVal, ChildSize.X);
if (MaxWidthVal > MinWidthVal)
{
XVal = FMath::Min(MaxWidthVal, XVal);
}
return FVector2D(XVal, ChildSize.Y);
}
}