Old 04-08-2019, 12:45 PM   #1
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default 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
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote
Old 04-09-2019, 12:04 PM   #2
xaverle
Human being with feelings
 
Join Date: Sep 2014
Posts: 47
Default

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
xaverle is offline   Reply With Quote
Old 04-09-2019, 12:34 PM   #3
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default

open reapack and install js_ReaScriptAPI

make sure you have up to date reaper version and sws
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote
Old 04-09-2019, 01:26 PM   #4
xaverle
Human being with feelings
 
Join Date: Sep 2014
Posts: 47
Default

Thank you very much...that did the trick

BRGDS

Alex
xaverle is offline   Reply With Quote
Old 04-15-2019, 05:34 AM   #5
Mottemania
Human being with feelings
 
Join Date: Apr 2016
Posts: 103
Default

Simple. Nice and easy, thank you!

Do you see any possibility for maybe the trackmanager? It has no separate open/close actions?!
Mottemania is offline   Reply With Quote
Old 09-05-2023, 03:57 PM   #6
Alex Ortega
Human being with feelings
 
Join Date: Oct 2013
Posts: 105
Default

Quote:
Originally Posted by Reno.thestraws View Post
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!
Alex Ortega is offline   Reply With Quote
Old 09-05-2023, 04:57 PM   #7
permeke
Human being with feelings
 
Join Date: Dec 2019
Posts: 588
Default

very nice
permeke is offline   Reply With Quote
Old 03-03-2024, 07:29 PM   #8
Alez156
Human being with feelings
 
Alez156's Avatar
 
Join Date: Jun 2015
Location: Venezuela
Posts: 346
Default

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

__________________
💙 I run Reapertips.com | 🦋 Reapertips Theme | ☕️ Buy me a coffee
🎸 Modern Metal Songwriting REAPER Template

Last edited by Alez156; 03-03-2024 at 07:46 PM.
Alez156 is online now   Reply With Quote
Old 03-04-2024, 12:01 AM   #9
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
Default

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.
cool is online now   Reply With Quote
Old 03-04-2024, 01:19 AM   #10
PitchSlap
Human being with feelings
 
PitchSlap's Avatar
 
Join Date: Jan 2008
Location: Vancouver, BC
Posts: 3,793
Default

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
PitchSlap is offline   Reply With Quote
Old 03-04-2024, 04:43 AM   #11
Alez156
Human being with feelings
 
Alez156's Avatar
 
Join Date: Jun 2015
Location: Venezuela
Posts: 346
Default

Quote:
Originally Posted by cool View Post
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!!
__________________
💙 I run Reapertips.com | 🦋 Reapertips Theme | ☕️ Buy me a coffee
🎸 Modern Metal Songwriting REAPER Template
Alez156 is online now   Reply With Quote
Old 03-04-2024, 04:53 AM   #12
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default

Quote:
Originally Posted by Alez156 View Post
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
__________________
Track Freezing Scripts

Coachz Repo
Coachz is online now   Reply With Quote
Old 03-05-2024, 11:13 AM   #13
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default

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()
__________________
Track Freezing Scripts

Coachz Repo
Coachz is online now   Reply With Quote
Old 03-05-2024, 11:50 AM   #14
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
Default

Quote:
Originally Posted by Coachz View Post
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.
cool is online now   Reply With Quote
Old 03-05-2024, 11:53 AM   #15
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
Default

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()
__________________
Track Freezing Scripts

Coachz Repo
Coachz is online now   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 12:57 PM.


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