If height is manually set, derive the width from that not the originally calculated height

This commit is contained in:
Steve Streeting 2020-11-24 17:30:12 +00:00
parent df20383558
commit d81b07871d

View File

@ -78,18 +78,16 @@ public:
const TSharedRef<FSlateFontMeasure> FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService(); const TSharedRef<FSlateFontMeasure> FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
MaxCharHeight = FontMeasure->GetMaxCharacterHeight(TextStyle.Font, 1.0f); MaxCharHeight = FontMeasure->GetMaxCharacterHeight(TextStyle.Font, 1.0f);
float IconHeight = FMath::Min(static_cast<float>(MaxCharHeight), Brush.ImageSize.Y); float IconHeight = FMath::Min(static_cast<float>(MaxCharHeight), Brush.ImageSize.Y);
float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ;
if (Width.IsSet())
{
IconWidth = Width.GetValue();
}
if (Height.IsSet()) if (Height.IsSet())
{ {
IconHeight = Height.GetValue(); IconHeight = Height.GetValue();
} }
float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ;
if (Width.IsSet())
{
IconWidth = Width.GetValue();
}
ChildSlot ChildSlot
[ [
@ -133,17 +131,17 @@ public:
TSharedPtr<SWidget> Widget = ChildSlot.GetWidget(); TSharedPtr<SWidget> Widget = ChildSlot.GetWidget();
SBox* Box = static_cast<SBox*>(Widget.Get()); SBox* Box = static_cast<SBox*>(Widget.Get());
float IconHeight = FMath::Min(static_cast<float>(MaxCharHeight), Brush.ImageSize.Y); float IconHeight = FMath::Min(static_cast<float>(MaxCharHeight), Brush.ImageSize.Y);
if (RequestedHeight.IsSet())
{
IconHeight = RequestedHeight.GetValue();
}
float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ; float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ;
if (RequestedWidth.IsSet()) if (RequestedWidth.IsSet())
{ {
IconWidth = RequestedWidth.GetValue(); IconWidth = RequestedWidth.GetValue();
} }
if (RequestedHeight.IsSet())
{
IconHeight = RequestedHeight.GetValue();
}
Box->SetWidthOverride(IconWidth); Box->SetWidthOverride(IconWidth);
Box->SetHeightOverride(IconHeight); Box->SetHeightOverride(IconHeight);