Skip to content

Commit

Permalink
Update ultraschall_gui_statemanager.lua
Browse files Browse the repository at this point in the history
Edge-Cases abfangen die bei sichtbaren Envelope-Lanes in einer Endlosschleife landeten
  • Loading branch information
rstockm committed Mar 26, 2021
1 parent 2ef7df2 commit 5bea67e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Scripts/ultraschall_gui_statemanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
function getAllTracksHeight ()

local height = 0
local singleheight = 0
local singleheight = 1000
local numberOfTracks = reaper.CountTracks(0)

for i=0, numberOfTracks-1 do
local MediaTrack = reaper.GetTrack(0, i)
local retval = reaper.GetMediaTrackInfo_Value(MediaTrack, "I_WNDH")
-- print ("Höhe: "..retval)
height = height + retval
singleheight = retval
if retval < singleheight then
singleheight = retval
end
-- print (retval)
end
return height, singleheight
Expand All @@ -65,16 +67,20 @@ function verticalZoom (maxheight)
if allTracksHeight < maxheight - offset then -- muss Vergößert werden
while allTracksHeight < maxheight - offset do
reaper.CSurf_OnZoom(0, 1)
allTracksHeight = getAllTracksHeight()
allTracksHeight, singleheight = getAllTracksHeight()
end
end

if allTracksHeight > maxheight - offset then -- muss Verkleinert werden
while allTracksHeight > maxheight - offset and singleheight > 24 do -- kleiner als 24 können Tracks nicht werden
shrinkCount = 0
while allTracksHeight > maxheight - offset and singleheight > 24 and shrinkCount < 20 do -- kleiner als 24 können Tracks nicht werden, hartes Limit von 20 Verkleinerungen für Edge-Cases
reaper.CSurf_OnZoom(0, -1)
allTracksHeight, singleheight = getAllTracksHeight()
-- print (singleheight)
shrinkCount = shrinkCount +1
-- print (singleheight.."-"..shrinkCount)
end
end

end

function countAllEnvelopes ()
Expand Down

0 comments on commit 5bea67e

Please sign in to comment.