Skip to content

UIElement.ClipToBounds property #3111

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

Closed

Conversation

Sergio0694
Copy link
Member

@Sergio0694 Sergio0694 commented Jan 25, 2020

This PR is part of the group being tracked in #3108.

PR Type

What kind of change does this PR introduce?

  • Feature

What is the new behavior?

A XAML attached property that uses a composition InsetClip to clip the rendering coming from inside a given UIElement. All additional info can be found in the linked issue.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

Marking this as draft since I haven't created the PR for the docs yet, or added a sample in the app.

@ghost
Copy link

ghost commented Jan 25, 2020

Thanks for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@michael-hawker
Copy link
Member

Looks fine, but I think similar to the actual InsetClip docs themselves, I'm not really sure what to do with it. It'd be great for the docs to go with this had some examples (and some images) of how this can be used effectively.

Does the inside InsetClip that gets created need any of it's properties exposed? Should we expose it in another attached property or something?

@Sergio0694
Copy link
Member Author

Sergio0694 commented Feb 11, 2020

@michael-hawker If we want to create a sample app, and example of the visualization could be to have an item contained in some parent (eg. a Grid) with a looping scale transform animation. Users could toggle this InsetClip on and off and see the item either escaping the bounds of its parent, or get clipped when the attached property is enabled. Eg. I use this in Legere for my custom frame animations (they're not really frames): I'm using a composition animation to fade the content of a page away and back in when you navigate, and I'm using this property to clip the parent control so that the content doesn't bleed outside in the shell during the animation. I personally find this quite a handy property, as the alternative is to use the old XAML geometry clip, which requires you to listen to the SizeChanged event to update the size of the clipping rectangle.

As for additional properties, yeah, the InsetClip has the Top, Bottom, Left and RightInset properties. We could probably expose them too through another attached property of type Thickness, if we wanted, why not! I can give that a try if you want! 😊

@vgromfeld
Copy link
Contributor

vgromfeld commented Mar 25, 2020

@Sergio0694 , I have a sample ready for the ClipToBounds property.
I was working on the same property and left it aside when I've seen your PR. I can still add my old sample to your PR if you agree:

  <Grid Padding="120">
    <Grid
        BorderBrush="White"
        BorderThickness="1"
        Width="148"
        Height="148"
        extensions:FrameworkElementExtensions.ClipToBounds="@[Clip to Bounds:Bool:True]">
      <Rectangle Fill="Blue" Width="100" Height="100">
        <Rectangle.RenderTransform>
          <TranslateTransform X="-50" Y="-50" />
        </Rectangle.RenderTransform>
      </Rectangle>
      <Rectangle Fill="Green" Width="100" Height="100">
        <Rectangle.RenderTransform>
          <TranslateTransform X="50" Y="50" />
        </Rectangle.RenderTransform>
      </Rectangle>
    </Grid>
  </Grid>

@Sergio0694
Copy link
Member Author

Hey @vgromfeld - that'd be perfect, thank you!

I had quite a few things going on at the moment so I couldn't get to writing the sample down for this PR yet, so that'd help! Other than that I guess we should just decide whether to leave this extension as is or to also add some way for users to specifically set the exact margins (like @michael-hawker mentioned a while back), and then this PR should be good to go and ready for review 😄

@vgromfeld vgromfeld mentioned this pull request Mar 25, 2020
7 tasks
@Sergio0694
Copy link
Member Author

Closing this to continue the work in #3193 then 👍

@Sergio0694 Sergio0694 closed this Mar 25, 2020
@michael-hawker michael-hawker mentioned this pull request Apr 1, 2020
36 tasks
Sergio0694 added a commit to Sergio0694/UICompositionAnimations that referenced this pull request May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants