Compare commits
2 Commits
fa570bbb4b
...
3a4d7aab2e
Author | SHA1 | Date | |
---|---|---|---|
3a4d7aab2e | |||
f41bb72fe5 |
@ -10,10 +10,12 @@
|
|||||||
-- Basic gui stuff by forum user "spk77": https://forum.cockos.com/showthread.php?t=161557
|
-- Basic gui stuff by forum user "spk77": https://forum.cockos.com/showthread.php?t=161557
|
||||||
|
|
||||||
|
|
||||||
-- Some adjustable settings:
|
-- Some adjustable settings (startup settings that can be changed in GUI):
|
||||||
local timeSinceProject = true -- EITHER this one is true OR one of the next two
|
local timeSinceProject = true -- EITHER this one is true OR one of the next two
|
||||||
local timeSinceMarker = false
|
local timeSinceMarker = false
|
||||||
local timeSinceRegion = false
|
local timeSinceRegion = false
|
||||||
|
local timeUnitHMS = false -- EITHER this one is true OR one of the next one
|
||||||
|
local timeUnitMeasures = true
|
||||||
|
|
||||||
-- Nothing to adjust here anymore...
|
-- Nothing to adjust here anymore...
|
||||||
local script_path
|
local script_path
|
||||||
@ -28,6 +30,13 @@ function msg(m)
|
|||||||
reaper.ShowConsoleMsg(tostring(m) .. "\n")
|
reaper.ShowConsoleMsg(tostring(m) .. "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Round number
|
||||||
|
function round(num, numDecimalPlaces)
|
||||||
|
local mult = 10^(numDecimalPlaces or 0)
|
||||||
|
return math.floor(num * mult + 0.5) / mult
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Store state to project variables
|
-- Store state to project variables
|
||||||
function storeExtState()
|
function storeExtState()
|
||||||
if timeSinceProject then
|
if timeSinceProject then
|
||||||
@ -48,6 +57,12 @@ function storeExtState()
|
|||||||
reaper.SetProjExtState(0, 'bigclock_extra', 'timeSinceRegion', '0')
|
reaper.SetProjExtState(0, 'bigclock_extra', 'timeSinceRegion', '0')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if timeUnitMeasures then
|
||||||
|
reaper.SetProjExtState(0, 'bigclock_extra', 'timeUnit', 'measures')
|
||||||
|
else
|
||||||
|
reaper.SetProjExtState(0, 'bigclock_extra', 'timeUnit', 'hms')
|
||||||
|
end
|
||||||
|
|
||||||
reaper.SetProjExtState(0, 'bigclock_extra', 'dockState', gfx.dock(-1))
|
reaper.SetProjExtState(0, 'bigclock_extra', 'dockState', gfx.dock(-1))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -89,9 +104,15 @@ function gui_init()
|
|||||||
rc_menu:add_item({label = "Time since previous marker",
|
rc_menu:add_item({label = "Time since previous marker",
|
||||||
toggleable = true,
|
toggleable = true,
|
||||||
selected = timeSinceMarker})
|
selected = timeSinceMarker})
|
||||||
rc_menu:add_item({label = "Time since previous region",
|
rc_menu:add_item({label = "Time since previous region|",
|
||||||
toggleable = true,
|
toggleable = true,
|
||||||
selected = timeSinceRegion})
|
selected = timeSinceRegion})
|
||||||
|
rc_menu:add_item({label = "HH:MM:SS.xxx",
|
||||||
|
toggleable = true,
|
||||||
|
selected = timeUnitHMS})
|
||||||
|
rc_menu:add_item({label = "Measures.Beats.xx|",
|
||||||
|
toggleable = true,
|
||||||
|
selected = timeUnitMeasures})
|
||||||
rc_menu:add_item({label = "Quit"})
|
rc_menu:add_item({label = "Quit"})
|
||||||
|
|
||||||
-- Let's add a command to all created items:
|
-- Let's add a command to all created items:
|
||||||
@ -134,7 +155,29 @@ function gui_init()
|
|||||||
end
|
end
|
||||||
storeExtState()
|
storeExtState()
|
||||||
end
|
end
|
||||||
rc_menu.items[4].command = function() quit = true end
|
rc_menu.items[4].command = function()
|
||||||
|
if rc_menu.items[4].selected then
|
||||||
|
timeUnitHMS = true
|
||||||
|
timeUnitMeasures = false
|
||||||
|
rc_menu.items[5].selected = false
|
||||||
|
else
|
||||||
|
--dont let user disable option but force selection of other option
|
||||||
|
rc_menu.items[5].selected = true;
|
||||||
|
end
|
||||||
|
storeExtState()
|
||||||
|
end
|
||||||
|
rc_menu.items[5].command = function()
|
||||||
|
if rc_menu.items[5].selected then
|
||||||
|
timeUnitHMS = false
|
||||||
|
timeUnitMeasures = true
|
||||||
|
rc_menu.items[4].selected = false
|
||||||
|
else
|
||||||
|
--dont let user disable option but force selection of other option
|
||||||
|
rc_menu.items[4].selected = true;
|
||||||
|
end
|
||||||
|
storeExtState()
|
||||||
|
end
|
||||||
|
rc_menu.items[6].command = function() quit = true end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Draw GUI --
|
-- Draw GUI --
|
||||||
@ -143,7 +186,11 @@ function drawGui()
|
|||||||
local val
|
local val
|
||||||
local timeRaw
|
local timeRaw
|
||||||
local timeDisplay
|
local timeDisplay
|
||||||
|
local timeDisplayHours
|
||||||
|
local timeDisplayMinutes
|
||||||
local timeDisplaySeconds
|
local timeDisplaySeconds
|
||||||
|
local timeMeasures
|
||||||
|
local timeBeats
|
||||||
local markerId
|
local markerId
|
||||||
local regionId
|
local regionId
|
||||||
local isRegion
|
local isRegion
|
||||||
@ -168,13 +215,31 @@ function drawGui()
|
|||||||
end
|
end
|
||||||
if retval > 0 then timeRaw = timeRaw - markerRegionPos end
|
if retval > 0 then timeRaw = timeRaw - markerRegionPos end
|
||||||
|
|
||||||
-- construct display string, with leading zeros if neccessary (e.g. 27:08.321)
|
-- Construct display string
|
||||||
timeDisplaySeconds = math.floor((timeRaw%60)*1000)/1000
|
if timeUnitMeasures then
|
||||||
timeDisplay = math.floor(timeRaw/60) .. ":"
|
-- measures and beats: e.g. 07.3.99
|
||||||
if timeDisplaySeconds < 10 then
|
timeBeats, timeMeasures, _, _, _ = reaper.TimeMap2_timeToBeats(0, timeRaw)
|
||||||
timeDisplay = timeDisplay .. "0"
|
timeDisplay = timeMeasures+1 .. '.' .. round(timeBeats+1, 2)
|
||||||
end
|
else
|
||||||
timeDisplay = timeDisplay .. timeDisplaySeconds
|
-- minutes and seconds: MM:SS.xxx (e.g. 27:08.321)
|
||||||
|
timeDisplayHours = math.floor(timeRaw/3600)
|
||||||
|
timeRaw = timeRaw%3600
|
||||||
|
timeDisplayMinutes = math.floor(timeRaw/60)
|
||||||
|
timeDisplaySeconds = round(timeRaw%60, 3)
|
||||||
|
if timeDisplayHours > 0 then
|
||||||
|
timeDisplay = timeDisplayHours .. ":"
|
||||||
|
if timeDisplayMinutes < 10 then
|
||||||
|
timeDisplay = timeDisplay .. "0"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
timeDisplay = ""
|
||||||
|
end
|
||||||
|
timeDisplay = timeDisplay .. timeDisplayMinutes .. ":"
|
||||||
|
if timeDisplaySeconds < 10 then
|
||||||
|
timeDisplay = timeDisplay .. "0"
|
||||||
|
end
|
||||||
|
timeDisplay = timeDisplay .. timeDisplaySeconds
|
||||||
|
end
|
||||||
|
|
||||||
gfx.clear = 3355443 -- background is dark grey
|
gfx.clear = 3355443 -- background is dark grey
|
||||||
|
|
||||||
@ -260,6 +325,16 @@ function init()
|
|||||||
timeSinceRegion = false
|
timeSinceRegion = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
retval, val = reaper.GetProjExtState(0, 'bigclock_extra', 'timeUnit')
|
||||||
|
if retval > 0 then
|
||||||
|
if val == 'measures' then
|
||||||
|
timeUnitMeasures = true
|
||||||
|
timeUnitHMS = false
|
||||||
|
else
|
||||||
|
timeUnitMeasures = false
|
||||||
|
timeUnitHMS = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- init stuff...
|
-- init stuff...
|
||||||
gui_init()
|
gui_init()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user