Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Correctly size the ImageButton BitmapImage #6663

Merged
merged 4 commits into from
May 11, 2022
Merged

Conversation

jsuarezruiz
Copy link
Contributor

Description of Change

Correctly size the Windows ImageButton BitmapImage.

image

Issues Fixed

Fixes #4913

@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/windows 🪟 area-controls-button Button, ImageButton labels Apr 29, 2022
nativeImage.Width = imageSourceSize.Width;
nativeImage.Height = imageSourceSize.Height;

nativeImage.Width = button.Width > 0 ? platformButton.ActualWidth : imageSourceSize.Width;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If ImageButton HeightRequest and WidthRequest properties have been set we use that values on the image. Otherwise, the height and width of the original image size is used.

Copy link
Member

Choose a reason for hiding this comment

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

I believe EZ added a special value for this: Primitives.Dimension.Unset
The Width/Height properties are already massaged into either Unset or a positive value, so we should probably use that to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied changes to use Primitives.Dimension.Unset, also added a sample:
fix-imagebutton-size

Is working correctly and also resize as expected.

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Apr 29, 2022
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

What happens when the the button changes size? Also, is this possible to be tested?

nativeImage.Width = imageSourceSize.Width;
nativeImage.Height = imageSourceSize.Height;

nativeImage.Width = button.Width > 0 ? platformButton.ActualWidth : imageSourceSize.Width;
Copy link
Member

Choose a reason for hiding this comment

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

I believe EZ added a special value for this: Primitives.Dimension.Unset
The Width/Height properties are already massaged into either Unset or a positive value, so we should probably use that to be consistent.

@Redth Redth added this to the 6.0.300 milestone May 5, 2022
@PureWeen PureWeen self-requested a review May 9, 2022 14:26
@PureWeen PureWeen self-assigned this May 9, 2022
@Redth Redth requested review from rachelkang and Redth May 10, 2022 14:39
@mattleibow mattleibow enabled auto-merge (squash) May 11, 2022 02:01
@mattleibow mattleibow merged commit 6ff3e58 into main May 11, 2022
@mattleibow mattleibow deleted the fix-4913 branch May 11, 2022 03:13
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@samhouts samhouts added the fixed-in-6.0.312 Look for this fix in 6.0.312! label Aug 2, 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-6.0.312 Look for this fix in 6.0.312! platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImageButton Image not scaling down by Width- and HeightRequest
7 participants