Skip to content

Conversation

@Foda
Copy link
Member

@Foda Foda commented Mar 14, 2024

Description of Change

Images should always set their size to the size of FontImageSource/CanvasImageSource as this is established behavior for Maui/Xamarin.

Image + Button Resize Rules

  • Images should always set their size to the size of FontImageSource/CanvasImageSource regardless of if they're in a button or not
  • If you don't set the size of the button then the button should grow to fit the image/content size
  • If you set the size of the button the image should stretch to fit the available space, unless it's a FontImageSource/CanvasImageSource
  • If you set the size of the button and the image then no resizing should happen
  • If you set the size of the image, it should not resize

Issues Fixed

Fixes #21202
Fixes #20648

@Foda Foda added platform/windows area-controls-button Button, ImageButton i/regression This issue described a confirmed regression on a currently supported version labels Mar 14, 2024
@Foda Foda requested a review from a team as a code owner March 14, 2024 18:12
Comment on lines 169 to 173
if (nativeImage.Source is CanvasImageSource canvas)
{
nativeImage.Width = canvas.Size.Width;
nativeImage.Height = canvas.Size.Height;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I reviewed a PR weeks ago that removed all the measuring code here - from normal images and things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit: 7dff6eb#diff-e34feff8430d43e27f52abff099ba347b41628f6bde6a68e12f8b618722c59c9

Should this rather have been implemented differently instead of just being removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you did 🥲. I misunderstood the behavior of how FontImageSource scales-to-fit the available space, which differs from how images in buttons scale-to-fit.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue18242"
Title="Issue 18242">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be a new page? I just finished up the Android fixes and if there are 2 columns this page will be too narrow and cramped for a good test on android/ios

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's probably a good idea.

</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Fonts\OpenSans-Regular.ttf" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should just be <MauiFont> ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-packaged app fonts won't work if they're set to MauiFont

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed now - we merged the win2d updates.

But it is fine if we want this to run on older branches.

mattleibow
mattleibow previously approved these changes Mar 15, 2024
@PureWeen
Copy link
Member

/rebase

@github-actions github-actions bot force-pushed the foda/FontImageButtonStretch branch from 66bbbe4 to a44ad41 Compare March 19, 2024 02:05
@PureWeen
Copy link
Member

UI Tests all passed.
Failing Device tests are unrelated

@PureWeen PureWeen merged commit d03a2c6 into main Mar 19, 2024
@PureWeen PureWeen deleted the foda/FontImageButtonStretch branch March 19, 2024 03:57
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-button Button, ImageButton fixed-in-8.0.20 fixed-in-9.0.0-preview.3.10457 i/regression This issue described a confirmed regression on a currently supported version platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Button font image source incorrectly sized on 8.0.10 when specifying a button HeightRequest Add more tests for Images on buttons

5 participants