godot
godot copied to clipboard
Allow docks to be closed and opened
- requires https://github.com/godotengine/godot/pull/88003
- closes https://github.com/godotengine/godot-proposals/issues/8206
- related https://github.com/godotengine/godot-proposals/issues/1441
- related https://github.com/godotengine/godot-proposals/issues/7233
Docks can be closed through their context menu, and reopened through the new Window
menu.
If a dock is already open, clicking on it in the Window
menu will focus on it.
Dock layouts can be saved with closed tabs. This helps with some of the use cases in https://github.com/godotengine/godot-proposals/issues/1441.
Added dock slot DOCK_SLOT_NONE
. Using this with add_control_to_dock
allows the dock to not be opened immediately, it will be closed by default. When it is opened from the Window
menu, it will appear floating.
Internally, renamed add_control_to_dock
to add_dock
and remove_control_from_dock
to remove_dock
. This is because I want to unify the language used better, the Control that is being added and removed is the dock, and it is added to a dock slot/dock container. However, I didn't change it in the editor plugin since it would break compat. I want to add it as the new names in EditorInterface in a future PR.
After https://github.com/godotengine/godot/pull/88081, shortcuts can be added to open docks.
What I can say with confidence is that:
- The menu could be called "View" as other programs seem to do;
- This needs checkboxes for every item in that menu. Visual Studio Code for example:
The menu could be called "View" as other programs seem to do;
In GIMP the menu is called "Windows".
I think this doesn't really deserve a separate top level menu. It could be inside Editor, e.g. next to the layout button.
Rebased since https://github.com/godotengine/godot/pull/88003 is merged. I moved it into the Editor menu next to the layouts. Since its no longer top level I changed the name to 'Editor Docks', rather than 'View' or 'Window'.
Added checkboxes. This helps see what is closed and what is not. Originally I wanted the action on clicking it to just open and focus on the dock, but the checkbox implies that clicking it will close the dock, so I'll probably change the functionality to that. When focusing on the dock, the 2d/3d editor will probably steal the focus anyway.
Incorporated the shortcut, but the shortcut name should probably be changed. Or maybe I should use different shortcuts, since the functionality is different.
I think I should also make the disabled docks from EditorFeatures be disabled items instead of just not present.
Yeah checkbox totally implies that you can toggle it, so it should display differently. You could make open docks show with bold text or using accent color, or show some other icon than checkbox. Maybe eye icon for open docks (to imply focus) and "open" icon for closed docks, to imply opening?
As for the shortcut, you could make the item display the dock's name instead of shortcut name. I think it's fine to reuse it, because it works correctly (i.e. reopens/focuses dock on the side and toggles dock on bottom).
I don't think I can make them bold or colored, PopupMenu items don't support BBCode and they share the same theme. The open eye icon (GuiVisibilityVisible
) makes it look like clicking will make it hidden, since that is what it does in the Scene Dock. The only open icon I could find was file open (Load
) but that didn't seem right for opening docks.
Here's what it looks like with Search
icons for open docks (to 'find' them) and closed eye icons for closed ones.
I also made docks disabled in EditorFeatures be disabled, and set the name for the shortcut.
I tried adding tooltips, but #73926 is causing issues, so I'll remove them until that is fixed.
Let me know if there are better icons or if I should try anything else. Or I can make it toggle open/closed and use checkboxes.
For reference, what other engines do: Unity has the menu items always open a new instance of the dock. Unreal has checkboxes to open and close docks, and they are in submenus for a fixed number of multiple instances.
Hmmm, in GIMP the docks menu simply displays the list of docks with their own icons, without providing information whether they are currently opened. Not sure how it is in other software. Unique icon per dock is obviously overkill (at least for now), but maybe they could all use the same icon and for displaying status, icon modulate can be used (with inactive docks being gray). As for what icon to use, I think Window is fine.
Here is how it looks with the Window icon with modulate:
IMO looks fine.
Close button needs icon:
Unexposed dock slot none and added close icon:
Updated to use opacity.
Also, I realized that changing the theme wasn't updating it so I connected it to the theme_changed signal.
You should use NOTIFICATION_THEME_CHANGED
instead of signal (also remember that it's received when node enters tree, so avoid unnecessary update).
You should use
NOTIFICATION_THEME_CHANGED
instead of signal (also remember that it's received when node enters tree, so avoid unnecessary update).
EditorDockManager doesn't have get that notification, and putting it into the existing one in DockContextPopup feels weird since its an unrelated child class. Maybe I should change when the menu gets updated and only update it on about_to_popup?
EditorDockManager doesn't have get that notification
Then signal is fine.
Thanks!
I think the menu bar should stay after clicking, otherwise when I adjust multiple times, I will have to open the menu bar repeatedly, which will become very troublesome.
Currently, clicking on the menu for an open dock only focuses on the dock, so the menu should close in that case. But for opening closed docks, we can make it stay open.
- made a PR for it #91484