From 9ddc1f697549131f5b12636a02229be4c6c21d8c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 29 Oct 2021 17:11:45 +0200 Subject: [PATCH] Made Image ScaleToImage take ui scale into account --- CHANGELOG.md | 1 + MLEM.Ui/Elements/Image.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c73a60..b899d4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Additions Improvements - Cache TokenizedString inner offsets for non-Left text alignments to improve performance - Exposed the epsilon value used by Element calculations +- Made Image ScaleToImage take ui scale into account Fixes - Fixed VerticalSpace height parameter being an integer diff --git a/MLEM.Ui/Elements/Image.cs b/MLEM.Ui/Elements/Image.cs index 364a284..3bf6cd5 100644 --- a/MLEM.Ui/Elements/Image.cs +++ b/MLEM.Ui/Elements/Image.cs @@ -43,6 +43,7 @@ namespace MLEM.Ui.Elements { private bool scaleToImage; /// /// Whether this image element's should be based on the size of the given. + /// Note that, when scaling to the image's size, the is also taken into account. /// public bool ScaleToImage { get => this.scaleToImage; @@ -97,7 +98,7 @@ namespace MLEM.Ui.Elements { /// protected override Vector2 CalcActualSize(RectangleF parentArea) { - return this.Texture != null && this.scaleToImage ? this.Texture.Size.ToVector2() : base.CalcActualSize(parentArea); + return this.Texture != null && this.scaleToImage ? this.Texture.Size.ToVector2() * this.Scale : base.CalcActualSize(parentArea); } ///