function motion()
counttracks = reaper.CountTracks(0)
if counttracks == nil then return end
for i = 1, counttracks do
track = reaper.GetTrack(0, i-1)
ftr = reaper.GetParentTrack(track)
ttr = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
if ftr ~= nil and (ttr == 0 or ttr == -1 or ttr == -3) then
htr = reaper.GetMediaTrackInfo_Value(track, "I_WNDH")
if htr >= 24 then
reaper.SetMediaTrackInfo_Value( track, "B_SHOWINMIXER", 1)
else
reaper.SetMediaTrackInfo_Value( track, "B_SHOWINMIXER", 0)
end
end
end
reaper.TrackList_AdjustWindows(false)
reaper.defer(motion)
end
-- Set ToolBar Button ON
function SetButtonON()
is_new_value, filename, sec, cmd, mode, resolution, val = reaper.get_action_context()
state = reaper.GetToggleCommandStateEx( sec, cmd )
reaper.SetToggleCommandState( sec, cmd, 1 ) -- Set ON
reaper.RefreshToolbar2( sec, cmd )
end
--
-- Set ToolBar Button OFF
function SetButtonOFF()
is_new_value, filename, sec, cmd, mode, resolution, val = reaper.get_action_context()
state = reaper.GetToggleCommandStateEx( sec, cmd )
reaper.SetToggleCommandState( sec, cmd, 0 ) -- Set OFF
reaper.RefreshToolbar2( sec, cmd )
end
----------------------------------------------------------------------------------------------------
SetButtonON() -- функция запуска срипта с "поджигом" кнопки тулбара
motion() -- основная функция дефера
reaper.atexit(SetButtonOFF) -- выход из скрипта с запуском функции выхода с тушением кнопки тулбара