Only use custom image sizing with ImageButtons#18521
Merged
Conversation
e793874 to
e6cb278
Compare
e6cb278 to
dd8ffdd
Compare
emaf
previously approved these changes
Nov 7, 2023
dd8ffdd to
0e70ec9
Compare
ImageButtons have a null value for CurrentTitle and can't have Text on them, giving us a way to distinguish Imagebuttons from normal buttons. Normal buttons with images should still use the standard sizing logic
0e70ec9 to
9253782
Compare
PureWeen
approved these changes
Nov 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Updates on the image resizing #17120 affected normal buttons with images, causing them to call the custom image sizing logic. The updates made images to occupy the space they are provided in respect to their constraints. This fixed
ImageButtonandImagebut adversely affectedButton.Standard
Buttonsdon't have control over their image dimensions, but do have control on how they want to lay these images out them out. Calling the new logic removes this functionality and causes buttons to occupy their available space/occupy the space requested by the image (which would ignore the text in the button).Solution
Use the old sizing logic with normal
Buttonsbut still use the new sizing logic forImageButton. We can differentiate them based on the value of the native view'sCurrentTitle.ImageButtonscan't have text and have anullvalue forCurrentTitle, so we add this check before using the image resizing logic.Note: Even if a
Buttonhas noTextvalue (or its ""), the native control will have a non-nullCurrentTitlethat'll just be the empty string. This is included in the tests I'm addingBefore & After
18504 (click me!)
18655 (click me!)
Copy source from sample project: https://github.com/zwikk/maui-playground/blob/main/Source/ButtonImageSource/ButtonImageSource/MainPage.xaml
Issues Fixed
Fixes #18504
Fixes #18655
Remaining work