-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use Background as Fill, if Fill is null in Shapes #14216
Conversation
@@ -13,10 +13,13 @@ protected override MauiShapeView CreatePlatformView() | |||
|
|||
public static void MapBackground(IShapeViewHandler handler, IShapeView shapeView) | |||
{ | |||
handler.UpdateValue(nameof(IViewHandler.ContainerView)); | |||
handler.ToPlatform().UpdateBackground(shapeView); | |||
if (shapeView.Background is not null && shapeView.Fill is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want both? don't we want one or other to always update ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be somewhat confusing. The background will be applied to the View background, in a Shape is the background rectangle. With the changes in the PR we are now using Fill to set the Shape background (not to be confused with the view) and if Fill is null, use the Background to fill the Shape. If Fill and Background are not null, will use Fill for the Shape background and Background for the ShapeView background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment here so everyone understand in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments.
Description of Change
To draw Shapes we use
ShapeView
. The Background property defines the background color or gradient of the ShapeView (rectangle based on the height and width of the control). Inside the ShapeView a Shape is drawn, for example an Ellipse, where the shape background color is defined with the Fill property. If a shadow is set, it is drawn following the shape between the Shape and the background.But if the Fill property is not set and the Background is set, the background of the View is actually drawn but not the Shape. For this reason, the Shadow is not rendered (it has no shape to follow). Check the behavior of the Shadows using Background example with an Ellipse before the changes.
This PR include changes to use the Background property as Fill, if Fill is null in Shapes. This would avoid confusion both when drawing some Shapes like an Ellipse setting the Background property without Fill, or drawing shadows in the same scenario.
Before

After

Issues Fixed
Fixes #13688