Skip to content

Conversation

@HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Dec 19, 2016

Fixes #7289
Fixes #5306

List<Invocation> commands = canvas.invocations.where((Invocation invocation) {
return invocation.memberName == #clipPath || invocation.memberName == #drawImageRect;
}).toList();
expect(commands.length, equals(2));
Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw, you don't need to say equals(2), you can just say 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point; done

/// * If [backgroundImage] is null, this decoration does not paint a background image.
/// * If [border] is null, this decoration does not paint a border.
/// * If [borderRadius] is null, this decoration use more efficient background
/// * If [borderRadius] is null, this decoration uses more efficient background
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to just be a bald-faced lie. We totally ignore the border radius when drawing the background image, as far as I can tell.

Maybe that's another bug? We don't clip the background image to the border radius?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added support for clipping the backgroundImage when borderRadius is specified.

screenshot

@Hixie
Copy link
Contributor

Hixie commented Dec 20, 2016

LGTM. Please file a bug about the border radius not clipping the background image.

new BoxDecoration(
borderRadius: new BorderRadius.all(const Radius.circular(16.0)),
backgroundImage: backgroundImage,
),
Copy link
Contributor

Choose a reason for hiding this comment

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

i guess we should have a control test too that verifies there's no clip if it's not one of these...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch. I've added one.

@Hixie
Copy link
Contributor

Hixie commented Dec 20, 2016

That's awesome. LGTM! :-)

if (clipPath != null) {
canvas.save();
canvas.clipPath(clipPath);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we already hit test correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The BoxDecoration hitTest() method appears to DTRT for the BoxShape.circle and borderRadius!=null scenarios. I don't think there's a hitTest test though.

@HansMuller HansMuller merged commit c9c577a into flutter:master Dec 20, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BoxDecoration with BoxShape.circle doesn't clip backgroundImage Option to correctly clip BackgroundImage in CircleAvatar

4 participants