From d81b07871d46e4811717f5dfde9a9032541f0387 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Tue, 24 Nov 2020 17:30:12 +0000 Subject: [PATCH] If height is manually set, derive the width from that not the originally calculated height --- .../RichTextBlockInputImageDecorator.cpp | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp b/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp index 75b6e16..d62bb4b 100644 --- a/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp +++ b/Source/StevesUEHelpers/Private/StevesUI/RichTextBlockInputImageDecorator.cpp @@ -78,18 +78,16 @@ public: const TSharedRef FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService(); MaxCharHeight = FontMeasure->GetMaxCharacterHeight(TextStyle.Font, 1.0f); float IconHeight = FMath::Min(static_cast(MaxCharHeight), Brush.ImageSize.Y); - float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ; - - if (Width.IsSet()) - { - IconWidth = Width.GetValue(); - } - if (Height.IsSet()) { IconHeight = Height.GetValue(); } + float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ; + if (Width.IsSet()) + { + IconWidth = Width.GetValue(); + } ChildSlot [ @@ -133,17 +131,17 @@ public: TSharedPtr Widget = ChildSlot.GetWidget(); SBox* Box = static_cast(Widget.Get()); float IconHeight = FMath::Min(static_cast(MaxCharHeight), Brush.ImageSize.Y); + if (RequestedHeight.IsSet()) + { + IconHeight = RequestedHeight.GetValue(); + } + float IconWidth = Brush.ImageSize.X * (IconHeight / Brush.ImageSize.Y) ; - if (RequestedWidth.IsSet()) { IconWidth = RequestedWidth.GetValue(); } - if (RequestedHeight.IsSet()) - { - IconHeight = RequestedHeight.GetValue(); - } Box->SetWidthOverride(IconWidth); Box->SetHeightOverride(IconHeight);