Old 09-15-2009, 12:54 AM   #1
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default Drag zoom plugin

Hi all!

I have made a plugin for "drag zoom" functionality. I must admit that it doesn't work perfectly the way I wanted (details below), and I still believe this would be quite easy for Reaper developers to implement properly. Anyway, this was an interesting project, and I'm eager to hear your comments!
Big thanks to Xenakios for his tip on finding the time display window.

Notes:
- There are two parts of the time display. In the upper part the cursor is a hand, and horizontal drag scrolls the project backward/forward. Vertical drag does nothing, so it seems perfect to use it for zoom in/out. However, there is a problem - the zoom is not centered around the current position, which "runs away" (especially noticeable when zooming in). The adjustZoom() SDK function has "centermode" parameter, but I couldn't find a magic value to make it work properly (well, I tried -1, 0 and 1 )

- Curiously, in the lower part of the time display adjustZoom() works correctly, regardless of "centermode" parameter! However, in this case it is too easy to accidentally change the time selection by dragging horizontally. To prevent this, I ignore the horizontal mouse movement when zooming in lower part - this helped, but sometimes the time selection still changes.

- The plugin registers an action called "Dragzoom Extension : Show Config" which opens a simple configuration dialog. The dialog has no OK or Cancel buttons - simply closing it (e.g. with Esc key) saves the current settings.

- The "scaling" parameter is used to translate vertical movement in pixels to zoom adjustment factor (first parameter to adjustZoom()) - lower value leads to smoother zoom.

- It would be great to implement drag zoom in the MIDI editor as well, but I'm not sure if it's possible.

Please try the plugin and let me know what you think.
Attached Files
File Type: zip reaper_dragzoom.zip (27.2 KB, 349 views)
boreg is offline   Reply With Quote
Old 09-15-2009, 04:53 AM   #2
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: City
Posts: 9,617
Default

Works ok for me. Using the pre-release 311 beta.

It creates/changes the time selection every time, which changes as we zoom in and out. Nevertheless it's a great analog control over zoom.

Holding a certain key and doing the mouse motion, is that possible ?
__________________
Dialogue/FX Editor & Re-Recording Mixer
Using Latch Preview
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 09-15-2009, 06:32 AM   #3
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 847
Default

Quote:
Originally Posted by boreg View Post
However, there is a problem - the zoom is not centered around the current position, which "runs away" (especially noticeable when zooming in). The adjustZoom() SDK function has "centermode" parameter, but I couldn't find a magic value to make it work properly (well, I tried -1, 0 and 1 )
centermode values: -1 = mode set in preferences, 0 = edit or play cursor, 1 = edit cursor, 2 = center of view, 3 = mouse cursor. Maybe try 2? Let me know if you still have troubles and I can post some code to reposition the horizontal position as you please.

Quote:
- It would be great to implement drag zoom in the MIDI editor as well, but I'm not sure if it's possible.
I don't believe this is possible to do

You should lock the time selection / loop points with the locking system before calling adjust zoom, that will solve your problem. You need to use some undocumented stuff for this, let me dig it up and I'll post later.
sws is offline   Reply With Quote
Old 09-15-2009, 07:42 AM   #4
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 847
Default

Ok, there's a Reaper config variable "projsellock" that is a bitmask of locking parameters:
1 = Time selection
2 = Items (full)
4 = Envelopes
8 = Markers
16 = Regions
32 = Time signature markers
64 = Items (left/right)
128 = Items (up/down)
256 = Item edges
512 = Item controls
1024 = Loop points
16384 = Locking enabled

For Reaper 3.x, use the new project variable functions:
Code:
typedef void ReaProject;
REAPER_PLUGIN_DECLARE_APIFUNCS int (*projectconfig_var_getoffs)(const char* name, int* szout);
REAPER_PLUGIN_DECLARE_APIFUNCS void* (*projectconfig_var_addr)(ReaProject* proj, int idx);
You'll want to save the current lock state, do your zooming, then restore the state. Here's how:
Code:
int szout;
int* pLock = (int*)projectconfig_var_addr(NULL, projectconfig_var_getoffs("projsellock", &szout));
int savedLock = *pLock;
*pLock = 17409;

// ZOOM

*pLock = savedLock;
Good luck!
sws is offline   Reply With Quote
Old 09-15-2009, 10:35 AM   #5
labyrinth
Human being with feelings
 
labyrinth's Avatar
 
Join Date: Nov 2007
Location: Massachusetts, USA
Posts: 2,248
Default

Cool...hope you can lock the time change.
__________________
www.res-ref.com | Resonant Reflections
iMac 3.2 GHz (i5 4570)/16GB RAM | OSX 10.10 (Yosemite) | Interface: Focusrite 18i6
labyrinth is offline   Reply With Quote
Old 09-15-2009, 03:22 PM   #6
denmla
Human being with feelings
 
Join Date: Jul 2009
Posts: 66
Default

