|
|
|
05-20-2019, 05:22 PM
|
#1
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Hide dockers individually
Hey guys,
I've been working on a script that will hide/show dockers individually.
My approach is:
- get the screen dimensions of Reaper's main window
- search for all docker windows (= REAPER_dock) and also get their screen dimensions
- now to get the right docker, I compare the right value with the width value of the screen
And that's where I'm stuck, now.
The logical step to show/hide the docker was to use reaper.JS_Window_Show().
However, when using this method, the windows inside the docker get hidden, but not the docker itself, as shown here:
https://imgur.com/ppLEWBj
The goal is NOT to terminate running scripts, therefore reaper.JS_Window_Destroy() is no option.
View: Show docker 40279, perfectly shows, that it's possible to hide dockers without terminating the running scripts.
I checked the child windows when using this action (all dockers hidden).
reaper.JS_Window_IsVisible() gave me a false for all the child windows.
The same thing, that I achieved by using JS_Window_Show().
But apparently there is another mechanism involed, that will update the arrange or the docker windows. Otherwise it would look like my screenshot from above.
Maybe someone can help?
Here's my code:
Code:
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
hwnd = reaper.GetMainHwnd() -- get Reaper main
retval, width, height = reaper.JS_Window_GetClientSize(hwnd) -- get window dimensions
retval, docker_list = reaper.JS_Window_ListFind("REAPER_dock", false) -- find all windows called REAPER_dock
docker_count, docker_array = ultraschall.CSV2IndividualLinesAsArray(docker_list) -- create docker array from list
for i=1, docker_count do
docker_hwnd = reaper.JS_Window_HandleFromAddress(docker_array[i]) -- convert address to hwnd
retval, left, top, right, bottom = reaper.JS_Window_GetRect(docker_hwnd) -- get docker dimensions
if right == width then -- get right docker
if reaper.JS_Window_IsVisible(docker_hwnd) then
reaper.JS_Window_Show(docker_hwnd, "HIDE") -- hide all children of right docker
else
reaper.JS_Window_Show(docker_hwnd, "SHOW") -- hide all children of right docker
end
end
end
Last edited by _Stevie_; 05-20-2019 at 05:35 PM.
|
|
|
05-27-2019, 03:36 AM
|
#2
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
bumpy bump
|
|
|
06-12-2019, 04:43 PM
|
#3
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Sigh, I guess there's no hope?
|
|
|
06-12-2019, 04:58 PM
|
#4
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
|
I wonder if the proper way to hide/show the dockers would be reaper.DockWindowAdd() and reaper.DockWindowRemove() rather than the JS functions?
|
|
|
06-12-2019, 05:01 PM
|
#5
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Yes, I tried that, too. The problem is to add the undocked window to the same docker as before.
Let me check with my code...
|
|
|
06-12-2019, 05:07 PM
|
#6
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
I indeed created a script for hiding the Track Inspector with the method you mentioned. But it doesn't dock back to the correct docker.
Maybe I'm also missing something...
Code:
hwnd = reaper.JS_Window_Find("Track Inspector", false)
if hwnd then
title = reaper.JS_Window_GetTitle(hwnd)
if reaper.JS_Window_IsVisible(hwnd) then
reaper.DockWindowRemove(hwnd)
else
reaper.DockWindowAdd(hwnd, title, 0, true)
end
else
reaper.ShowConsoleMsg("Track Inspector is not running!")
end
EDIT: actually! How do you dock the Reaticulate script back to where it was, when we undock it?
|
|
|
06-12-2019, 05:14 PM
|
#7
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
|
Do different values of the third argument to DockWindowAdd() affect which docker it attaches to?
Although even if it does, I don't know how to get the current value before undocking.
|
|
|
06-12-2019, 05:20 PM
|
#8
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Well, it almost looks like it wouldn't.
What method do you use to redock the Reaticulate window?
It always docks to the same position, where it was before.
|
|
|
06-12-2019, 05:23 PM
|
#9
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
|
Quote:
Originally Posted by _Stevie_
Well, it almost looks like it wouldn't.
What method do you use to redock the Reaticulate window?
It always docks to the same position, where it was before.
|
It's a lot easier there because I control the gfx context (having created it). All I need to do is call gfx.dock().
What you're trying to do is different, since you're trying to manipulate the dock states from the outside.
|
|
|
06-12-2019, 05:26 PM
|
#10
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Oh... ok that is different indeed.
|
|
|
06-13-2019, 04:05 AM
|
#11
|
Human being with feelings
Join Date: Jun 2012
Location: Spain
Posts: 7,238
|
I can make Track inspector to be hidden but running in the background. This would help to make the tag actions work without having Track Inspector visible.
Like the Region Tracks script that it has a minimize button that sends the script to background without gfx window but still running to manage the regions etc.
|
|
|
06-13-2019, 06:33 AM
|
#12
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Hey Heda! That would actually be a great idea. But there is a problem...
This will only work, if only one script is running in the dock. As soon as I add another script to
the docker, where TI is located, it won’t work anymore, because only TI will be hidden but not the whole docker.
So, my plan is to do the following:
- identify the docker by a script that will always be there (like TI).
- cycle thru all the scripts running in the docker and hide them
- save the dock ID via SetExState
- save all the script names, that are running inside the docker via SetExState
When toggling that action again:
- check if docker is visible
- if it isn’t, get the dock ID from GetExtState
- also retrieve all the other scripts names that are in the same dock as TI
- add all the scripts to the dock
Not sure, if I’m missing something, but in theory this should work.
Last edited by _Stevie_; 06-13-2019 at 07:26 AM.
|
|
|
06-13-2019, 08:04 AM
|
#13
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
I think, I solved it, even without using ExState.
Code coming shortly...
|
|
|
06-13-2019, 11:44 AM
|
#14
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Here you go. Not sure, if it can be done even more efficiently. But give it a spin, if you think so.
What puzzled me a bit was the use of arrays and tables. The difference didn't seem obvious to me. I took a code snippet from Edgemeal and adjusted it to my needs.
Another thing is: although my functions are local, arrays are global. Is this normal and if so, should I localize them? I always thought that everything in a "local function" is localized anyway?
Okay, but now back to the script. Once you put the title of a window in "known_window" (here Track Inspector), the script will toggle all windows that are docked in the same docker. That means, if TI is docked in the left docker, the script will toggle show the left docker. If you want to toggle show the right docker, you have to pick the title of a known_window that is docked there and put it in the script.
Code:
local function GetDocker(known_window)
known_hwnd = reaper.JS_Window_Find(known_window, false) -- get hwnd of known docked window
docker_hwnd = reaper.JS_Window_GetParent(known_hwnd) -- get (parent) docker hwnd
docker_id = reaper.DockIsChildOfDock(known_hwnd) -- dock id is retained, if even window is removed from dock!
docker_visible = reaper.JS_Window_IsVisible(docker_hwnd) -- get visible state of dock
if docker_id ~= -1 then
return docker_visible, docker_hwnd, docker_id
else
reaper.ShowMessageBox("The window with the title "..known_window.." does not exist", "Error", 0)
end
end
local function GetChildren(docker_hwnd)
child_array = reaper.new_array({},100) -- create array
retval = reaper.JS_Window_ArrayAllChild(docker_hwnd, child_array) -- store all children in array
table = child_array.table()
end
local function ToggleDocker(docker_visible, docker_id)
for t = 1, #table do
address = table[t] -- iterate thru table and get window address
child_hwnd = reaper.JS_Window_HandleFromAddress(address) -- convert address to hwnd
child_title = reaper.JS_Window_GetTitle(child_hwnd) -- get full title of window
if docker_visible then -- if docker is visible: hide
if child_title ~= "Custom1" then -- ignore Custom1 window
reaper.DockWindowRemove(child_hwnd)
end
else -- if docker is visible: show
if child_title ~= "Custom1" then -- ignore Custom1 window
reaper.DockWindowAdd(child_hwnd, child_title, docker_id, true)
end
end
end
end
local known_window = "Track Inspector" -- enter your known window title here
local docker_visible, docker_hwnd, docker_id = GetDocker(known_window)
GetChildren(docker_hwnd)
ToggleDocker(docker_visible, docker_id)
|
|
|
06-14-2019, 09:40 AM
|
#15
|
Human being with feelings
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
|
Stevie... love the idea... just was trying it but either I don't get it or something is missing... here's my tale:
I have at the right of the arrange a docker with three tabs
1-performance
2-HeDa Track Inspector VIP
3-FX Browser
and at the right of the TCP I have the reaper MCP docked to use as a track inspector also...
OK so I ran you script as is, thinking it would hide and also restore the dock at the right side that holds the three tabs listed above.
...and it indeed hides them but then running it again does not restore them ... instead it puts that dock along with a slew of tabs to the left of the TCP...
...the slew of tabs seem to be each of the FX Browser folders, each one on a tab... wtf???
not at all what I expected and really a mess
...it does seem close though
|
|
|
06-14-2019, 10:24 AM
|
#16
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Yeah, I noticed this as well. There’s really something going wrong. I yet have to find out what’s causing this.
When toggling the docker twice, it changes the docker ID. In my case, the first iteration is docker ID 0 and on the second iteration it switches to ID 5. This goes back and forth. I think that’s the culprit. I’ll dig deeper.
Maybe the devs can also shed some light if they are reading this.
|
|
|
06-14-2019, 10:34 AM
|
#17
|
Human being with feelings
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
|
ah I see... well that changing ID certainly describes what I see happen...
this will be a kewl tool if you get it working
I was just thinking but have tried it... that in my case I might be able to get the same [desired] result with just another screen set
|
|
|
06-24-2019, 06:28 AM
|
#18
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by _Stevie_
Yeah, I noticed this as well. There’s really something going wrong. I yet have to find out what’s causing this.
When toggling the docker twice, it changes the docker ID. In my case, the first iteration is docker ID 0 and on the second iteration it switches to ID 5. This goes back and forth. I think that’s the culprit. I’ll dig deeper.
Maybe the devs can also shed some light if they are reading this.
|
This changing of the docker ID is due the fact, that Reaper has 16 of them (0 to 15).
Usually, you don't use all of them, leading to some of them being "hidden" at the same position.
So when you add a window to a docker, which is at a position where numerous "hidden" dockers are positioned, it will simply take anyone of them(dunno what kind of "pattern" Reaper is using for the selection-process).
Still investigating into that more, but that's my current state of understanding.
@all
BTW: You might want to add a +1 to the following FR-thread, where I added some docker-related function-requests:
https://forum.cockos.com/showthread.php?t=222314
|
|
|
06-24-2019, 07:41 AM
|
#19
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Hey mespo!
Thanks for chiming in. I have found a pattern but it doesn’t make sense to me.
Please keep us posted if you find anything!
|
|
|
06-12-2021, 07:09 AM
|
#20
|
Human being with feelings
Join Date: Jan 2013
Posts: 1,126
|
Hey Stevie, have you ever found a way to sort this out?
And then, may I ask, what "Custom1" window is?
|
|
|
06-12-2021, 07:21 AM
|
#21
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Unfortunately I didn't. I haven't pursued this any further, I have to confess.
|
|
|
02-25-2023, 08:06 AM
|
#22
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Done by FTC. Check ReaPack for:
Toggle show bottom docker.lua
Toggle show left docker.lua
Toggle show right docker.lua
Toggle show top docker.lua
|
|
|
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 03:21 AM.
|