diff --git a/Tracks Properties/cfillion_Toggle visual spacer before or after selected tracks.lua b/Tracks Properties/cfillion_Toggle visual spacer before or after selected tracks.lua new file mode 100644 index 000000000..2a105370e --- /dev/null +++ b/Tracks Properties/cfillion_Toggle visual spacer before or after selected tracks.lua @@ -0,0 +1,28 @@ +-- @description Toggle visual spacer before or after selected tracks +-- @author cfillion +-- @version 1.0 +-- @metapackage +-- @provides +-- [main] . > cfillion_Toggle visual spacer before selected tracks.lua +-- [main] . > cfillion_Toggle visual spacer after selected tracks.lua +-- @donation https://reapack.com/donate + +local UNDO_STATE_TRACKCFG = 1 +local SCRIPT_NAME = select(2, reaper.get_action_context()):match("([^/\\_]+)%.lua$") +local MODE_AFTER = SCRIPT_NAME:match('after') + +reaper.PreventUIRefresh(1) +reaper.Undo_BeginBlock() +for i = 0, reaper.CountSelectedTracks(nil) - 1 do + local track = reaper.GetSelectedTrack(nil, i) + if MODE_AFTER then + local id = reaper.GetMediaTrackInfo_Value(track, 'IP_TRACKNUMBER') + track = reaper.GetTrack(nil, id) + end + if track then + local spacer = reaper.GetMediaTrackInfo_Value(track, 'I_SPACER') + reaper.SetMediaTrackInfo_Value(track, 'I_SPACER', spacer ~ 1) + end +end +reaper.Undo_EndBlock(SCRIPT_NAME, UNDO_STATE_TRACKCFG) +reaper.PreventUIRefresh(-1)