Video panning fixes and improvements#542
Conversation
|
The renames are of course subjective so let me know if you disagree with something. |
This makes sense and is a good change, but I'd still like to point out that panning out ot bounds can be useful when Typesetting. Of course, you never really need to go extremely far out, but depending on how tight this limit is, it could get in the way. |
I know, that's why I used the following formula: When panning the video e.g. to the right, this ensures the distance between the left edge of the video and the right edge of the viewport is at least 10% of the viewport width. ( I'm not particularly attached to this formula. We could lower the 10% value, or change it to be an absolute size (that might not be a bad idea actually). The formula also prevents moving the video to the corner when it is zoomed out to be smaller than 10% of the viewport, so a special case could be added for that. Note that when you are trying to bring something far out of video bounds into view (e.g. rotation origin), it's usually better to do that by zooming out rather than panning, as when panning you don't really see where you are. And if it turns out there is a usecase that is broken by this change, we could add an option to disable the limit. |
|
Thanks!
Yeah, this mostly had historical reasons. Back when video panning wasn't possible, the Nit 1: Typo
Carrying on with the trend of distinguishing all the various sizes we're juggling around, maybe
Oh, neat! When implementing gesture support I was testing on a Mac (since none of my standard setups have both Wayland and a touchpad), and there the zoom gesture is only a zoom with no panning. So I didn't realize that wx's gestures on other platforms do also include panning. Thanks for noticing this! Touchpad zooming on Wayland does indeed feel much better now. Comment: Can you add some comment explaining what coordinate system
The limit you chose is pretty much what I would also have intuitively chosen if I had been forced to pick a limit. I don't think it should impair the user during normal typesetting: If the user needs to pan this far out of bounds then chances are that whatever they're doing is suboptimal or will have bad performance. The one use case I can imagine where this could hurt is when trying to fix some existing broken line/clip/etc (as opposed to purposefully creating a line/clip point so far outside). Maybe a bug in Aegisub or some script created a clip or line that's positioned extremely far away, and the user want to fix it using the visual tools. But:
So I think this case can safely be ignored and the panning limit can be kept.
Thanks for mentioning this; I tested it and everything works correctly. |
9003b52 to
6db0fd7
Compare
Oops, fixed.
This is likely a result of me first making the changes in a different order and then rewriting history to put all renames up front. Will fix.
Yes, that's basically correct. I have rebased the PR and will address the rest of your feedback shortly. |
6db0fd7 to
cafb739
Compare
Actually, no, it was intentional. The variable actually does contain the viewport center — not the content center, as panning has not been applied to it. I admit this is a bit confusing, which is actually one of the reasons I rewrote that code. I have added some comments explaining the anchor points in detail. You can review them now. There may still be some minor inconsistencies in terminology (content vs video, screen position vs canvas position). I will try to go through the code and comments and gather all the relevant terms used, so we can consider if we want to unify them. |
d376113 to
2cba336
Compare
The code referred to the virtual area where the video frame is located
as the 'viewport', which is not the correct use of the term. Change the
terminology to the following:
- 'Viewport' refers to the intended area inside which the video
should be displayed (the "window" we are looking through). When
possible, it should be the same as the client area, but this cannot
be guaranteed.
- 'Content' refers to the whole video frame, with panning and scaling
applied. When panning is active, it will extend outside the
viewport.
- 'Window zoom' refers to the ratio between the video resolution and
the viewport size.
- 'Content zoom' refers to the ratio between the viewport size and the
content size.
85c20b3 to
d95174f
Compare
The previous code incorrectly added unscaled panning to a value (`unpannedVideoCenter`) which, despite the name, already had panning applied. This was wrong both because the padding was applied twice and because the added padding wasn't properly scaled. However, due to the missing scaling, the added value was not very large, so the effect of the error was typically small. The code also didn't take into account the fact that on some platforms, a touchpad or touchscreen zoom gesture should not only zoom, but also pan the video, resulting in very unnatural zooming behavior when the "zoom center" moved during the gesture. Fix both issues by rewriting the code using an "anchor point" concept, where the position of the zoom center is converted to video-relative coordinates to obtain an anchor point, and when the zoom center moves, the panning is adjusted so that the anchor point always follows the zoom center.
d95174f to
4f9690f
Compare
|
I believe I have now addressed all your feedback. I have also updated more doc comments, adding more detailed descriptions and unifying some terminology. The actual allocated area is now referred to as the client area, its size as client size, and client position is used to refer to position relative to it. Almost all uses of the term canvas have been eliminated. |
|
Thanks again! |
This PR can be conceptually divided into two parts. The first part contains only renames and comment changes and consists of:
The second part contains the actual improvements and consists of:
These changes make zooming/panning behave much nicer, especially with touchpads.
As an example, here is a comparison of mouse wheel zooming before and after. Notice how in the 'before' video, the position slips by about 5 pixels, while in the 'after' video, the position stays within 0.5px from the initial one.
Video comparison
before.mp4
after.mp4
The touchpad improvements are much more significant, but hard to show on a video without also recording the touchpad.
Also, the maximum panning distance is limited, so that you don't accidentally move the video out of view when zooming and get lost in the vast black area.
The changes weren't tested with DPI scaling. I believe I shouldn't have broken anything, but it needs to be verified.