-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Scroll TCP to track currently edited in active MIDI editor v0.5
- Loading branch information
1 parent
f686e0a
commit 0d8b705
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Various/talagan_Scroll TCP to track currently edited in active MIDI editor.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--[[ | ||
@description Scroll TCP to track currently edited in active MIDI editor | ||
@version 0.5.0 | ||
@author Ben 'Talagan' Babut | ||
@donation https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1¤cy_code=EUR | ||
@license MIT | ||
@metapackage | ||
@provides | ||
[main=main,midi_editor] . | ||
@changelog | ||
Initial release. | ||
@about | ||
It may happen that you are working in the MIDI editor and want to access the edited track TCP's but unfortunately, it's not on screen, you | ||
don't want to scroll by yourself, and you don't want to break your track selection. | ||
This action can be used to scroll the TCP to have the currently edited MIDI take's track at the top, so you can interract with the track | ||
controls and keep your track selection and the rest of your current screen layout intact. | ||
There's a good chance that if you need this, you'll use it as a small brick in custom actions in conjunction with other ones | ||
(scroll, resize, fit, etc). | ||
--]] | ||
|
||
|
||
-- Using X-Raym's X-Raym_Scroll vertically to first selected track.lua | ||
-- Thanks Raymond ! | ||
function ScrollTrackToTop( track ) | ||
reaper.PreventUIRefresh( 1 ) | ||
|
||
local track_tcpy = reaper.GetMediaTrackInfo_Value( track, "I_TCPY" ) | ||
|
||
local mainHWND = reaper.GetMainHwnd() | ||
local windowHWND = reaper.JS_Window_FindChildByID(mainHWND, 1000) | ||
local scroll_retval, scroll_position, scroll_pageSize, scroll_min, scroll_max, scroll_trackPos = reaper.JS_Window_GetScrollInfo( windowHWND, "v" ) | ||
reaper.JS_Window_SetScrollPos( windowHWND, "v", track_tcpy + scroll_position ) | ||
|
||
reaper.PreventUIRefresh( -1 ) | ||
end | ||
|
||
local function proceed() | ||
|
||
local me = reaper.MIDIEditor_GetActive() | ||
if not me then return end | ||
|
||
local take = reaper.MIDIEditor_GetTake(me); | ||
if not take then return end | ||
|
||
local track = reaper.GetMediaItemTake_Track(take); | ||
if not track then return end | ||
|
||
ScrollTrackToTop(track); | ||
|
||
end | ||
|
||
proceed(); | ||
|