|
|
|
04-08-2019, 12:45 PM
|
#1
|
Human being with feelings
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
|
script : Pop up toolbar
Hello Everyone
I'm currently building a config for a client and I made a little trick that I wanna share with you
An image is better than 1000 words
https://drive.google.com/open?id=1QX...mqAm-OErvSoSYb
In short, the left toolbars appears only when mouse cursor is touching the left border of the screen
How?
1) I made 2 cycle action that open or close the toolbars I need (8 & 16 in my case)
https://drive.google.com/open?id=1Zs...I3QrTBjQjRJmOV
2) I create this script.lua
Code:
local r = reaper; local function nothing() end; local function bla() end
function act(id) r.Main_OnCommand(id, 0) end
local function Main()
x,y = reaper.GetMousePosition()
if x == 0 then
act(reaper.NamedCommandLookup("_S&M_CYCLACTION_102")) end -- Toolbar left
if x > 120 then
act(reaper.NamedCommandLookup("_S&M_CYCLACTION_101")) end -- Toolbar left
r.defer(Main)
end
Main()
The colored value depends on your config
RED : Cycle action ID that open the toolbars
GREEN : Cycle action ID that close the toolbars
BLUE, Toolbar width in pixel
3) Set the script as global start action (or in a custom start action)
et voila
|
|
|
04-09-2019, 12:04 PM
|
#2
|
Human being with feelings
Join Date: Sep 2014
Posts: 47
|
Hi Reno,
Great idea...
I followed the evolvement of your script on the french forum...
unfortunately my french language skills are as bad as my scripting skills:-(
So, i copied your script from post#16 and tried to make it work, but i get an
error message "...LUA 12 attempt to call a nil value (field JS_Window_Monitor FromRect)"
So, what i`ve been missing/ doing wrong??
Thanks in advance
Alex
|
|
|
04-09-2019, 12:34 PM
|
#3
|
Human being with feelings
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
|
open reapack and install js_ReaScriptAPI
make sure you have up to date reaper version and sws
|
|
|
04-09-2019, 01:26 PM
|
#4
|
Human being with feelings
Join Date: Sep 2014
Posts: 47
|
Thank you very much...that did the trick
BRGDS
Alex
|
|
|
04-15-2019, 05:34 AM
|
#5
|
Human being with feelings
Join Date: Apr 2016
Posts: 103
|
Simple. Nice and easy, thank you!
Do you see any possibility for maybe the trackmanager? It has no separate open/close actions?!
|
|
|
09-05-2023, 03:57 PM
|
#6
|
Human being with feelings
Join Date: Oct 2013
Posts: 105
|
Quote:
Originally Posted by Reno.thestraws
Hello Everyone
I'm currently building a config for a client and I made a little trick that I wanna share with you
An image is better than 1000 words
https://drive.google.com/open?id=1QX...mqAm-OErvSoSYb
In short, the left toolbars appears only when mouse cursor is touching the left border of the screen
How?
1) I made 2 cycle action that open or close the toolbars I need (8 & 16 in my case)
https://drive.google.com/open?id=1Zs...I3QrTBjQjRJmOV
2) I create this script.lua
Code:
local r = reaper; local function nothing() end; local function bla() end
function act(id) r.Main_OnCommand(id, 0) end
local function Main()
x,y = reaper.GetMousePosition()
if x == 0 then
act(reaper.NamedCommandLookup("_S&M_CYCLACTION_102")) end -- Toolbar left
if x > 120 then
act(reaper.NamedCommandLookup("_S&M_CYCLACTION_101")) end -- Toolbar left
r.defer(Main)
end
Main()
The colored value depends on your config
RED : Cycle action ID that open the toolbars
GREEN : Cycle action ID that close the toolbars
BLUE, Toolbar width in pixel
3) Set the script as global start action (or in a custom start action)
et voila
|
THANK YOU!
|
|
|
09-05-2023, 04:57 PM
|
#7
|
Human being with feelings
Join Date: Dec 2019
Posts: 589
|
very nice
|
|
|
03-03-2024, 07:29 PM
|
#8
|
Human being with feelings
Join Date: Jun 2015
Location: Venezuela
Posts: 350
|
Commenting 5 years later to let you know that I just tried this today and it worked super well! Thank you so much
I tweaked the script a bit.
I made X a little easier to trigger: "if x >= 0 and x <= 20 then"
Because I have a monitor on the left so my cursor wont snap to 0.
Now onto set up a bunch of track templates in this new popup toolbar
Last edited by Alez156; 03-03-2024 at 07:46 PM.
|
|
|
03-04-2024, 12:01 AM
|
#9
|
Human being with feelings
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 962
|
Reno.thestraws, Alez156 Great idea, thanks!
I modified your script to remove the cycle actions. Now you just need to enter the ID of the desired toolbar and the distance at which the toolbar will close.
Updated, Now the script works correctly if the Reaper is not maximized to full screen.
Code:
local r = reaper
id = 41680 -- toolbar action id
cl = 70 -- distance to close the toolbar (px)
local function Main()
_, left, top, right, bottom = r.JS_Window_GetClientRect( r.JS_Window_FindChildByID( r.GetMainHwnd(), 0) )
x,y = r.GetMousePosition()
state = r.GetToggleCommandStateEx( 0, id)
if x <= left and state == 0 then
r.Main_OnCommand(id, 0) end
if x >= left+cl and state == 1 then
r.Main_OnCommand(id, 0) end
r.defer(Main)
end
Main()
Update2
another modification for right side of screen:
Code:
local r = reaper
id = 41680 -- toolbar action id
cl = 70 -- distance to close the toolbar (px)
local function Main()
_, left, top, right, bottom = r.JS_Window_GetClientRect( r.JS_Window_FindChildByID( r.GetMainHwnd(), 0) )
x,y = r.GetMousePosition()
state = r.GetToggleCommandStateEx( 0, id)
if x >= right-1 and state == 0 then
r.Main_OnCommand(id, 0) end
if x <= right - cl and state == 1 then
r.Main_OnCommand(id, 0) end
r.defer(Main)
end
Main()
Last edited by cool; 03-04-2024 at 11:57 AM.
|
|
|
03-04-2024, 01:19 AM
|
#10
|
Human being with feelings
Join Date: Jan 2008
Location: Vancouver, BC
Posts: 3,795
|
Seems like an interesting idea for a script, especially it could work for all 4 sides and allowed choosing particular toolbars, or opening/closing other things (dockers etc.) with a basic UI for those less comfortable modifying code.
__________________
FRs: v5 Media Explorer Requests, Global Quantization, Session View
Win10 Pro 64-bit, Reaper 6(x64), AMD 3950x, Aorus X570 Master, 64GB DDR4 3600, PowerColor Red Devil 5700XT, EVO 970 2TB, 10TB HD, Define R6
|
|
|
03-04-2024, 04:43 AM
|
#11
|
Human being with feelings
Join Date: Jun 2015
Location: Venezuela
Posts: 350
|
Quote:
Originally Posted by cool
Reno.thestraws, Alez156 Great idea, thanks!
I modified your script to remove the cycle actions. Now you just need to enter the ID of the desired toolbar and the distance at which the toolbar will close.
Code:
local r = reaper
id = 41680 -- toolbar action id
cl = 70 -- distance to close the toolbar (px)
localfunction Main()
x,y = r.GetMousePosition()
state = r.GetToggleCommandStateEx( 0, id)
if x == 0 and state == 0 then
r.Main_OnCommand(id, 0) end
if x > cl and state == 1 then
r.Main_OnCommand(id, 0) end
r.defer(Main)
end
Main()
|
Owww yea much cleaner!!
|
|
|
03-04-2024, 04:53 AM
|
#12
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
|
Quote:
Originally Posted by Alez156
Commenting 5 years later to let you know that I just tried this today and it worked super well! Thank you so much
I tweaked the script a bit.
I made X a little easier to trigger: "if x >= 0 and x <= 20 then"
Because I have a monitor on the left so my cursor wont snap to 0.
Now onto set up a bunch of track templates in this new popup toolbar
|
Well that's really cool
|
|
|
03-05-2024, 11:13 AM
|
#13
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
|
Just tried it but mine is activating in the middle of the screen.
Code:
local r = reaper
id = 41941 -- toolbar action id
cl = 70 -- distance to close the toolbar (px)
local function Main()
_, left, top, right, bottom = r.JS_Window_GetClientRect( r.JS_Window_FindChildByID( r.GetMainHwnd(), 0) )
x,y = r.GetMousePosition()
state = r.GetToggleCommandStateEx( 0, id)
if x <= left and state == 0 then
r.Main_OnCommand(id, 0) end
if x >= left+cl and state == 1 then
r.Main_OnCommand(id, 0) end
r.defer(Main)
end
Main()
|
|
|
03-05-2024, 11:50 AM
|
#14
|
Human being with feelings
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 962
|
Quote:
Originally Posted by Coachz
Just tried it but mine is activating in the middle of the screen.
Code:
local r = reaper
id = 41941 -- toolbar action id
cl = 70 -- distance to close the toolbar (px)
local function Main()
_, left, top, right, bottom = r.JS_Window_GetClientRect( r.JS_Window_FindChildByID( r.GetMainHwnd(), 0) )
x,y = r.GetMousePosition()
state = r.GetToggleCommandStateEx( 0, id)
if x <= left and state == 0 then
r.Main_OnCommand(id, 0) end
if x >= left+cl and state == 1 then
r.Main_OnCommand(id, 0) end
r.defer(Main)
end
Main()
|
What is the resolution of your monitor? Do you use one monitor or several?
Also, you can try the code from post #11. It does not take into account the windowed mode of the Reaper, but it may work correctly.
|
|
|
03-05-2024, 11:53 AM
|
#15
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
|
Thanks for the reply. Chatgpt just wrote these for me and they work. I'm 1920x1080
Really a killer feature. I also had it add a feature to set the distance to close also so you can make it stay open as you move your mouse.
Code:
-- left side
local r = reaper
id = 41941 -- toolbar action id
openDistance = 70 -- distance to open the toolbar (px)
closeDistance = 300 -- distance to close the toolbar (px)
isOpen = false -- flag to track toolbar state
local function Main()
x, y = r.GetMousePosition()
state = r.GetToggleCommandStateEx(0, id)
if x <= openDistance and not isOpen then
r.Main_OnCommand(id, 0)
isOpen = true
end
if x > closeDistance and isOpen then
r.Main_OnCommand(id, 0)
isOpen = false
end
r.defer(Main)
end
Main()
Code:
-- right side
local r = reaper
id = 41942 -- toolbar action id
openDistance = 70 -- distance to open the toolbar (px)
closeDistance = 300 -- distance to close the toolbar (px)
isOpen = false -- flag to track toolbar state
local function Main()
x, y = r.GetMousePosition()
state = r.GetToggleCommandStateEx(0, id)
_, _, _, right, _ = r.JS_Window_GetClientRect(r.JS_Window_FindChildByID(r.GetMainHwnd(), 0))
if x >= right - openDistance and not isOpen then
r.Main_OnCommand(id, 0)
isOpen = true
end
if x < right - closeDistance and isOpen then
r.Main_OnCommand(id, 0)
isOpen = false
end
r.defer(Main)
end
Main()
|
|
|
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 04:09 AM.
|