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

Add CroppedRegionChanged event for ImageCropper. #3179

Conversation

HHChaos
Copy link
Contributor

@HHChaos HHChaos commented Mar 22, 2020

Fixes #3163

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:x

  • 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

@ghost
Copy link

ghost commented Mar 22, 2020

Thanks HHChaos 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 🙌

@ghost ghost assigned michael-hawker Mar 22, 2020
Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

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

It looks like there are inconsistencies to when this event fires. Initially, it only fires after moving the thumb and letting go of the mouse a single time, but if you then drag the image around it fires constantly as the image is moving. It looks like there are discrepancies between when the CroppedRegion property is updated during ManipulationDeltas vs. ManipulationCompleteds between the image and the thumbs.

It feels like there should there be two events, one which occurs as the region is changing do to the deltas, and another when the manipulations are completed? We could call them CropRegionManipulationDelta that's fired constantly as the thumbs or image are moving vs. CropRegionManipulationCompleted which fires only after a thumb or image manipulation with the mouse has finished?

We of course also need to document these behaviors and add an event section to the documentation here.

Thanks!

@michael-hawker michael-hawker added this to the 6.1 milestone Mar 24, 2020
…ppedRegionChangedEventArgs.cs

Co-Authored-By: Michael Hawker MSFT (XAML Llama) <[email protected]>
@ghost
Copy link

ghost commented Mar 25, 2020

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

@HHChaos
Copy link
Contributor Author

HHChaos commented Mar 28, 2020

It looks like there are inconsistencies to when this event fires. Initially, it only fires after moving the thumb and letting go of the mouse a single time, but if you then drag the image around it fires constantly as the image is moving. It looks like there are discrepancies between when the CroppedRegion property is updated during ManipulationDeltas vs. ManipulationCompleteds between the image and the thumbs.

It feels like there should there be two events, one which occurs as the region is changing do to the deltas, and another when the manipulations are completed? We could call them CropRegionManipulationDelta that's fired constantly as the thumbs or image are moving vs. CropRegionManipulationCompleted which fires only after a thumb or image manipulation with the mouse has finished?

We of course also need to document these behaviors and add an event section to the documentation here.

Thanks!

This is because dragging the thumb does not necessarily cause the CroppedRegion to change, although it seems that the CroppedRegion has changed. CroppedRegion only changes when the image is moved or zoomed (it can be understood that a change in the viewport will cause a CroppedRegion change). I want to know what you think about this. Is it acceptable?

@michael-hawker
Copy link
Member

@HHChaos yeah I understand the rationale of the current implementation. I'm just commenting from actually playing with the event from the development side, it doesn't seem as useful when the two scenarios (resizing area vs. changing image size/pos) behave differently.

I feel like based on the events we do have, it shouldn't be too hard to split apart into two sets of events for when there's any change vs. when it's completed?

I'm pretty sure this'll help developers in different scenarios too when they're providing immediate feedback on the cropped region's size with the delta or having to perform another step after the user's finished their manipulation.

From looking at the code in ImageCropper.Events.cs, I think we have enough flexibility to make these distinctions as we have the underlying ManipulationDelta/Completed events for the Thumbs or the Images. We'd just have to map those to our own versions for the CroppedRegion update and just tighten it up a bit.

@michael-hawker
Copy link
Member

@HHChaos also, if it helps, I did this initial review all on a live stream starting here. We jump to another PR for a bit while the app compiles, but you can see me testing the scenario out first-hand live here and discussing with some other community members about separating these concerns.

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
///为< 请参阅cref = “ ImageCropper.CroppedRegionChanged ” />事件提供事件数据。
Copy link
Member

Choose a reason for hiding this comment

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

Looks like something happened with GitHub accepting the comment? This is causing the CI to fail as it's not a valid XML doc comment anymore.

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 seems that github accepted the changes that were automatically translated by Google Translate (because my chrome automatically translated the webpage into Chinese), maybe it should be a github bug? 🤣
Let me fix it.

@HHChaos
Copy link
Contributor Author

HHChaos commented Apr 1, 2020

@HHChaos yeah I understand the rationale of the current implementation. I'm just commenting from actually playing with the event from the development side, it doesn't seem as useful when the two scenarios (resizing area vs. changing image size/pos) behave differently.

I feel like based on the events we do have, it shouldn't be too hard to split apart into two sets of events for when there's any change vs. when it's completed?

I'm pretty sure this'll help developers in different scenarios too when they're providing immediate feedback on the cropped region's size with the delta or having to perform another step after the user's finished their manipulation.

From looking at the code in ImageCropper.Events.cs, I think we have enough flexibility to make these distinctions as we have the underlying ManipulationDelta/Completed events for the Thumbs or the Images. We'd just have to map those to our own versions for the CroppedRegion update and just tighten it up a bit.

@michael-hawker Yes, I think you are right. I will make some changes.

@HHChaos HHChaos closed this Apr 1, 2020
@michael-hawker michael-hawker removed this from the 6.1 milestone Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a OnCropChanged event to the ImageCropper
3 participants