Skip to content

Fixed Android RoundRectangle border logic#17087

Merged
rmarinho merged 4 commits intomainfrom
dev/jestedfa/issue14276+14936
Aug 30, 2023
Merged

Fixed Android RoundRectangle border logic#17087
rmarinho merged 4 commits intomainfrom
dev/jestedfa/issue14276+14936

Conversation

@jstedfast
Copy link
Member

@jstedfast jstedfast commented Aug 29, 2023

Description of Change

  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.

Issues Fixed

Fixes #14276
Fixes #14936

BorderAlignment

BorderResizeContent.mp4

BorderStrokeOptions

BorderUsingLayouts.mp4
BorderUsingStyles.mp4
BorderClippingPlayground.mp4
BorderPlayground.mp4

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)
@jstedfast jstedfast marked this pull request as ready for review August 30, 2023 00:37
@jstedfast jstedfast requested a review from a team as a code owner August 30, 2023 00:37
@rmarinho rmarinho merged commit b420f50 into main Aug 30, 2023
@rmarinho rmarinho deleted the dev/jestedfa/issue14276+14936 branch August 30, 2023 15:00
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2023
@samhouts samhouts added the fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/android

Projects

None yet

3 participants