Thank you very much boreg!

It`s really neat but if you could lock the time-loop change and make it little more sluggish or inert would be great!
denmla is offline   Reply With Quote
Old 09-17-2009, 02:24 AM   #7
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default

Thanks for the comments folks! keep 'em coming
SWS, you're a real guru.
Will definitely have a look at this.
boreg is offline   Reply With Quote
Old 09-17-2009, 08:41 AM   #8
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default

Quote:
Originally Posted by sws View Post
centermode values: -1 = mode set in preferences, 0 = edit or play cursor, 1 = edit cursor, 2 = center of view, 3 = mouse cursor. Maybe try 2? Let me know if you still have troubles and I can post some code to reposition the horizontal position as you please.
centermode=2 didn't help either. Actually, it doesn't appear to have any effect at all - the view always "runs away" when zooming in upper half, and stays centered around the cursor in the lower half.

Quote:
Originally Posted by denmla View Post
It`s really neat but if you could lock the time-loop change and make it little more sluggish or inert would be great!
You can make it zoom slower by decreasing the "scaling" parameter in the config dialog. Default is 0.1 - try 0.05 or 0.02 and tell me if it's better.
Now, if you mean some kind of acceleration - that would be much trickier to do...

Quote:
Originally Posted by airon View Post
Holding a certain key and doing the mouse motion, is that possible ?
Do you mean holding a key and dragging, or holding a key and moving the mouse (without pressing the mouse button)?

Attached is an updated version which implements SWS suggestions for locking the selection. Enjoy, and let me know what you think!

Boris.
Attached Files
File Type: zip reaper_dragzoom.zip (27.1 KB, 258 views)
boreg is offline   Reply With Quote
Old 11-05-2009, 12:14 PM   #9
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 5,028
Default

Great plug for zooming on a laptop without a scroll wheel mouse. And the difference between dragging in the "upper half" and teh "lower half" works well when you get used to it.

Thanks
__________________
// MVHMF
Vote for the Starter Marker FR here http://forum.cockos.com/project.php?issueid=4371
Let's finally get rid of those ugly odd time measures.
Fabian is offline   Reply With Quote
Old 08-15-2010, 06:40 PM   #10
Reflected
Human being with feelings
 
Reflected's Avatar
 
Join Date: Jul 2009
Posts: 1,922
Default

Not perfect...but I'm surprised.
I wouldn't even dream that it is possible to do it with extensions

hope that you will update it.
Thanks a lot!
Reflected is offline   Reply With Quote
Old 08-15-2010, 07:01 PM   #11
Reflected
Human being with feelings
 
Reflected's Avatar
 
Join Date: Jul 2009
Posts: 1,922
Default

a thing I don't like is when you need to drag the mouse up and leave it again and again to zoom out because the screen limit.

[img]http://img824.**************/img824/9745/lim.gif[/img]
Reflected is offline   Reply With Quote
Old 08-15-2010, 07:06 PM   #12
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

Same here, waiting on this one! Also it seems like that if this plugin functions to do something like this from the timeline, that one could be written to do this. I'm not a coder, so I do know.

Thanks, Wyatt
WyattRice is offline   Reply With Quote
Old 08-16-2010, 12:17 PM   #13
jedstar2000
Human being with feelings
 
jedstar2000's Avatar
 
Join Date: Apr 2009
Location: Bristol uk
Posts: 1,006
Default

Nice work most appreciated

It would be great to be able to use this from a modifier so as to be able to hover the cursor over a part of a waveform an zoom in / out
__________________
...............Reaper the DIY DAW.....................
MultiTrack Editing Macros http://forum.cockos.com/showthread.php?t=50111
Hybrid Theme http://forum.cockos.com/showthread.php?t=131090
jedstar2000 is offline   Reply With Quote
Old 08-17-2010, 03:26 AM   #14
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default

Thanks for the feedback folks!
Hope I'll find the time to update the plugin.

@Reflected - I agree, it's a problem, but how do you see it solved?
I was thinking of separate scaling factors for upward and downward movement - this would allow you to make zoom out faster than zoom in. Would this help?
boreg is offline   Reply With Quote
Old 08-17-2010, 09:13 AM   #15
Reflected
Human being with feelings
 
Reflected's Avatar
 
Join Date: Jul 2009
Posts: 1,922
Default

Quote:
Originally Posted by boreg View Post
@Reflected - I agree, it's a problem, but how do you see it solved?
I was thinking of separate scaling factors for upward and downward movement - this would allow you to make zoom out faster than zoom in. Would this help?
if it will work faster it may confuse the sense of balance.

not sure if you can do that from your side, but I think that limiting the mouse dragging area to a vertical area 2cm above the timeline could work well, so everytime you go to the end of the screen while dragging, it will get back to the timeline area automatically while you keep dragging up.
Reflected is offline   Reply With Quote
Old 08-17-2010, 09:27 AM   #16
Subz
Human being with feelings
 
