function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y) -- mouse down message at splitter location
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y) -- set width, mouse up message
else -- ' TCP is on right side
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false) -- Check if the track is visible in the TCP
code
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then -- Exiting a folder, reduce the current depth
current_depth = current_depth + depth
end
end
end
-- Assuming each depth level increases width by a certain amount, adjust this multiplier as needed
local depth_width_multiplier = 50
return max_depth * depth_width_multiplier
end
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
reaper.ShowConsoleMsg("Max visible folder depth width: " .. tostring(max_visible_folder_depth_width) .. "\n")
if max_visible_folder_depth_width > 0 then SetTcpWidth(max_visible_folder_depth_width) end
end
reaper.defer()
no long answers. what do i need to change for the tcp area change to be automatic?
Assistant
To make the TCP area change automatic, remove the console output and the manual check. Essentially, you just need to directly call the SetTcpWidth function without any conditions or manual intervention. Here's the modified script:
lua
-- Set TCP width based on visible track with highest folder depth *** Windows OS only ***
-- Edgemeal - Modified by ChatGPT - May 24, 2024
-- Donate: https://www.paypal.me/Edgemeal
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y) -- mouse down message at splitter location
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y) -- set width, mouse up message
else -- ' TCP is on right side
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false) -- Check if the track is visible in the TCP
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then -- Exiting a folder, reduce the current depth
current_depth = current_depth + depth
end
end
end
-- Assuming each depth level increases width by a certain amount, adjust this multiplier as needed
local depth_width_multiplier = 50
return max_depth * depth_width_multiplier
end
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then SetTcpWidth(max_visible_folder_depth_width) end
end
reaper.defer()
User
always replace “ with " and comments start with --
Assistant
Certainly! Here is the modified script with the character replacements and maintained comments:
lua
-- Set TCP width based on visible track with highest folder depth *** Windows OS only ***
-- Edgemeal - Modified by ChatGPT - May 24, 2024
-- Donate: https://www.paypal.me/Edgemeal
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y) -- mouse down message at splitter location
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y) -- set width, mouse up message
else -- TCP is on right side
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false) -- Check if the track is visible in the TCP
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then -- Exiting a folder, reduce the current depth
current_depth = current_depth + depth
end
end
end
-- Assuming each depth level increases width by a certain amount, adjust this multiplier as needed
local depth_width_multiplier = 50
return max_depth * depth_width_multiplier
end
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then SetTcpWidth(max_visible_folder_depth_width) end
end
reaper.defer()
User
replace – with --
Assistant
Absolutely! Here is the modified script with all instances of '–' replaced by '--':
lua
-- Set TCP width based on visible track with highest folder depth *** Windows OS only ***
-- Edgemeal -- Modified by ChatGPT -- May 24, 2024
-- Donate: https://www.paypal.me/Edgemeal
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y) -- mouse down message at splitter location
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y) -- set width, mouse up message
else -- TCP is on right side
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false) -- Check if the track is visible in the TCP
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then -- Exiting a folder, reduce the current depth
current_depth = current_depth + depth
end
end
end
-- Assuming each depth level increases width by a certain amount, adjust this multiplier as needed
local depth_width_multiplier = 50
return max_depth * depth_width_multiplier
end
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then SetTcpWidth(max_visible_folder_depth_width) end
end
reaper.defer()
User
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y)
else
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false)
code
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then
current_depth = current_depth + depth
end
end
end
local depth_width_multiplier = 50
return max_depth * depth_width_multiplier
end
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then SetTcpWidth(max_visible_folder_depth_width) end
end
reaper.defer()
the change isn't automatic still. give me the shortest answer
Assistant
To make the change automatic, use reaper.defer to continuously monitor and adjust the TCP width:
lua
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y)
else
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false)
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then
current_depth = current_depth + depth
end
end
end
local depth_width_multiplier = 50
return max_depth * depth_width_multiplier
end
function AdjustTcpWidth()
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
return
end
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then
SetTcpWidth(max_visible_folder_depth_width)
end
reaper.defer(AdjustTcpWidth)
end
AdjustTcpWidth()
This script will continuously check and adjust the TCP width automatically.
User
give me only the change
Assistant
To make the TCP width change automatic, replace:
lua
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then SetTcpWidth(max_visible_folder_depth_width) end
end
reaper.defer()
with:
lua
function AdjustTcpWidth()
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
return
end
local max_visible_folder_depth_width = GetMaxVisibleFolderDepth() + 270
if max_visible_folder_depth_width > 0 then
SetTcpWidth(max_visible_folder_depth_width)
end
reaper.defer(AdjustTcpWidth)
end
AdjustTcpWidth()
This will continuously monitor and adjust the TCP width automatically.
User
Hey!
I'm making a VSlider in ReaImGui that goes from values -150 to 20.
When I drag the slider, I find that the sensitivity is too high. I want it to react less to the amount of mouse drag without needing to change the values mentioned above (for example, when moving the mouse x amount, it only moves the slider a % of x)
Is there a way to do it?
Assistant
Yes, you can adjust the sensitivity of the vertical slider in ReaImGui by using a combination of two sliders: the actual functional VSlider for the user to interact with, and a hidden slider to control the sensitivity.
Here's how you can achieve this:
Create your VSlider as usual.
Add a hidden slider that scales the mouse movement.
Use the hidden slider's value to update the actual VSlider's value.
Here's an example of how you can implement this in Lua with ReaImGui:
lua
local vslider_value = 0
local hidden_slider_value = 0
local sensitivity = 0.1 -- Adjust this to change sensitivity. Less than 1.0 makes it less sensitive.
function clamp(val, lower, upper)
if val < lower then return lower end
if val > upper then return upper end
return val
end
function main()
if ImGui_Begin("VSlider with Sensitivity") then
-- Hidden slider (not displayed to the user)
local _, mouse_delta_y = ImGui_GetMouseDragDelta(0) -- Get mouse y-drag since start of dragging
hidden_slider_value = hidden_slider_value + mouse_delta_y * sensitivity -- Scale mouse movement
ImGui_ResetMouseDragDelta(0) -- Reset drag delta to avoid accumulating drag
-- Update actual slider value
vslider_value = clamp(vslider_value + hidden_slider_value, -150, 20) -- Clamp to [-150, 20]
hidden_slider_value = 0 -- Reset hidden slider value
-- Display actual VSlider to user
local sldr_changed, new_val = ImGui_VSliderInt("##VSlider", 100, 200, vslider_value, -150, 20, "%d")
if sldr_changed then
vslider_value = new_val -- Update the actual VSlider value if changed by user directly
end
ImGui_End()
end
reaper.defer(main)
end
-- Initialize ImGui and start main loop
if reaper.ImGui_CreateContext then
reaper.ImGui_CreateContext("my_script")
end
main()
User
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y)
else
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false)
code
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then
current_depth = current_depth + depth
end
end
end
local depth_width_multiplier = 50
return max_depth
end
function AdjustTcpWidth()
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
return
end
local max_visible_folder_depth_width = tcp_default_size + (theme_folder_indent * GetMaxVisibleFolderDepth())
reaper.ShowConsoleMsg(GetMaxVisibleFolderDepth())
if max_visible_folder_depth_width > 0 then
SetTcpWidth(max_visible_folder_depth_width)
end
reaper.defer(AdjustTcpWidth)
end
tcp_default_size = 260
theme_folder_indent = 12
AdjustTcpWidth()
why isn't the script automatically adjusting tcp width?
Assistant
To troubleshoot and ensure the script adjusts the TCP width correctly and dynamically, you can start by simplifying and verifying each component step by step.
Here’s a streamlined version of your code with some debug prints to help you isolate where the issue might be:
Check if the JS_ReaScriptAPI extension is installed.
Ensure GetMaxVisibleFolderDepth is correctly calculating the max depth.
In this version, the script directly sets the TCP width based on the calculated folder depth without displaying any messages or requiring additional steps.
This version ensures that all quotes are double quotes and maintains the comments with --. The script is set to automatically adjust the TCP width based on the calculated folder depth, with no additional output or manual steps needed.
In this example:
vslider_value stores the actual slider value.
hidden_slider_value stores the amount to adjust the slider value.
sensitivity controls how sensitive the slider is to mouse movement. You can adjust this value to make the slider more or less sensitive.
When the slider is moved, the hidden_slider_value is updated according to the mouse drag distance (mouse_delta_y), scaled by the sensitivity factor. Then, vslider_value is updated based on hidden_slider_value, and hidden_slider_value is reset for the next frame. The actual slider value is clamped within the range [-150, 20] to ensure it stays within bounds.
Feel free to adjust the sensitivity value to your liking. Lower values will make the slider less sensitive to mouse movement.
function SetTcpWidth(width)
local main = reaper.GetMainHwnd()
local tcp_hwnd = reaper.JS_Window_FindEx(main, nil, "REAPERTCPDisplay", "")
if tcp_hwnd then
local x, y = 0, 0
local _, _, _, av_r = reaper.JS_Window_GetRect(reaper.JS_Window_FindChildByID(main, 0x3E8))
local _, main_x = reaper.JS_Window_GetRect(main)
local _, tcp_x, tcp_y, tcp_r = reaper.JS_Window_GetRect(tcp_hwnd)
if tcp_r < av_r then
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x + (tcp_r - tcp_x) + 2, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_x + width) - main_x, y)
else
x, y = reaper.JS_Window_ScreenToClient(main, tcp_x - 5, tcp_y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(main, "WM_LBUTTONUP", 0, 0, (tcp_r - width) - main_x, y)
end
end
end
function GetMaxVisibleFolderDepth()
local max_depth = 0
local num_tracks = reaper.CountTracks(0)
local current_depth = 0
for i = 0, num_tracks - 1 do
local track = reaper.GetTrack(0, i)
local depth = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
local is_visible = reaper.IsTrackVisible(track, false)
if is_visible then
current_depth = current_depth + depth
if current_depth > max_depth then
max_depth = current_depth
end
if depth < 0 then
current_depth = current_depth + depth
end
end
end
local depth_width_multiplier = 50
return max_depth
end
function AdjustTcpWidth()
if not reaper.APIExists("JS_WindowMessage_Send") then
reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
return
end
local max_visible_folder_depth = GetMaxVisibleFolderDepth()
local max_visible_folder_depth_width = tcp_default_size + (theme_folder_indent * max_visible_folder_depth)
reaper.ShowConsoleMsg("Max Visible Folder Depth: " .. tostring(max_visible_folder_depth) .. "\n") -- Debug: print the folder depth
reaper.ShowConsoleMsg("TCP Width: " .. tostring(max_visible_folder_depth_width) .. "\n") -- Debug: print the calculated TCP width
if max_visible_folder_depth_width > 0 then
SetTcpWidth(max_visible_folder_depth_width)
end
reaper.defer(AdjustTcpWidth)
end
tcp_default_size = 260
theme_folder_indent = 12
AdjustTcpWidth()
Steps to verify:
Ensure JS_ReaScriptAPI is installed and loaded:
This script uses the JS_WindowMessage_Send function, which requires the js_ReaScriptAPI extension. Ensure it's installed and loaded in REAPER.
Check the debug messages:
The script prints the maximum visible folder depth and the calculated TCP width to the console. You can open Script Console Output view in REAPER to see if these are being updated correctly.
Verify TCP adjustment:
After verifying that debug messages update correctly, ensure that SetTcpWidth properly changes the TCP width. It may need further adjustments or rechecking the logic around window message sending.
If the debug prints are correct but the TCP is not adjusting, the issue is likely within the SetTcpWidth function or the window messages being sent.
Adjust the script accordingly based on the debug output. If further specific adjustments are needed within the SetTcpWidth function, those might involve fine-tuning how the mouse messages are simulated or considering additional REAPER API functions.