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 <gadfly@gadfly.vip>

* fix: Make IgnoredWhitespace toggle button visible based on IsTextDiff

---------

Signed-off-by: Gadfly <gadfly@gadfly.vip>
This commit is contained in:
GadflyFang 2025-02-06 09:49:45 +08:00 committed by GitHub
parent dd254ebf4f
commit 92065dee12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -129,6 +129,7 @@
<ToggleButton Classes="line_path"
Width="28"
IsChecked="{Binding IgnoreWhitespace, Mode=TwoWay}"
IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.IgnoreWhitespace}">
<Path Width="14" Height="14" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}"/>
</ToggleButton>

View file

@ -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