From 92065dee12dc8f73c82065fc70008d1098387fe4 Mon Sep 17 00:00:00 2001 From: GadflyFang Date: Thu, 6 Feb 2025 09:49:45 +0800 Subject: [PATCH] fix: Ensure each ImageView instance calculates its own aspect ratio (#929) * fix: Ensure each ImageView instance calculates its own aspect ratio - Modified ArrangeOverride methods in ImageView class to independently calculate and apply the aspect ratio based on the instance's image. Signed-off-by: Gadfly * fix: Make IgnoredWhitespace toggle button visible based on IsTextDiff --------- Signed-off-by: Gadfly --- src/Views/DiffView.axaml | 1 + src/Views/ImageContainer.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml index 23a141c3..aa75c2a0 100644 --- a/src/Views/DiffView.axaml +++ b/src/Views/DiffView.axaml @@ -129,6 +129,7 @@ diff --git a/src/Views/ImageContainer.cs b/src/Views/ImageContainer.cs index aecea0b2..b62746ed 100644 --- a/src/Views/ImageContainer.cs +++ b/src/Views/ImageContainer.cs @@ -92,6 +92,20 @@ namespace SourceGit.Views return availableSize; } + + protected override Size ArrangeOverride(Size finalSize) + { + if (Image is { } image) + { + var imageSize = image.Size; + var scaleW = finalSize.Width / imageSize.Width; + var scaleH = finalSize.Height / imageSize.Height; + var scale = Math.Min(scaleW, scaleH); + return new Size(scale * imageSize.Width, scale * imageSize.Height); + } + + return base.ArrangeOverride(finalSize); + } } public class ImageSwipeControl : ImageContainer