|
|
|
01-31-2020, 07:15 AM
|
#1
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
How to get TCP width? (SOLVED)
In the API doc for GetMediaTrackInfo_Value I see I_MCPW for MCP width and various for TCP height (I_WNDH, I_TCPH) but nothing for TCP width, did I miss it?
It surely must be possible to get somehow, because themes are able to rearrange TCP elements depending on TCP width (e.g. default theme does this).
WALTER thing maybe? Can we access this via ReaScript also?
Last edited by nofish; 01-31-2020 at 06:03 PM.
|
|
|
01-31-2020, 09:28 AM
|
#2
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
There's a reaper.ini entry for that, which is changed when the tcp-width is changed.
Don't remember which one, but a quick diff of reaper.ini after dragging the right part of the tcp should help.
|
|
|
01-31-2020, 09:43 AM
|
#3
|
Pixel Pusher
Join Date: Mar 2007
Location: Blighty
Posts: 4,950
|
Quote:
Originally Posted by nofish
It surely must be possible to get somehow, because themes are able to rearrange TCP elements depending on TCP width (e.g. default theme does this).
WALTER thing maybe? Can we access this via ReaScript also?
|
Yeah, that's entirely a WALTER thing, we get it directly as a scalar. Could you program a theme to tale that scalar and convert it into a param and send that to a script? I don't know. Its an interesting thought, but FWIW I just quickly tried and it didn't seem to work.
|
|
|
01-31-2020, 12:02 PM
|
#4
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Thanks.
@mespotine
I checked with your Display-Altered-ConfigFile-Entries script, it's leftpanewid, but it seems to store the previous TCP width or something, not the current one. At least not quite as I'd expected.
@White Tie
If it worked it would be a theme dependent solution anyway, so not ideal (for scripting purposes).
But I think I found a way:
Getting the TCP HWND ("REAPERTCPDisplay") and measuring its rectangle width seems to work.
|
|
|
01-31-2020, 12:02 PM
|
#5
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
On Windows (no clue on MAC) you could search reaper children by classname to get the TCP window handle, then use ClientRect to get width.
This returns the same width value as shown in reaper.ini (leftpanewid=) here on Win10.
Code:
-- Requires js_ReaScriptAPI extension,
-- https://forum.cockos.com/showthread.php?t=212174
function GetClientBounds(hwnd)
ret, left, top, right, bottom = reaper.JS_Window_GetClientRect(hwnd)
return left, top, right-left, bottom-top
end
function FindChildByClass(hwnd, classname, occurance)
local arr = reaper.new_array({}, 255)
reaper.JS_Window_ArrayAllChild(hwnd, arr)
local adr = arr.table()
local control_occurance = 0
for j = 1, #adr do
local hwnd = reaper.JS_Window_HandleFromAddress(adr[j])
if reaper.JS_Window_GetClassName(hwnd)== classname then
control_occurance = control_occurance + 1
if occurance == control_occurance then
return hwnd
end
end
end
end
function Main()
-- get first reaper child window with classname "REAPERTCPDisplay".
tcp_hwnd = FindChildByClass(reaper.GetMainHwnd(),'REAPERTCPDisplay',1)
if tcp_hwnd then
x,y,w,h = GetClientBounds(tcp_hwnd)
msg(w) -- show width
end
end
Maybe better/easier to just get the value from the ini file?
|
|
|
01-31-2020, 12:21 PM
|
#6
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by nofish
Thanks.
@mespotine
I checked with your Display-Altered-ConfigFile-Entries script, it's leftpanewid, but it seems to store the previous TCP width or something, not the current one. At least not quite as I'd expected.
|
IIRC, it includes window borders, so you need to subtract that.
|
|
|
01-31-2020, 06:03 PM
|
#7
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
You both are right, leftpanewid= seems to work and gives same result as calculating client rectangle.
Tried both ways again, must have made some error in my first test.
Anyway, solved. Thanks!
|
|
|
02-01-2020, 08:14 AM
|
#8
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
A note for future reference:
leftpanewid= doesn't exist in the reaper.ini in a fresh Reaper install, it gets created first time user adjusts the TCP divider it seems.
So when accessing it via script it should be checked if exists (and handled accordingly if not).
edit:
Anyone by chance knows what the leftpanewid_alt= entry is?
edit2:
Ah it gets created when double-clicking the divider, stores last width which will get restored when double-clicking again.
Last edited by nofish; 02-01-2020 at 08:57 AM.
|
|
|
03-19-2024, 08:22 AM
|
#9
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
Code:
arrange.w = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0x3E8)
arrange.retval, arrange.left, arrange.top, arrange.right, arrange.bottom = reaper.JS_Window_GetClientRect( arrange.w )
arrange.left, arrange.top = reaper.JS_Window_ScreenToClient(arrange.w, arrange.left, arrange.top)
arrange.width = arrange.right - arrange.left
arrange.left is the x position of arrange view (so it's TCP width, if TCP on the left)
(code by cfillion)
EDIT: Wait there is mistake
Last edited by X-Raym; 03-19-2024 at 08:33 AM.
|
|
|
03-19-2024, 11:00 AM
|
#10
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
About 4 years later now I wonder why I needed that.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 10:40 AM.
|