Old 05-13-2018, 03:30 PM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default Width & height of arrange view?

Hello!

I've haven't coded anything for some time and feel a bit rusty...

Could you tell me how to get the current width & height of the arrange view in pixels?

Thanks!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-13-2018, 08:56 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You can read these values from the reaper.ini by reading the widths of the dockers(I don't know which reaper.ini-entry is which, but it should be possible to find out).
They are updated, when you move the docker-positions, so you have always the most recent one in the reaper.ini

With that, you can calculate the width and height of the arrange-view.
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-14-2018, 02:39 AM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thanks!

Hmm, sounds quite complicated.. :/
How can I know which docker is which and where it is located? Furthermore, if I drag a docker and change its size, is this reflected immediately in the ini?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-14-2018, 02:30 PM   #4
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

In the SWS there is "SWS/wol: Set selected envelope height to maximum", which means that there is a way to know the arrange window height.

So, I had a look in the SWS GitHub and found this:

Code:
int GetCurrentTcpMaxHeight()
{                       	
RECT r;                       	
GetClientRect(GetArrangeWnd(), &r);                       	
return r.bottom - r.top;                       
}
I wonder if someone could create and add in the SWS an API that would give the arrange width and height.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-14-2018, 10:34 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

We have from reascript a SWS BR function to get Arrange View width as time position, and native function for zoom level.

I dont remember anything with getting with and height of arrange view right as pixels on screen.

--
Open a SWS github ticket if you want this function to be bring to reascript. :P
X-Raym is offline   Reply With Quote
Old 05-16-2018, 06:17 AM   #6
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I built my own version of SWS where I added this:
Code:
C: void AM_GetArrangeSize(int* WidthOut, int* HeightOut)
EEL: extension_api("AM_GetArrangeSize", int &Width, int &Height)
Lua: number Width, number Height = reaper.AM_GetArrangeSize()
Python: (Int WidthOut, Int HeightOut) = AM_GetArrangeSize(WidthOut, HeightOut)

Get dimensions of Arrange View in pixels
I have done a pull request to the SWS Github too.

Works like a dream

P.S. Now is time to refine my private Smart Zoom script (and make it public when SWS adds my function)
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-16-2018, 09:45 AM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

Nice :P
X-Raym is offline   Reply With Quote
Old 05-16-2018, 10:10 AM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Does that mean, you already have the height in pixels but not the width in pixels?
I once wrote a function that returns the pixel-position of the left and right sides of the Reaper-window itself.
Maybe you can modify it for your needs:

https://forum.cockos.com/showpost.ph...17&postcount=3

Full thread:
https://forum.cockos.com/showthread.php?t=203785
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-16-2018, 01:22 PM   #9
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by doppelganger View Post
hmm, interesting, is it possible to get current arrange view position in relation to absolute height of arrange view? Something like GetSet_ArrangeView2, but vertically with pixels at output (ideally i need x and y of track in TCP), i'm novice in programming, but maybe i will be able to do it, if it's possible in sws. I made fxlist for TCP, main functionality works, but some things, like scrolling tracks or dragging arrange view, do not work. https://stash.reaper.fm/33575/list.gif
What do you mean by "current arrange view position in relation to absolute height of arrange view"? The mouse pointer height in relation to the height of the arrange view?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-18-2018, 02:57 PM   #10
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by doppelganger View Post
that arrange area's vertical size increases, when more tracks added, right?

Well, no! :P The Arrange View is this:





The TCP is where track panels exist. The height of the TCP is equal to the height of the Arrange View.


I can't understand what you are trying to do, but if you wish, I can send you my sws build for you to try my function and see if that helps you
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-19-2018, 05:14 AM   #11
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You may also be interested in my script, that displays changed and altered settings in pref-files like reaper.ini

http://mespotine.de/Ultraschall/Reap...le-Entries.lua

Just start it and drag around the elements surrounding the arrangeview to see, which elements are necessary to read from reaper.ini.

Probably the following reaper.ini-entries are interesting for you, as they surround the arrange-view exactly and are updated as soon as the these things are changed by mouse-dragging, etc.

[REAPER] -> leftpanewid - right side of TrackControlPanel
[REAPER] -> toppane - top of the first track but below the ruler

[REAPER] -> dockheight_r - docker right
[REAPER] -> dockheight_t - docker top
[REAPER] -> dockheight - docker bottom
[REAPER] -> dockheight_l - docker left

They give you the coordinates related to the Reaper-window itself, but not in relation to the screen-position.
Means, if the Reaper-window is maximized/fullscreen, the corrdinates match screencoordinates, but if you move the Reaper-window somewhere else, the coordinates don't match.

Maybe this helps you to make it work...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-24-2018, 02:21 AM   #12
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Very cool script! Thank you mespotine!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-24-2018, 03:25 AM   #13
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I have this:
reaper window height = 1040
arrange view height = 749 (1040-749 = 291)

dockheight = 270
dockheight_t = 68
toppane = 68

=======================

reaper window width = 1920
arrange view width = 1460 (1920-1460 = 460)

dockheight_l = 72
dockheight_r = 348
leftpanewid = 354


I cannot get to these numbers (291 for height and 460 for width) by using any of the variables in the reaper.ini ...
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 05-24-2018 at 04:04 PM.
amagalma is offline   Reply With Quote
Old 05-24-2018, 09:03 AM   #14
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Unfortunately you can't influence the variables from within Reaper, only get them from reaper.ini.
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-24-2018, 09:22 AM   #15
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I meant I cannot find a way to calculate the Arrange view height and width, without using my sws function
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-24-2018, 09:41 AM   #16
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
arrange view width = 1460 (1920-460 = 460)
Didn't you mean
arrange view width = 1460 (1920-1460 = 460) ?
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-24-2018, 04:03 PM   #17
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I know that the arrange width is 1460 pixels (through my sws api AM_GetArrangeSize.

I know that the reaper window width is 1920 pixels.

So they differ by 460 pixels (1920-460).

But dockheight_l = 72, dockheight_r = 348 and leftpanewid = 354. Not 460
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-24-2018, 04:04 PM   #18
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by mespotine View Post
Didn't you mean
arrange view width = 1460 (1920-1460 = 460) ?
Yes, corrected
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-01-2018, 03:09 AM   #19
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

How would you get TCP width ?


I'm trying



Code:
a = reaper.SNM_GetIntConfigVar( "leftpanewid", 666 )

but only get the error code :S
X-Raym is offline   Reply With Quote
Old 10-01-2018, 07:37 AM   #20
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I don't remember leftpanewid being accessible as config var. Is it in my docs?

Not all entries in reaper.ini are accessible configvars.
Maybe a good FR..
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-01-2018, 07:45 AM   #21
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Me being stupid: just read it from the reaper.ini
It will be updated when the arrangeview is updated.

There should be a script in Reaper Internals showing updated reaper.ini values. Might be helpful...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-01-2018, 09:37 AM   #22
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

@mespotine
I'm not sure to understand, is it a bug or just the wrong funciton to get this value then ?


I need it in a defer script so I don't think that the get private string from SWS function is the most optimized way to get it... is it ?
X-Raym is offline   Reply With Quote
Old 10-02-2018, 07:14 AM   #23
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

It's not a bug, it's just not accessible as config-var.

But you can read it from reaper.ini, where the entry is updated every time the width of the TCP is changed by the user.
So the GetPrivateProfileString-SWS-function is the only option for you, as far as I know.

Edit: You can use:
https://github.com/Ultraschall/ultra...le-Entries.lua
to display changed entries in a config-ini-file into the ReaperConsole. This might help, if you want to check, which entry has been changed, when moving around things in the arrange-view.

Last edited by Meo-Ada Mespotine; 10-02-2018 at 08:15 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-04-2018, 01:44 PM   #24
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by X-Raym View Post
How would you get TCP width ?

I have created an API in SWS for that (AM_GetArrangeSize)... Hopefully, one day Tim will compile the new version of SWS..
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-04-2018, 02:05 PM   #25
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

@amalgama
Oh yes I saw that ! waiting for the merge... :P
X-Raym is offline   Reply With Quote
Old 10-28-2018, 03:56 AM   #26
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

No need to wait for the SWS merge anymore!


With juliansader's js_ReaScriptAPI extension I can get the values like this:
Code:
local w = reaper.JS_Window_Find( "trackview", true )
local retval, left, top, right, bottom = reaper.JS_Window_GetClientRect( w )
width = right - left
height = bottom - top
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-28-2018, 03:12 PM   #27
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

@amalgama
Thx !
X-Raym is offline   Reply With Quote
Old 11-13-2018, 06:00 AM   #28
eviluess
Human being with feelings
 
eviluess's Avatar
 
Join Date: Dec 2015
Location: Guangzhou, China
Posts: 176
Default

Quote:
Originally Posted by amagalma View Post
No need to wait for the SWS merge anymore!


With juliansader's js_ReaScriptAPI extension I can get the values like this:
Code:
local w = reaper.JS_Window_Find( "trackview", true )
local retval, left, top, right, bottom = reaper.JS_Window_GetClientRect( w )
width = right - left
height = bottom - top
How to access the function "JS_Window_Find" in Lua?
eviluess is offline   Reply With Quote
Old 11-13-2018, 07:03 AM   #29
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

You need the js_ReaScriptAPI extension
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-15-2018, 09:57 AM   #30
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

@amalgama
Really awesome !!


X-Raym is offline   Reply With Quote
Old 12-16-2018, 03:38 AM   #31
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Impressive!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-21-2018, 02:11 PM   #32
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Alternative method (using julian's v0.962):

Code:
local _, left, top, right, bottom = reaper.JS_Window_GetClientRect( reaper.JS_Window_FindChildByID( reaper.GetMainHwnd(), 1000) )
width = right - left
height = bottom - top
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-21-2018, 03:08 PM   #33
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

@amagalma
How is it better ?
X-Raym is offline   Reply With Quote
Old 12-21-2018, 07:11 PM   #34
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I remember julian saying that finding a window by name is not the safest cross-platform way, since windows may have different names on different platforms (or no names). Finding by ID is the way to go
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma 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 01:58 AM.


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