RPR adjustZoom
From CockosWiki
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR adjustZoom
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR adjustZoom
Contents |
adjustZoom()
void adjustZoom(double amt, int forceset, bool doupd, int centermode)
forceset=0,doupd=true,centermode=-1 for default
This is mostly notes from posts by sws at the moment.
centremode: -1 = mode set in preferences, 0 = edit or play cursor, 1 = edit cursor, 2 = center of view, 3 = mouse cursor.
You should lock the time selection / loop points with the locking system before calling adjust zoom
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:
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);
Save the current lock state, do your zooming, then restore the state. Like this:
int szout; int* pLock = (int*)projectconfig_var_addr(NULL, projectconfig_var_getoffs("projsellock", &szout)); int savedLock = *pLock; *pLock = 17409; // Do the ZOOMing bits *pLock = savedLock;
Parameters
double amt, int forceset, bool doupd, int centermode
Returns
void
Examples
C++
void HorizZoomSelItems() { HWND hTrackView = GetTrackWnd(); if (!hTrackView) return; RECT r; GetClientRect(hTrackView, &r); // Find the coordinates of the first and last selected item double x1 = 1.0e300, x2 = -1.0e300; for (int i = 1; i <= GetNumTracks(); i++) { MediaTrack* tr = CSurf_TrackFromID(i, false); if (GetTrackVis(tr) & 2) for (int j = 0; j < GetTrackNumMediaItems(tr); j++) { MediaItem* mi = GetTrackMediaItem(tr, j); if (*(bool*)GetSetMediaItemInfo(mi, "B_UISEL", NULL)) { double d = *(double*)GetSetMediaItemInfo(mi, "D_POSITION", NULL); if (d < x1) x1 = d; d += *(double*)GetSetMediaItemInfo(mi, "D_LENGTH", NULL); if (d > x2) x2 = d; } } } if (x1 >= 1.0e300) return; adjustZoom(0.94 * r.right / (x2 - x1), 1, false, -1); SetHorizPos(hTrackView, x1, 0.03); }
Perl
# ----------------------------------------------------------------------- # adjustZoom.pl # # syntax: # void adjustZoom(double amt, int forceset, bool doupd, int centermode) # ----------------------------------------------------------------------- use strict; use warnings; my $amt = 20; # 20 -> zoom in, -20 -> zoom out my $forceset = 0; # = 0 - allow many stages of zoom, >= 1 - zoom to level my $doupd = 0; # true / false ? my $centermode = 1; # center zoom to edit cursor RPR_adjustZoom($amt, $forceset, $doupd, $centermode);
Python
# ----------------------------------------------------------------------- # adjustZoom.py # # syntax: # void adjustZoom(double amt, int forceset, bool doupd, int centermode) # ----------------------------------------------------------------------- amt = 20; # 20 -> zoom in, -20 -> zoom out forceset = 0; # = 0 - allow many stages of zoom, >= 1 - zoom to level doupd = 0; # true / false ? centermode = 1; # center zoom to edit cursor RPR_adjustZoom(amt, forceset, doupd, centermode);
See Also
(Section automatically generated, edits may be overwritten.)
Stuff
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR adjustZoom
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR adjustZoom