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

Use Background as Fill, if Fill is null in Shapes #14216

Merged
merged 9 commits into from
Apr 26, 2023
Merged

Use Background as Fill, if Fill is null in Shapes #14216

merged 9 commits into from
Apr 26, 2023

Conversation

jsuarezruiz
Copy link
Contributor

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.

image

Before
shapes-background-before

After
shapes-background-after

Issues Fixed

Fixes #13688

@jsuarezruiz jsuarezruiz added t/bug Something isn't working area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing labels Mar 27, 2023
@@ -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)
Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments.

@rmarinho rmarinho merged commit 22dc87e into main Apr 26, 2023
29 checks passed
@rmarinho rmarinho deleted the fix-13688 branch April 26, 2023 18:47
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shadow does not work as expected on Android vs Windows
3 participants