Old 09-15-2009, 12:54 AM   #1
boreg
Human being with feelings
 
Join Date: Jul 2009
Posts: 162
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, 584 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: Berlin
Posts: 11,817
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 ?
__________________
Using Latch Preview (Video) - Faderport 16 setup for CSI 1.1 , CSI 3.10
Website
"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: 857
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: 857
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: 121
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: 162
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
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:16 AM.


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