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

Issue 70 Implement scrolling and panning in viewer #1164

Merged
merged 17 commits into from
Sep 6, 2020

Conversation

ThomasWilshaw
Copy link
Collaborator

Fixes sobotka#70

I've added basic translation functionality to the viewer. Assuing this is the right aproach I think there's some discussion to be had about specific functionality. For example, Ctrl clicking resets the image to the center of the view but doesn't affect the scaling, which is posibly not ideal?

Having just re read the original issue, do you only want this when the viewer is zoomed in?

Had to separate zoom and translate matrices to stop the zoom being applied to itelf. This also required adding separate get/set functions for each matrix and a GetCombinedMatrix() funtion.

Added those functions to other files where needed but may be wrong. Need to look at export.cpp. Gizmos are also not quite right yet either.

There's probaly a few improvements that could be made to the feel as well.

@ThomasWilshaw
Copy link
Collaborator Author

Panning is now only possible if the viewer is zoomed in.

@itsmattkc
Copy link
Contributor

itsmattkc commented Jun 5, 2020

Indeed only panning when zoomed in and there's parts of the canvas offscreen, however in addition to middle mouse it should show scrollbars and drag with the primary mouse button when the hand tool is selected (no Ctrl+drag). Those behaviors would keep it in line with the other widgets.

@ThomasWilshaw
Copy link
Collaborator Author

Okay no problem, is it correct to be doing all this through the OpenGL matrix?

Had to separate zoom and translate matrices to stop the zoom being
applied to itelf. This also required adding separate get/set functions
for each matrix and a GetcombinedMatrix() funtion.

Added those functions ot other files where needed ut may be wrong. Need
to look at export.cpp

Also changed the mouse move and press events to make translation work.
The translation needs to be scaled relative to the zoom percentage so
we get sensible movement when dragging. Dragging is also disabled when
the image is smaller than the container widget.

Re-orders the initialisation of some variables to stop a compile
warning on Travis.
If Hand Tool is selected we can now drag with a left click AS WELL AS
middle click. This keeps the view behaviour in line with other widgets
in Olive.

For simplicity it does not use handmovableview.
Original fix was wrong, this sorts it out I think. Delta values had to
be doubled as we're in Clip space (I think) and the matrix
multiplication order had to be swapped around.

Updated one of the signla/slot pairs to be simpler as we no longer need
to pass the zoom percentage back and forth.
World transform is based of the view matrix and can be used on any
QPainter that needs to draw on the canvas and move with the mouse/
zoom.
It seems like something that could come in handy elsewhere when drawing
stuff to the viewer.
Added a new function that inverts the world transform and applies it to
a point. This allows the gizmo code to work in it's own space and not
need to know is the image has been zoomed or translated.
Pixel sampler now works with a zoomed/translated image. As usual we
have to flip the y translation as OpenGl stores images upside down.

Need to look at a better way of handling this.
There are now two functions to get the full matrix for the transformed
image. One that returns as is and one that returns with the Y
translation flipped for OpenGL.

Also some minor bug fixing.
@ThomasWilshaw ThomasWilshaw marked this pull request as ready for review June 22, 2020 12:59
@itsmattkc itsmattkc merged commit ba64313 into olive-editor:master Sep 6, 2020
@ThomasWilshaw ThomasWilshaw deleted the issue_70 branch September 29, 2020 17:57
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.

[TODO] Implement scrolling/panning in a zoomed in viewer
3 participants