View Single Post
Old 08-29-2015, 03:34 PM   #24
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default

here's is it

no graphical glitch

Code:
function Main()

Folder = 1
Selected = 2
FX = 4
Mute = 8
Solo = 16
SIP = 32
RecArm = 64


-- COUNT TRACKS
  count_tracks = reaper.CountTracks(0)
  
 -- LOOP FOR EVERY TRACK
  for i = 0, count_tracks -1 do
      track = reaper.GetTrack(0, i)
      retval, TrackState = reaper.GetTrackState(track)      
      count_items_track = reaper.CountTrackMediaItems(track)           
    
    -- LOOP FOR EVERY ITEM
    for j = 0, count_items_track -1 do
        item = reaper.GetTrackMediaItem(track, j)       
      
  -- CHECK THE FIRST TAKE OF ITEM TO DETERMINE SOURCE TYPE 
    
        take = reaper.GetMediaItemTake(item, 0)    
        source = reaper.GetMediaItemTake_Source(take)       
        take_type = reaper.GetMediaSourceType(source, "test")                 
        _G["take_type"..j] = take_type
     
   ---- TAKE TYPES -----------------------------------------       
          if take_type == "MIDI" then
             RTakeType = "M"
          elseif take_type == "VIDEO" then
             RTakeType = "V"
          else
             RTakeType = "A"
          end
          
         
    end
         
        item_check = 1 --ITEMS IN TRACK ARE CONSIDERED TO BE ALL SIMILAR
     if count_items_track >= 2  then 
    
  --CHECK IF SOME ITEMS IN TRACK DON'T MATCH
        for l = 0, count_items_track -2 do
            m = (l + 1)
          if take_type0 ~= _G["take_type"..m] then
            reaper.BR_SetMediaTrackLayouts(track, "", "cc --- Large Media")
            item_check = 0
          break
        end
     end
  end
        
      --IF ALL THE ITEMS MATCH CHECK THE SOURCE TYPE AND CHANGE TRACK LAYOUT
  if item_check == 1 and count_items_track > 0 then
      
      -----------------------------------------------------------MIDI-------------------
     if RTakeType == "M" and (TrackState &64) ~= RecArm then
        reaper.BR_SetMediaTrackLayouts(track, "", "aa - Standard")   
      
        elseif RTakeType == "M" and (TrackState &64) == RecArm then    ----------------REC-ARM
               reaper.BR_SetMediaTrackLayouts(track, "", "bd --- Small Full Meter")              
     
      -----------------------------------------------------------VIDEO------------------
      
        elseif RTakeType == "V"  and (TrackState &64) ~= RecArm then
               reaper.BR_SetMediaTrackLayouts(track, "", "ba - Small")
        
        elseif RTakeType == "V" and (TrackState &64) == RecArm then   ----------------REC-ARM
               reaper.BR_SetMediaTrackLayouts(track, "", "bd --- Small Full Meter")       
      -----------------------------------------------------------WAVE-------------------
    
        elseif RTakeType == "A" and (TrackState &64) ~= RecArm then    
               reaper.BR_SetMediaTrackLayouts(track, "", "cc --- Large Media")
      
        elseif RTakeType == "A" and (TrackState &64) == RecArm then    ----------------REC-ARM
               reaper.BR_SetMediaTrackLayouts(track, "", "bd --- Small Full Meter")
      
     end
  end
     
      ------------------------NO ITEMS -------------------------------------------------
      ----IF TRACK IS FOLDER------------------------------------------------------------
      if count_items_track == 0 then
          if (TrackState &1) == Folder then
              reaper.BR_SetMediaTrackLayouts(track, "", "ai --- Standard Live Recording")      
          
      --------------------------------DEFAULT LAYOUT------------------------------------
          elseif (TrackState &64) ~= RecArm then                           
                 reaper.BR_SetMediaTrackLayouts(track, "", "cc --- Large Media")
          
          elseif (TrackState &64) == RecArm then                 ----------------REC-ARM
                 reaper.BR_SetMediaTrackLayouts(track, "", "bd --- Small Full Meter")       
     
        
          end
      end
      
  end
reaper.TrackList_AdjustWindows(1)
reaper.UpdateArrange()
reaper.defer(Main)    
end

Main()
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote