-- Toggle Auto zoom height selected tracks in MCP
local SIZE = 10;
--============== FUNCTION MODULE FUNCTION ========================= FUNCTION MODULE FUNCTION ============== FUNCTION MODULE FUNCTION ==============
local Fun,Load,Arc = reaper.GetResourcePath()..'/Scripts/Archie-ReaScripts/Functions'; Load,Arc = pcall(dofile,Fun..'/Arc_Function_lua.lua');--====
if not Load then reaper.RecursiveCreateDirectory(Fun,0);reaper.MB('Missing file / Отсутствует файл !\n\n'..Fun..'/Arc_Function_lua.lua',"Error",0);
return end; if not Arc.VersionArc_Function_lua("2.4.1",Fun,"")then Arc.no_undo() return end;--=====================================================
--============== FUNCTION MODULE FUNCTION ======▲=▲=▲============== FUNCTION MODULE FUNCTION ============== FUNCTION MODULE FUNCTION ==============
local Api_sws = Arc.SWS_API(true);
if not Api_sws then Arc.no_undo()return end;
Arc.HelpWindowWhenReRunning(1,"Arc_Function_lua",false);
local function GetSetSizeMCPTrack(track,numb,set);
local retval,str = reaper.GetTrackStateChunk(track,"",false);
local size = string.match(str,"SHOWINMIX%s+%S-%s+(%S-)%s");
if set == 1 then;
local size = size + numb;
if size > 1 then size = 1 end;
if size < 0 then size = 0 end;
local strSHOWINMIX = string.match(str,"SHOWINMIX.-\n");
local FirstHalfLine,SecondHalfLine = string.match(str,"(SHOWINMIX%s+%S-%s+)%S+(.-\n)");
local str2 = string.gsub(str,strSHOWINMIX,FirstHalfLine..size..SecondHalfLine);
reaper.SetTrackStateChunk(track, str2,false);
else;
return size;
end;
end;
local TrT={};
local stop;
local ProjectState2;
SIZE=(SIZE or 10)/100;
--local ProjectState2 = reaper.GetProjectStateChangeCount(0);
--[[
CountSelTrack = reaper.CountSelectedTracks(0);
for i = 1, CountSelTrack do;
Track = reaper.GetSelectedTrack(0,i-1);
GUID = reaper.GetTrackGUID(Track);
TrT[#TrT+1] = GUID;
end;
-- ]]
local function loop();
local ProjectState = reaper.GetProjectStateChangeCount(0);
if ProjectState ~= ProjectState2 then;
ProjectState2 = ProjectState;
for i = #TrT,1,-1 do;
local ByGUID = reaper.BR_GetMediaTrackByGUID(0,TrT[i]);
if ByGUID then;
local Sel = reaper.GetMediaTrackInfo_Value(ByGUID,"I_SELECTED");
if Sel == 0 then;
GetSetSizeMCPTrack(ByGUID,SIZE,1);
table.remove(TrT,i);
end;
end;
end;
local CountSelTrack = reaper.CountSelectedTracks(0);
for i = 1, CountSelTrack do;
local Track = reaper.GetSelectedTrack(0,i-1);
local GUID = reaper.GetTrackGUID(Track);
for i2 = 1, #TrT do;
if TrT[i2] == GUID then;
stop = 1;
end;
end;
if not stop then;
GetSetSizeMCPTrack(Track,-SIZE,1);
TrT[#TrT+1] = GUID;
end;
stop=nil;
end;
end;
reaper.defer(loop);
--t=(t or 0)+1
end;
loop();
Arc.GetSetToggleButtonOnOff(1,1);
reaper.atexit(Arc.GetSetToggleButtonOnOff);