Subz's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,918
Default

Woe!!!

Interesting extension!!

hope you find the time to make it what it can be

Thanks

Subz
Subz is offline   Reply With Quote
Old 09-26-2010, 07:50 PM   #17
PitchSlap
Human being with feelings
 
PitchSlap's Avatar
 
Join Date: Jan 2008
Location: Vancouver, BC
Posts: 3,121
Default

Wow, I forgot how amazing drag-zoom is (especially on a laptop)! I really hope this is a native feature soon.

Btw, has anyone figured out a way to use this without it changing the play cursor and loop points?
__________________
FRs: v5 Media Explorer Requests, Global Quantization, Session View
Win10 64-bit, Reaper 5(x64), Core i7-5700HQ, 16GB RAM, GeForce GTX 960M, SSD
PitchSlap is offline   Reply With Quote
Old 04-11-2011, 01:14 PM   #18
Reflected
Human being with feelings
 
Reflected's Avatar
 
Join Date: Jul 2009
Posts: 1,922
Default

any updates?

maybe it will be a good idea to use middle button at the time ruler to drag zoom instead of left click, this way there will be less conflicts with the time selection.
Reflected is offline   Reply With Quote
Old 04-13-2011, 03:53 AM   #19
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default

Sorry man, don't know when I'll have the time for it. I'll be happy to share the code (which is very simple btw) if anyone wants to take over.
boreg is offline   Reply With Quote
Old 04-13-2011, 06:17 AM   #20
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 847
Default

Boreg, I can integrate your code into SWS if you're OK with that.

Tim

Last edited by sws; 04-13-2011 at 06:56 AM. Reason: spam prevention
sws is offline   Reply With Quote
Old 04-13-2011, 06:47 AM   #21
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default

Tim, that would be great!
Email sent.
boreg is offline   Reply With Quote
Old 04-13-2011, 07:05 AM   #22
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

Wow,
Can't wait for this one.
WyattRice is offline   Reply With Quote
Old 04-17-2011, 03:25 AM   #23
pbk
Human being with feelings
 
pbk's Avatar
 
Join Date: Jul 2009
Location: Afford Slaughterhouse, FL
Posts: 618
Default

Any updates on using this inside the MIDI editor?
__________________
It takes an ordered complex system to recognize another ordered complex system.
pbk is offline   Reply With Quote
Old 04-17-2011, 03:49 AM   #24
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 147
Default

Quote:
Originally Posted by pbk View Post
Any updates on using this inside the MIDI editor?
AFAIK Reaper currently does not provide a function for setting zoom level in the MIDI editor. Dunno if the upcoming V4 is going to have one - if not, guess we're out of luck...
boreg is offline   Reply With Quote
Old 05-17-2011, 07:18 AM   #25
sws
Code Monkey
 
sws's Avatar
 
Join Date: Sep 2007
Location: Madison, WI
Posts: 847
Default

SWS beta #23 has Boreg's dragzoom code merged!

(Also, a confirmation that MIDI editor drag zoom is unlikely.)
sws is offline   Reply With Quote
Old 05-17-2011, 08:02 AM   #26
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

Quote:
Originally Posted by sws View Post
SWS beta #23 has Boreg's dragzoom code merged!
Nice Tim and Boreg. Thanks!
WyattRice is offline   Reply With Quote
Old 05-17-2011, 10:30 AM   #27
musicbynumbers
Human being with feelings
 
musicbynumbers's Avatar
 
Join Date: Jun 2009
Location: brighton, uk
Posts: 12,279
Default

Indeed thanks to both of you!

Apart from a few little reported bugs it's super smooth compared to most other daws!
musicbynumbers is offline   Reply With Quote
Old 05-17-2011, 11:07 AM   #28
Evan
Human being with feelings
 
Evan's Avatar
 
Join Date: Oct 2006
Location: Greece
Posts: 3,518
Default

Thank you very much for this!

And a reminder for the FR for this feature

http://forum.cockos.com/project.php?issueid=1723

Please vote those who are interested!
Evan is offline   Reply With Quote
Old 05-17-2011, 12:33 PM   #29
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: City
Posts: 9,617
Default

Hmm. That's a great idea I had not voted on yet.I use Live as well, so I'd like something like that. I'd probably use it in the timeruler mouse modifier context .

Thanks for the plugin udpate. Fine indeed.
__________________
Dialogue/FX Editor & Re-Recording Mixer
Using Latch Preview
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 05-17-2011, 02:02 PM   #30
spikemullings
Human being with feelings
 
spikemullings's Avatar
 
Join Date: Aug 2007
Location: East London
Posts: 1,697
Default

Completely fantastic. Thank you.
This would be great for a "set such and such a mouse modifier action to marquee zoom" type action just like the brilliant one for freehand draw envelopes.
__________________
Cloth-Eared Hobbyist
http://www.reverbnation.com/spikemullings
spikemullings is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.