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

InteractionTracker: move contents rather than widget? #302

Closed
adrientetar opened this issue Oct 14, 2018 · 8 comments
Closed

InteractionTracker: move contents rather than widget? #302

adrientetar opened this issue Oct 14, 2018 · 8 comments

Comments

@adrientetar
Copy link

So I use an InteractionTracker with a Win2D canvas control to make an infinite canvas (with zoom/pan).

When I transform the canvas' Visual, it moves the canvas widget around in the window. I'm looking to rather move (scale/zoom) the contents, without changing the geometry of the widget (sort of like the zoom in Edge I guess). How can I do that?

Code for reference: https://github.com/adrientetar/Fonte

RS5/17763

@adrientetar
Copy link
Author

Btw, I strumbled upon UIElement.RegisterAsScrollPort where docs say:

This method is intended for use by custom controls that do not use the platform's native controls to display a scrollable area. For example, a custom scrolling control could be built using InteractionTracker.

That sounds like what I'm looking for, I don't fully understand what this method does though. Is there a snippet out there using RegisterAsScrollPort?

@adrientetar
Copy link
Author

cc @crutkas if you can provide more info on how to use UIElement.RegisterAsScrollPort.

@crutkas
Copy link
Member

crutkas commented Oct 24, 2018

@adrientetar did you leave this feedback on the doc's page? Bottom right has a popup for "was this page helpful". Looking at this, I see Danielle assigned to Lindsay which would have been some of the first people i would have asked so you're in good hands.

Good job also providing a repro

@likuba
Copy link
Contributor

likuba commented Nov 13, 2018

Hey @adrientetar

I've played around with your sample a bit and I'm not sure I understand what behavior you want to change :) Typically when I think of content that can be manipulated like this I think of there being a "content" and "viewport" where the content is the canvas getting manipulated, and the viewport is the window looking into the content that is moving around.

In your case, it seems like the canvas with the letter a is being manipulated (the content) and the host of that canvas is the viewport. What are you trying to change behavior-wise here?

Thanks!

@adrientetar
Copy link
Author

adrientetar commented Nov 23, 2018

Thanks for looking at this, @likuba.

As you said I'm using InteractionTracker to scroll the canvas.

In the initial position it looks like this (in blue, I'm drawing a selection rectangle with the mouse):

image

When I scroll though, the drawing is clipped to the original viewport – the selection rectangle won't draw all the way to the edge:

image

I would like that when I scroll, I can still draw on all visible area. So I tried to make the canvas size much larger than viewport size, but the drawing area is still limited to original viewport.

Can InteractionTracker behave like ScrollViewer, where scrolling around can display more content?

@micahl
Copy link

micahl commented Dec 17, 2018

The Windows UI Library contains an InteractionTracker-based scrolling control. You could take a look at its code to see what its doing, or you could use it directly and save quite a bit of effort and code rather than create a custom scrolling control.
In fact, here's a fork of your repo that I modified to use the WinUI Scroller. It addresses the issue you initially raised. It also enables zooming via mousewheel as well as more natural motion by default. The caveat here is that the control is in 'preview' so its API may (very likely) change in the future.

@adrientetar
Copy link
Author

Wow! thanks so much Micah. Guess I'll be using Scroller and looking at the code to see how it works (;

Btw, are you guys gonna post pm specs for this control? Looking at this PR, will Scroller stop being exposed in favor of ScrollerView?

@micahl
Copy link

micahl commented Dec 18, 2018

I posted a new proposal that should start to address your question. Take a look and feel free to comment / ask more questions.

Proposal: A more flexible ScrollViewer

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

No branches or pull requests

5 participants