Skip to content

Added clipBehavior to Overlay, Flow, AnimatedSize and AndroidView#65910

Merged
fluttergithubbot merged 5 commits intoflutter:masterfrom
thecalamiity:issue-63246
Sep 17, 2020
Merged

Added clipBehavior to Overlay, Flow, AnimatedSize and AndroidView#65910
fluttergithubbot merged 5 commits intoflutter:masterfrom
thecalamiity:issue-63246

Conversation

@thecalamiity
Copy link
Contributor

@thecalamiity thecalamiity commented Sep 16, 2020

Description

Added clipBehavior to Overlay, Flow, AnimatedSize and AndroidView.

/cc @liyuqian

Related Issues

Closes #63246

Tests

Added tests to check if the mentioned widgets can set and update their clipBehaviors.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Sep 16, 2020
Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

Thanks for writing this patch! It mostly looks good, but let's avoid the breaking change, a very lengthy process, by setting default clip to hardEdge for now. I think that would also fix some widget test failures with clip assertions.

AlignmentGeometry alignment = Alignment.center,
TextDirection? textDirection,
RenderBox? child,
Clip clipBehavior = Clip.none,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's default this to Clip.hardEdge now to avoid breaking changes. We can change the default and go through the lengthy breaking change process later.

///
/// Defaults to [Clip.none], and must not be null.
Clip get clipBehavior => _clipBehavior;
Clip _clipBehavior = Clip.none;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

RenderFlow({
List<RenderBox>? children,
required FlowDelegate delegate,
Clip clipBehavior = Clip.none,
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

///
/// Defaults to [Clip.none], and must not be null.
Clip get clipBehavior => _clipBehavior;
Clip _clipBehavior = Clip.none;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

required AndroidViewController viewController,
required PlatformViewHitTestBehavior hitTestBehavior,
required Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers,
Clip clipBehavior = Clip.none,
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

const Overlay({
Key? key,
this.initialEntries = const <OverlayEntry>[],
this.clipBehavior = Clip.none,
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto


/// {@macro flutter.widgets.Clip}
///
/// Defaults to [Clip.none], and must not be null.
Copy link
Contributor

Choose a reason for hiding this comment

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

remember to change documentation too when the default is changed to Clip.hardEdge.

_Theatre({
Key? key,
this.skipCount = 0,
this.clipBehavior = Clip.none,
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

List<RenderBox>? children,
required TextDirection textDirection,
int skipCount = 0,
Clip clipBehavior = Clip.none,
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

///
/// Defaults to [Clip.none], and must not be null.
Clip get clipBehavior => _clipBehavior;
Clip _clipBehavior = Clip.none;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@liyuqian liyuqian requested a review from goderbauer September 16, 2020 18:11
@thecalamiity
Copy link
Contributor Author

@liyuqian Did the same to AndroidView and AnimatedSize because some tests were failing

Copy link
Contributor

@liyuqian liyuqian left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@override
void paint(PaintingContext context, Offset offset) {
context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintWithDelegate);
if(clipBehavior == Clip.none) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: space after if and before (.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :D

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

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

This is already merged, but I think that line of code needs to be reexamined. I will submit an issue to double check it.

// (see comment in _paintTexture for an explanation of when this happens).
if (size.width < _currentAndroidViewSize.width || size.height < _currentAndroidViewSize.height) {
context.pushClipRect(true, offset, offset & size, _paintTexture);
if (size.width < _currentAndroidViewSize.width || size.height < _currentAndroidViewSize.height && clipBehavior != Clip.none) {
Copy link
Contributor

Choose a reason for hiding this comment

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

&& has higher precedence than ||

I have no idea what the logical flow was intended to be here, but it looks wrong.

Copy link
Member

Choose a reason for hiding this comment

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

That does look wrong. Wanna send a PR to fix it?

Copy link
Contributor

Choose a reason for hiding this comment

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

See #67343

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree it's wrong. Thanks for finding it!

Copy link
Contributor Author

@thecalamiity thecalamiity Oct 7, 2020

Choose a reason for hiding this comment

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

So sorry for this guys 😞 I somehow missed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add clipBehavior to Overlay, Flow, AnimatedSize, and AndroidView

6 participants