[Bug] Aspect settings not working on MacOS (4.3-pre) #7949
Comments
Hi @DennisWelu thanks for reporting this. I am kind of confused though.
That was to show the expected output, gotcha! :) |
👍 @jfversluis Yup! I should have captioned them, but the first image (expected) is actually the iOS simulator running the same code. The 2nd image (actual) is a MacOS window just shaped roughly the same aspect so it's a closer apple to apples comparison. |
I'm wondering if this ever worked, even before the refactor you're mentioning. In any case, I got the 80% solution here: 723d10d But as it turns out there is no built-in AspectFill for an NSImage... So just need to add that and this should be good again. |
Super work. I believe it did work previously - I have a Mac app that uses AspectFill and the behavior changed after updating. From what I've seen in a couple places the layer has to be captured for the NSImage at the right time then the gravity of the layer can be made to fulfill the AspectFill behavior: https://stackoverflow.com/questions/23002653/nsimageview-image-aspect-fill/38752428#38752428 |
Thanks @DennisWelu, I've seen that. The weird thing about that code is: the |
I'm just lofting out observations from casual review of the changes, but I do see it grabbing the |
Wow it must've been Friday afternoon... It simply has a Implemented it like this and now they all work again. Thanks for the second pair of eyes! I'll open the PR right after this. |
Awesome! Thanks @jfversluis! |
I am sad that 2 of 3 aspect settings for Image will continue to not work until vNext+1. |
+1 @DennisWelu sorry about that :( You're more than welcome to take my PR and try to fix that last piece |
@jfversluis LOL, appreciate the sympathy! I did make one comment on the PR as I started to look through the changes a bit. Haven't gotten to the point of ACTUALLY trying to make it work. If I can peel off a couple hours from other projects I might, but can't promise! |
I have a crazy workaround for scale to full size of the parent control (like window). private void ScaleImageToWindowSize(bool visible)
{
// Have to scale down and then up that macOs is recognize the change 🤦♂️
if (Device.Idiom == TargetIdiom.Desktop)
{
this.Dispatcher.BeginInvokeOnMainThread(() =>
{
if (visible)
{
// Calc needed fullscreen size
double windowMax = Math.Max(this.Width, this.Height);
double imageMax = Math.Max(ImageBlurred.Width, ImageBlurred.Height);
double scale = windowMax / imageMax;
if (scale < 1 || double.IsInfinity(scale))
{
ImageBlurred.Scale = 1;
}
else
{
ImageBlurred.Scale = scale + 0.2; // Little offset because there is a black border
}
}
else
{
// Have to set this to get original size
ImageBlurred.HorizontalOptions = LayoutOptions.Center;
ImageBlurred.VerticalOptions = LayoutOptions.Center;
ImageBlurred.Scale = 0.0001;
}
});
}
} |
Description
Only 1 of the 3 aspect settings works on XF Mac.
Steps to Reproduce
Expected Behavior
The expected behavior is demonstrated on iOS:
Actual Behavior
The actual behavior in a MacOS window:
Basic Information
Reproduction Link
ImageAspect.zip
The text was updated successfully, but these errors were encountered: