Old 01-31-2020, 07:15 AM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default 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.
nofish is offline   Reply With Quote
Old 01-31-2020, 09:28 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

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.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 01-31-2020, 09:43 AM   #3
White Tie
Pixel Pusher
 
White Tie's Avatar
 
Join Date: Mar 2007
Location: Blighty
Posts: 4,950
Default

Quote:
Originally Posted by nofish View Post
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.
__________________
The House of White Tie
White Tie is offline   Reply With Quote
Old 01-31-2020, 12:02 PM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

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.
nofish is offline   Reply With Quote
Old 01-31-2020, 12:02 PM   #5
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

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?
Edgemeal is offline   Reply With Quote
Old 01-31-2020, 12:21 PM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by nofish View Post
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.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 01-31-2020, 06:03 PM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

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!
nofish is offline   Reply With Quote
Old 02-01-2020, 08:14 AM   #8
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

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.
nofish is offline   Reply With Quote
Old 03-19-2024, 08:22 AM   #9
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

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.
X-Raym is offline   Reply With Quote
Old 03-19-2024, 11:00 AM   #10
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

About 4 years later now I wonder why I needed that.
nofish is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.