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

canvas zoom and scroll with mousewheel #1659

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

Ant1r
Copy link
Contributor

@Ant1r Ant1r commented May 1, 2022

Zoom and scroll with the mouse wheel, like most modern software.

zoom

The code is adapted from https://wiki.tcl-lang.org/page/Canvas+zooming+using+mousewheel.
It will also allow to clean up the GUI C code from every IEMGUI_ZOOM() occurrences and logic ;-)

Note: the current zoom factor could be reported to the Pd-core side, in order to be saved to file.

@Ant1r
Copy link
Contributor Author

Ant1r commented May 2, 2022

Trying to update the line-width of lines and rectangles:

scrollzoom-linewidth-1

@umlaeute
Copy link
Contributor

umlaeute commented May 2, 2022

oh shit.

@Spacechild1
Copy link
Contributor

That's just awesome! Pd badly needs a proper zoom function...

@Ant1r
Copy link
Contributor Author

Ant1r commented May 13, 2022

"Almost" good here!
At least edition is now possible in a zoomed canvas.
Still some bugs, with "undo" for example.
Scrolling to the zooming center still to be done too.

@Ant1r
Copy link
Contributor Author

Ant1r commented May 14, 2022

I think it's about ready.
I've fixed some bugs, and added scrolling with mouse button 2 (scrollwheel button). Very pleasant...
Please test!

@Ant1r Ant1r marked this pull request as ready for review May 14, 2022 15:34
@Ant1r Ant1r changed the title [feature] POC control-mousewheel canvas zoom [feature] canvas zoom and scroll with mousewheel May 14, 2022
tcl/pd_canvaszoom.tcl Outdated Show resolved Hide resolved
tcl/pd_canvaszoom.tcl Outdated Show resolved Hide resolved
@umlaeute
Copy link
Contributor

umlaeute commented May 30, 2022

the current zoom factor should be reported to the Pd-core side, in order to be saved to file.

i honestly don't think so.
this could be saved entirely on the GUI side via ::pd_guiprefs::write (resp ::pd_guiprefs::read)

@umlaeute
Copy link
Contributor

i wonder whether the internal zoom-state should (also) be kept as a "step" value, so it's easier to reset to zoom=0 (and when saving the zoom-amount to a preferences file, we can store simple integers and don't have to worry about precision)

this would of course totally break if the zoom-factor was changeable.

@Ant1r
Copy link
Contributor Author

Ant1r commented May 30, 2022

this could be saved entirely on the GUI side via ::pd_guiprefs::write (resp ::pd_guiprefs::read)

I was thinking that the zoom factor could be saved per-patch, I mean both zoom factor and scrolling position can be seen as part of the final presentation of the patch to the user.

i wonder whether the internal zoom-state should (also) be kept as a "step" value

Maybe we could store something like a fractional log factor? e.g zommfactor = pow(10, zoomsteps/100) so:

-30 -> 1/2
 0  -> 1 
 30 -> 2
100 -> 10

etc... ?

@Ant1r
Copy link
Contributor Author

Ant1r commented May 30, 2022

Actually zoom factor = pow(2, steps/100) is better in order to include exact powers of 2...

@umlaeute
Copy link
Contributor

yes, sthg like that.

I was thinking that the zoom factor could be saved per-patch

hmm, interesting idea.

what i do love about this entire PR, is that it it's totally unrelated to Pd-core, and just does all the magic on the GUI side.
the only changes on the C side would be to get rid of the entire zoom-goo there.

@Ant1r
Copy link
Contributor Author

Ant1r commented May 30, 2022

Yeah, thanks, that's what I like too. I'm dreaming of a world where Pd doesn't even know how do the objects look like on the patch...

If I had more time I'd love to try recoding my entire new knob in TCL, as an exercise. I wonder what change in the core would be needed, if any.
((edit) I meant rewriting in TCL the purely GUI part of the knob)

@umlaeute umlaeute linked an issue Aug 29, 2022 that may be closed by this pull request
@umlaeute umlaeute added the feature suggestion for an enhancement label Sep 5, 2022
@Spacechild1 Spacechild1 changed the title [feature] canvas zoom and scroll with mousewheel canvas zoom and scroll with mousewheel Sep 14, 2022
@Ant1r
Copy link
Contributor Author

Ant1r commented Sep 27, 2022

internal zoom-state should (also) be kept as a "step" value

done. Now the depth is expressed in steps, and the actual depth is pow(2, steps / 100).
zsteps is kept within the [-400 , 400] range, so zdepth remains within [1/16 , 16].

@Ant1r
Copy link
Contributor Author

Ant1r commented Apr 9, 2023

This PR has been brought up to date.

I would appreciate it being tested in a variety of circumstances, so that we can insist to have it included.
My own tests show no obvious problem.

@Ant1r
Copy link
Contributor Author

Ant1r commented Jun 21, 2023

This PR has been updated to latest master, and debugged for MacOS and Windows.

@Ant1r Ant1r mentioned this pull request Jun 29, 2023
@Spacechild1
Copy link
Contributor

I already gave many thumbs up, but I haven't come around to actually test it yet. I will put this on my list and then lobby relentlessly to have this included in Pd 0.55 :)

@pingarelho
Copy link

pingarelho commented Dec 21, 2023

Firstly, thank you for this PR, I have been using it extensively for the past month.

I noticed that when zooming in and out, and then going to the properties screen and clicking ok, the label and the value of a [nbx], for instance, can change a bit. Video below for reference.

zoom_pr.mp4

@Ant1r
Copy link
Contributor Author

Ant1r commented Dec 22, 2023

Thanks for the feedback, I'll check that as soon as I can (which won't be for a good week).

Ant1r and others added 24 commits March 14, 2024 22:12
simplifying the MouseWheel bindings (and prepare for Ctrl-+ resp Ctrl--)
- the  "Zoom New Windows" setting is now saved to {pd_guiprefs}/default_zoom.conf
- the old .pdsettings::zoom is ignored
- LATER: allow other default_zoom values than 0(100%) or 100(200%)
better keeping immobile the content under the mouse
(and give up trying to do it on scrolling, no working solution was found)
(except for text items and rectangular selection outline)
@Ant1r
Copy link
Contributor Author

Ant1r commented Mar 14, 2024

updated and rebased.

@sebshader
Copy link
Contributor

wouldn't it be more complete/consistent if the c-side zoom logic were taken out as well?

@Ant1r
Copy link
Contributor Author

Ant1r commented Mar 25, 2024

Of course I'm all for doing it, but let's see if it's worth the effort...

@Ant1r
Copy link
Contributor Author

Ant1r commented Apr 15, 2024

@millerpuckette have you had a chance to test this one?

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

Successfully merging this pull request may close these issues.

Offer more than two zoom settings
6 participants