-
-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Editor: Add highlight around docks when dragging #106762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, it works as expected. This is a nice usability improvement 🙂
My only concern is that the width of the drag border hint is a bit too wide by default. It also varies depending on the editor spacing preset chosen, and it'll be invisible with the Compact spacing preset:
Default
Spacious
Compact
I suggest using a fixed value that's identical to the standard focus outline (Math::round(2 * EDSCALE)
).
Thanks for the tips! I changed the width to a constant, and removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip on |
The
|
Thats a good idea, I'll play around with it. I think that floating docks right now are more about docks themselves rather than the TabContainers though, so I don't know if they should be supported. |
There were a few visual changes, primarily that the dragging hints will only be shown when hoverred on, and the visual side of the rect is now fit to the TabContainer, but the interaction is not. The clip shows an example of this: Screen.Recording.2025-05-28.at.10.45.16.AM.mov |
editor/editor_dock_manager.cpp
Outdated
int dock_hidden_size = 28 * EDSCALE; | ||
int dock_hidden_offset = dock_hidden_size + 4 * EDSCALE; | ||
Rect2 temp_dock_drag_rects[DOCK_SLOT_MAX]; | ||
temp_dock_drag_rects[DOCK_SLOT_LEFT_UL] = dock_slot[DOCK_SLOT_LEFT_UL]->get_global_rect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just cover the contents, so the TabContainer drag and drop logic works the same as before, and dropping it on the contents just adds it to the end.
dock_slot[i]->get_current_tab_control()->get_global_rect();
.
And this logic to set the rects should be from EditorDockManager's drag begin notification, so it only happens once instead of for each one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately since EditorDockManager
is an Object and not in the tree, it does not receive the drag notification. However, I already have safeguards against computing the information multiple times, it stores the output and has an early return if the output is already known for the current drag.
Although if I limit the drop rect to the child control, then the highlight won't appear when the mouse is over the tabbar unless I returned to using input()
. What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't get the notification, then it is fine. In the future we may want to move some dock management into a Control.
I think it's fine to not highlight when the mouse is over the TabBar, since it has its own drop highlight and it allows moving the tab to a different index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually thinking about it, I do think that we should override the TabBar drag and dropping. If we want to limit where the dock can be dropped (ie for different horizontal / vertical layouts), we need to change the behavior somewhat, and I think that this is the place. I might try and see if I can somehow update the TabBar's drop hint.
It should be back to the original design from a user standpoint, but with a control as the backend, cleaning up the implementation a lot. There's a few changes that should be made once the EditorDock PR is merged, but until then it is good. |
int drop_tab = dock_manager->dock_slot[occupied_slot]->get_tab_bar()->get_closest_tab_idx_to_point(p_point); | ||
dock_manager->_move_dock(dragged_dock, dock_manager->dock_slot[occupied_slot], drop_tab); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping the tab on a dock should move it to the end by default, currently it never puts it at the end.
I think only when the tab is over the TabBar part should you be able to change the index.
|
||
for (int i = 0; i < DOCK_SLOT_MAX; i++) { | ||
if (dock_slot[i]->is_visible_in_tree()) { | ||
dock_drag_rects[i]->set_rect(dock_slot[i]->get_global_rect()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure why the TabBar needs to be covered. For moving to closed slots in the future, it can either be on top of the TabBars or work around it, since dropping directly into the TabBar should probably always drop into the TabBar.
If it is needed for some reason, then the TabBar's tab drag index highlight should be recreated so you know what index the dock will be at when dropped.
@@ -7717,6 +7717,7 @@ EditorNode::EditorNode() { | |||
editor_dock_manager->add_hsplit(main_hsplit); | |||
editor_dock_manager->add_hsplit(right_hsplit); | |||
|
|||
// Register dock TabContainers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Register dock TabContainers. |
This isn't really needed.
dock_found = true; | ||
} | ||
} | ||
if (!dock_found) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dock_found = true; | |
} | |
} | |
if (!dock_found) { | |
break; | |
} | |
} | |
if (!dock_tab_dragged) { |
|
||
set_as_top_level(true); | ||
dock_drop_highlight.instantiate(); | ||
dock_drop_highlight->set_draw_center(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should draw a partially transparent center so it is more clear that it isn't for the dock's content?
Closes godotengine/godot-proposals#12489
Adds a highlight around docks when dragging that tells you whether you can drop a dock. Also increases the area to drop docks to the entire TabContainer.
There is multiple colors that the highlight could be depending on whether it is a valid dragging operation (say if you were trying to drag a vertical dock into the bottom panel), but currently no container is marked as horizontal so this won't go into effect.
Screen.Recording.2025-05-23.at.2.51.05.PM.mov
This PR also creates the EditorDockTabContainer class to contain the logic.
The primary issue that I ran into was that all the buttons and internal components in the docks stopped mouse input, so dragging and checking if the mouse was contained by the rect wouldn't work as expected (and in the case of the Scene Dock it would only work in the small margins in between buttons), which is why I pivoted to using
input
.