View Single Post
Old 04-06-2016, 08:53 PM   #58
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Ok, enough of that.

This is about the only way I can show any appreciation. There's a few scripts around for setting layouts in a fairly fancy way. I think I will use them in a simpler way for organizational purposes (colored faders.) Nothing really planned out firmly yet. Baby steps. (Also new SWS will have auto layout.)

The first two are like the set layout actions you can set up in Screensets Window, in case 20 is not enough. Use the layout name phrases you find there when you copy and edit the scripts. The editable stuff is above the dashed lines.

EDIT: Updated top two with PreventUIRefresh. Significant speed increase. Also added user editable variables to skip various tracks that are set to layouts like Separator, FX Rack, etc.
Code:
-- layout - set selected tracks TCP layout to Condensed - Gold Fader.lua

track_panel = "Condensed - Gold Fader" -- edit phrase between quotes to another from Screensets window
skip_Separators = true -- change to false to make script not skip these
skip_Long_Name = true -- change to false to make script not skip these
skip_Shy_Meter = true -- change to false to make script not skip these
skip_Tracking = true -- change to false to make script not skip these
---------------------------------------------------------------------------------------------------------------
function Fn_Set_TCP_Layout()
  reaper.Undo_BeginBlock2(0)
  reaper.PreventUIRefresh(1)
  local cst = reaper.CountSelectedTracks(0)
  for c=1,cst do
    local ok = true
    local trk = reaper.GetSelectedTrack(0, c-1)
    local r,s = reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", "", false)
    if skip_Separators == true and string.find(s,"Separator",1,true) then ok = nil
    elseif skip_Long_Name == true and string.find(s,"Long Name",1,true) then ok = nil
    elseif skip_Shy_Meter == true and string.find(s,"Shy Meter",1,true) then ok = nil
    elseif skip_Tracking == true and string.find(s,"Tracking",1,true) then ok = nil
    end
    if ok then
      reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", track_panel, true)
    end
  end
  reaper.PreventUIRefresh(-1)
  reaper.Undo_EndBlock2(0, "set TCP layout", -1)
end

Fn_Set_TCP_Layout()
Code:
-- layout - set selected tracks MCP layout to Narrow - Gold Fader.lua

mixer_panel = "Narrow - Gold Fader" -- edit phrase between quotes to another from Screensets window
skip_Separators = true
skip_Sidebars = true
skip_FX_Racks = true
---------------------------------------------------------------------------------------------------------------
function Fn_Set_MCP_Layout()
  reaper.Undo_BeginBlock2(0)
  reaper.PreventUIRefresh(1)
  local cst = reaper.CountSelectedTracks(0)
  for c=1,cst do
    local ok = true
    local trk = reaper.GetSelectedTrack(0, c-1)
    local r,s = reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", "", false)
    if skip_Separators == true and string.find(s,"Separator",1,true) then ok = nil
    elseif skip_Sidebars == true and string.find(s,"Sidebar",1,true) then ok = nil
    elseif skip_FX_Racks == true and string.find(s,"FX Rack",1,true) then ok = nil
    end
    if ok then
      reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", mixer_panel, true)
    end
  end
  reaper.PreventUIRefresh(-1)
  reaper.Undo_EndBlock2(0, "set MCP layout", -1)
end

Fn_Set_MCP_Layout()
The next two are select/unselect based on layout.

Code:
-- layout - add Condensed - Gold Fader tracks to selection.lua

track_panel = "Condensed - Gold Fader" -- edit phrase between quotes to another from Screensets window, no layout = ""
select = true -- change to false to unselect instead

------------------------------------------------------------------------------
function Fn_Select_By_Layout()
  local ct = reaper.CountTracks(0)
  for c=1,ct do
    local trk = reaper.GetTrack(0, c-1)
    local r,s = reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", "", false)
    if s == track_panel then
      reaper.SetTrackSelected(trk, select)
    end
  end
  reaper.TrackList_AdjustWindows(true)
end

Fn_Select_By_Layout()
function NoUndoPoint () end 
reaper.defer(NoUndoPoint)
Code:
-- layout - add Narrow - Gold Fader tracks to selection.lua

track_mixer_panel = "Narrow - Gold Fader" -- edit phrase between quotes to another from Screensets window
select = true -- change to false to unselect instead
---------------------------------------------------------------------------------------------------------------
function Fn_Select_By_Layout()
  local ct = reaper.CountTracks(0)
  for c=1,ct do
    local trk = reaper.GetTrack(0, c-1)
    local r,s = reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", "", false)
    if s == track_mixer_panel then
      reaper.SetTrackSelected(trk, select)
    end
  end
  reaper.TrackList_AdjustWindows(true)
end

Fn_Select_By_Layout()
function NoUndoPoint () end 
reaper.defer(NoUndoPoint)
I will probably do some to switch layout without losing the color of the fader, and...

Last edited by FnA; 04-08-2016 at 04:25 PM. Reason: clarify script variables
FnA is offline   Reply With Quote