|
|
|
10-01-2019, 01:57 PM
|
#721
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
You can try using JS_Mouse_GetCursur to get the current cursor when your script starts, and then restore that cursor with JS_Mouse_SetCursor when the script exits.
|
|
|
10-01-2019, 02:00 PM
|
#722
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
How cool! JS_Mouse_GetCursor exists! Didn't know! As usual I scanned Xraym's API website, but couldn't find it there. Checking if that works...
EDIT: Woooop, it worked!!!
|
|
|
10-02-2019, 08:14 AM
|
#723
|
Human being with feelings
Join Date: Aug 2011
Posts: 517
|
This script looks awesome Stevie!
|
|
|
10-02-2019, 02:34 PM
|
#724
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Hah thanks man! Still need to take care of a few corner cases, but otherwise it comes along nicely.
|
|
|
10-11-2019, 06:52 AM
|
#725
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
An idea I had for some days now, as I see so many useful examples and snippets, what about adding an example-folder to the repository, so the examples don't get lost in this thread?
That can be filled by all of us, who have examples posted in here.
|
|
|
10-12-2019, 01:42 AM
|
#726
|
Human being with feelings
Join Date: Aug 2011
Posts: 517
|
Mespotine yes!! That would surely encourage most of us noob coders to try things out and learn from you guys. At the same time, i guess this would make this thread more relevant (deeper sort of posts so to speak), since a lot of the simpler questions could be answered just by digging in the examples.
+1000! Great idea!
|
|
|
10-12-2019, 06:49 AM
|
#727
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
I also like this suggestion.
'ReaTeam' has something similar I find helpful too:
https://github.com/ReaTeam/ReaScripts-Templates
|
|
|
10-12-2019, 02:42 PM
|
#728
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Good idea.
I created a new "js_ReaScriptAPI" folder in the ReaTeam repository that nofish linked to above.
|
|
|
10-20-2019, 07:34 AM
|
#729
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Code:
retval, left, top, right, bottom = reaper.JS_Window_GetClientRect( windowHWND )
* On macOS, screen coordinates are relative to the *bottom* left corner of the primary display, and the positive Y-axis points upward.
Does that mean that on MacOs we get actually this order of output? :
Code:
retval, left, bottom, right, top = reaper.JS_Window_GetClientRect( windowHWND )
Last edited by amagalma; 10-20-2019 at 07:40 AM.
|
|
|
10-20-2019, 01:54 PM
|
#730
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
No. You get the same order of output, but on Mac "top" will be a larger number than "bottom", whereas on PC and Linux, "top" will be a smaller number.
|
|
|
10-22-2019, 02:21 PM
|
#731
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Me again!
I don't mean to pester, but I'm having an issue with my current WIP script.
https://forum.cockos.com/showthread.php?t=226217
Do you think it's possible that you may ever add vertical zoom control to your API extension? On a related note, I know the guys from SWS managed to code several actions that can accurately control REAPER's vertical arrange zoom, but I haven't managed to get in contact with them regarding whether or not they could assist with this issue I'm having (I'm sure they could).
|
|
|
10-22-2019, 02:39 PM
|
#732
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by Dafarkias
I haven't managed to get in contact with them
|
16 hours is not a lot of time...
|
|
|
10-22-2019, 10:35 PM
|
#733
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
cfillion
It's not. But I didn't mean to offend you by making that statement. I'm simply trying to get results quickly while attempting not to pester any one source entirely too much.
Obviously, I read the forums enough to know that you are a crucial member of the SWS crew. Can I PM you with more questions regarding my predicament?
|
|
|
10-23-2019, 07:51 AM
|
#734
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
@Dafarkias
The zoom-problem, at lest the zoom-factor, is one I also have trouble with. I tried to make this happen in my Ultraschall-API but there's some tricky conversion needed, that I couldn't figure out yet.
So the only way to make it is currently using BR_GetArrangeView and BR_SetArrangeView for horizontal zoom.
You can, however, check my Ultraschall-API and the functions:
https://mespotin.uber.space/Ultrasch...etVerticalZoom
https://mespotin.uber.space/Ultrasch...etVerticalZoom
for the vertical zoom. Maybe that helps you.
|
|
|
10-23-2019, 09:16 AM
|
#735
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Fudge.
After a little more investigation, it even seems that there is a little bit of undesirable behavior from the SWS action, SWS: Vertical zoom to selected tracks.
It seems that REAPER uses some sort of algorithm that determines a non-linear 'track-gap' at the far-north of the arrange view, which makes things all the more difficult to codify.
This is very frustrating to me, because I really like the concept of the 'project map' script I'm working on, but these limitations regarding the vertical zoom/dependable positioning are somewhat crippling.
|
|
|
10-23-2019, 12:36 PM
|
#736
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Dafarkias
Do you think it's possible that you may ever add vertical zoom control to your API extension? On a related note, I know the guys from SWS managed to code several actions that can accurately control REAPER's vertical arrange zoom, but I haven't managed to get in contact with them regarding whether or not they could assist with this issue I'm having (I'm sure they could).
|
I have asked Justin himself about this, long ago, since I too wanted to add zoom functions to the extension. Unfortunately, REAPER's windows do not respond reliably to zoom messages, and Justin recommended using native actions such as "Toggle zoom to selected items".
Quote:
Originally Posted by mespotine
So the only way to make it is currently using BR_GetArrangeView and BR_SetArrangeView for horizontal zoom.
|
These functions have been deprecated since REAPER got the native GetSet_ArrangeView2 function.
|
|
|
10-23-2019, 12:42 PM
|
#737
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
He (Justin) didn't happen to mention whether or not he would every consider incorporating such a function into the API, did he?
Obviously I know they are insanely busy and whatnot, so I'm sure it's not even a passing thought.
Bummer...
|
|
|
10-23-2019, 10:02 PM
|
#739
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Thanks for sharing that.
I actually did create a feature request, it's just not very dynamic ( https://forum.cockos.com/showthread.php?t=226217).
I'll stop pestering you now about this
|
|
|
10-24-2019, 02:26 AM
|
#740
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by amagalma
Code:
retval, left, top, right, bottom = reaper.JS_Window_GetClientRect( windowHWND )
* On macOS, screen coordinates are relative to the *bottom* left corner of the primary display, and the positive Y-axis points upward.
Does that mean that on MacOs we get actually this order of output? :
Code:
retval, left, bottom, right, top = reaper.JS_Window_GetClientRect( windowHWND )
|
Quote:
Originally Posted by juliansader
No. You get the same order of output, but on Mac "top" will be a larger number than "bottom", whereas on PC and Linux, "top" will be a smaller number.
|
Thanks but I tried it and I think, for the sake of simplicity, it is easier to say that they are just returned in a different order.
Code:
local OSX = string.match(reaper.GetOS(), "OSX") and true or false
if OSX then
_, left, bottom, right, top = reaper.JS_Window_GetClientRect( hwnd )
else
_, left, top, right, bottom = reaper.JS_Window_GetClientRect( hwnd )
end
Worked for me
|
|
|
10-24-2019, 06:12 PM
|
#741
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,619
|
I've been playing with the new JS_Window_SetStyle() function and I'm running into an issue where when I specify the default style of CAPTION,SIZEBOX,SYSMENU, JS_Window_AttachTopmostPin() fails to work.
By itself, this works:
Code:
reaper.JS_Window_AttachTopmostPin(hwnd)
However this doesn't work inasmuch as the pin is not attached:
Code:
reaper.JS_Window_SetStyle(hwnd, 'CAPTION,SIZEBOX,SYSMENU')
reaper.JS_Window_AttachTopmostPin(hwnd)
Any thoughts?
On a related note, is there an API to directly control the always-on-top window behavior that is managed via the pin button?
Thanks!
|
|
|
10-25-2019, 05:46 AM
|
#742
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by tack
On a related note, is there an API to directly control the always-on-top window behavior that is managed via the pin button?
|
JS_Window_SetZOrder() I'd assume (didn't use myself yet though).
|
|
|
10-25-2019, 05:57 AM
|
#743
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,619
|
Quote:
Originally Posted by nofish
|
That's just a one time action though, isn't it? It can move the window to top but doesn't make it sticky such that it's always on top, I thought.
|
|
|
10-25-2019, 06:00 AM
|
#744
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Ah yes, I think you're right. I somehow missed that you want to make it sticky, sorry.
|
|
|
10-25-2019, 02:29 PM
|
#745
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,171
|
Quote:
Originally Posted by tack
On a related note, is there an API to directly control the always-on-top window behavior that is managed via the pin button?
Thanks!
|
If my memory serves me correct:
In JS_Window_SetPosition API
Add "TOPMOST" or "NOTOPMOST" for zOrder parameter.
I've only tried this on Windows - no idea if it works for a different OS.
|
|
|
10-25-2019, 02:40 PM
|
#746
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,619
|
Quote:
Originally Posted by lb0
If my memory serves me correct:
In JS_Window_SetPosition API
Add "TOPMOST" or "NOTOPMOST" for zOrder parameter.
I've only tried this on Windows - no idea if it works for a different OS.
|
Much obliged! Works on both Mac and Windows. Thanks lb0.
Edit: Looks like JS_Window_SetZOrder() is even more convenient if all you want to do is toggle that behaviour.
|
|
|
10-26-2019, 01:38 AM
|
#747
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Dafarky again. Different topic.
Is there currently a way to remove a window titlebar from a preexisting Reascript gfx window? Specifically:
https://forum.cockos.com/showthread.php?t=226263
|
|
|
10-26-2019, 05:53 AM
|
#748
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,171
|
Quote:
Originally Posted by Dafarkias
|
yep:
From my Stripper script I use (along these lines):
Code:
local win = reaper.JS_Window_Find('- LBX Stripper -', true)
if win then
local style = reaper.JS_Window_GetLong(win, 'STYLE')
if style then
style = style & (0xFFFFFFFF - 0x00C40000)
reaper.JS_Window_SetLong(win, "STYLE", style)
end
end
|
|
|
10-26-2019, 12:37 PM
|
#749
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Thanks lb0! Used the code to make Reaticulate borderless, now I have everything nicely fitting on the screen
|
|
|
10-26-2019, 12:51 PM
|
#750
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,619
|
Quote:
Originally Posted by _Stevie_
Thanks lb0! Used the code to make Reaticulate borderless, now I have everything nicely fitting on the screen
|
There will be a proper implementation in the next pre-release (RSN).
|
|
|
10-26-2019, 12:52 PM
|
#751
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Woah, awesome, thank you tack!!!
|
|
|
10-26-2019, 01:43 PM
|
#752
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by _Stevie_
Thanks lb0! Used the code to make Reaticulate borderless, now I have everything nicely fitting on the screen
|
Doesn't this do the same thing? (haven't tested yet)
Code:
reaper.JS_Window_SetStyle(hwnd, "POPUP")
|
|
|
10-26-2019, 03:52 PM
|
#753
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
@lb0
One for the books! Thank you!
|
|
|
10-26-2019, 06:05 PM
|
#754
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,171
|
Quote:
Originally Posted by Edgemeal
Doesn't this do the same thing? (haven't tested yet)
Code:
reaper.JS_Window_SetStyle(hwnd, "POPUP")
|
Looks like it does - - If there's a long winded approach available - I'm sure to use it
...don't think JS_SetStyle was available when I coded this (could be wrong though).
|
|
|
10-26-2019, 06:20 PM
|
#755
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by lb0
Looks like it does - - If there's a long winded approach available - I'm sure to use it
...don't think JS_SetStyle was available when I coded this (could be wrong though).
|
Julian added soon after that.
|
|
|
10-30-2019, 11:10 AM
|
#756
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Please let me preemptively apologize for my ignorance:
When setting a borderless window on an an existing window via reaper.JS_Window_SetStyle(hwnd, "POPUP"), this is only Windows compatible, no? (I.e., does not work with OSX)
|
|
|
10-30-2019, 11:24 AM
|
#757
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
With JS_Window_Create, what is the purpose of parameter classname? Does this mean, I can create a hwnd with a certain, already existing class or does this create a new class of the name "className"?
|
|
|
10-30-2019, 12:32 PM
|
#758
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Any clue why this code runs OK on v0.990 and 991 but instantly crashes REAPER using v0.992 or 993? (on Windows 10).
Code:
-- Runs OK on v0.990 and 991 but instantly crashes REAPER using v0.992 or 993!
--
function msg(str)
reaper.ShowConsoleMsg(tostring(str) .. '\n')
end
btnX=30 btnY=30 btnW=120 btnH=33 txt = "Hello World!"
winW=300 winH=200
window = reaper.JS_Window_Create("Test", "myClass", 120, 120, winW, winH,"POPUP")
bm = reaper.JS_LICE_CreateBitmap(true, winW, winH)
reaper.JS_Composite(window, 0, 0, winW, winH, bm, 0, 0, winW, winH)
reaper.JS_LICE_Clear(bm, 0xFFFFFF00)
reaper.JS_LICE_FillRect(bm, btnX, btnY, btnW, btnH, 0xFABB00FF, 1, "COPY")
reaper.JS_Window_InvalidateRect(window, 0, 0, winW, winH, true)
function loop()
if reaper.ValidatePtr(window, "HWND") then
hDC = reaper.JS_GDI_GetWindowDC(window)
reaper.JS_GDI_SetTextBkColor(hDC, 0xFABB00FF) -- set text back color same as btn rect area.
reaper.JS_GDI_DrawText(hDC, txt, string.len(txt), btnX, btnY, btnX+btnW, btnY+btnH, 'VCENTER HCENTER SINGLELINE') -- center text
reaper.JS_GDI_ReleaseDC(window, hDC)
-------------------------------------------------------
if reaper.JS_Mouse_GetState(1) == 1 then -- Left mouse button down
-- Is mouse over area, like a button?
if ContainsMouse(window, btnX,btnY,btnW,btnH) then
msg('Mouse down over fake button')
end
end
--------------------------------------------------------
reaper.defer(loop)
end
end
function ContainsMouse(hwnd,x,y,w,h)
local mX, mY = reaper.GetMousePosition()
local cx, cy = reaper.JS_Window_ScreenToClient(hwnd, mX, mY)
if (cx >= x) and (cx <= x+w) and (cy <= y+h) and (cy >= y) then
return true
end
end
function exit()
reaper.JS_Window_Destroy(window)
reaper.JS_LICE_DestroyBitmap(bm)
end
reaper.atexit(exit)
reaper.defer(loop)
|
|
|
10-30-2019, 01:03 PM
|
#759
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Dafarkias
When setting a borderless window on an an existing window via reaper.JS_Window_SetStyle(hwnd, "POPUP"), this is only Windows compatible, no? (I.e., does not work with OSX)
|
It is *supposed* to work on OSX and Linux, but if anything doesn't, please let me know!
|
|
|
10-30-2019, 01:03 PM
|
#760
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by mespotine
With JS_Window_Create, what is the purpose of parameter classname? Does this mean, I can create a hwnd with a certain, already existing class or does this create a new class of the name "className"?
|
It does both. If you give it a class name that doesn't exist, it internally creates a new window class and then creates a window instance out of it. I don't know what purpose that would serve within the context of ReaScript, I am just looking at the extension's code. Maybe it's required for creating new top level windows? (My win32 is getting quite rusty at this point...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
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 05:40 AM.
|