Fixed Android RoundRectangle border logic#17087
Merged
Conversation
1. RoundRectangle.GetPath() should not do ANY comepnsation for StrokeThickness because our callers do that for us. All we need to do is draw the rounded rectangle path using the width and height as-is. 2. RoundedRectangle.GetInnerPath() needs to be consistent about using the strokeThickness argument instead of (sometimes) using the StrokeThickness property which *may* be different. e.g. MauiDrawable.Android.cs's _shape's StrokeThickness is always 1 even when that is not the StrokeThickness that has been set on the Border). 3. MauiDrawable.Android.cs MUST pass a bounds argument to _shape?.ToPlatform() because that's what is expected if we want the stroke path (which we do, despite the 'clipPath' name suggesting otherwise). 4. MauiDrawable.Android.cs's _strokeThickness, _width, and _height member variables have already been multiplied by the pixel density on the Android device, so we must divide by _density to get back "MAUI pixels" that the RoundRectangle logic needs. 5. ContentViewGroup *also* needs to divide width and height by the pixel density instead of multiplying the StrokeThickness by the pixel density because clipShape.ToPlatform() calls RoundRectangle.InnerPathForBounds() which expects "MAUI pixels" rather than Android pixel coordinates. 6. ShapeExtensions.ToPlatform() now requires a 'float density` argument that represents the Android device's pixel density so that it can scale the "MAUI pixels" to "Android pixels". 7. I suspect that BorderDrawable.cs also needs to do this, but I'm not sure how to test that theory.
TODO: make sure this passes (copied over from a previous attempt at fixing Android's RoundRectangle bugs)
rmarinho
approved these changes
Aug 30, 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.
Description of Change
Issues Fixed
Fixes #14276
Fixes #14936
BorderResizeContent.mp4
BorderUsingLayouts.mp4
BorderUsingStyles.mp4
BorderClippingPlayground.mp4
BorderPlayground.mp4