Add switch on hover to TabBar#103478
Conversation
Calinou
left a comment
There was a problem hiding this comment.
Tested locally, it works as expected.
Note that there's no delay after hovering a tab before it switches, which feels inconsistent with other actions like dragging items on top of inspector sections (which uses a delay configured in some project/editor setting). The delay avoids accidentally switching tabs when quickly dragging an item on top of unrelated tabs.
See KDE's Dolphin for comparison:
kde_dolphin_drag_and_drop_onto_tabs.mp4
|
The bottom panel also doesn't have delay. It can be improved later I think. |
scene/gui/tab_bar.cpp
Outdated
| } | ||
| } | ||
| } else if (switch_on_hover && hover > -1 && hover != current) { | ||
| const_cast<TabBar *>(this)->set_current_tab(hover); |
There was a problem hiding this comment.
I don't really like how we do this in a const method, but it happens a lot in can_drop_data and the current alternatives aren't great. So its fine for now.
6c9dd11 to
bf5d7fa
Compare
|
Well, turns out there were quite a few issues with what I did (including TabContainer rearranging not working at all, though not sure if it was from the beginning or after my latest changes). I modified my approach a bit and it should be all working now. |
There was a problem hiding this comment.
This causes errors when dragging a node from the scene dock, switching to another scene by hovering over the scene tab bar, and trying to drop to the scene dock. It seems to sometimes crash, not sure how exactly to reproduce yet.
So the scene tree dock dragging logic will need some tweaks.
ERROR: Node not found: "/root/@EditorNode@21408/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@26/DockVSplitCenter/@VSplitContainer@54/@VBoxContainer@55/@EditorMainScreen@102/MainScreen/@CanvasItemEditor@11646/@VSplitContainer@11298/@HSplitContainer@11300/@HSplitContainer@11302/@Control@11303/@SubViewportContainer@11304/@SubViewport@11305/Control2/Control" (absolute path attempted from "/root/@EditorNode@21408/@Panel@14/@VBoxContainer@15/DockHSplitLeftL/DockHSplitLeftR/DockVSplitLeftR/DockSlotLeftUR/Scene/@SceneTreeEditor@5127").
There is also issues when trying to drag text between text edits in a similar way, when dragging between scenes changes the inspector and creates TextEdits. I guess this is because it never receives NOTIFICATION_DRAG_BEGIN since the dragging started before it existed.
ERROR: The main caret should not be removed. ERROR: scene\gui\tree.cpp:1509 - Index p_column = 0 is out of bounds (cells.size() = 0).
This seems like a larger dragging issue, and NOTIFICATION_DRAG_BEGIN should be sent to all new nodes while dragging is ongoing.
| drag_data["type"] = p_type; | ||
| drag_data["type"] = "tab"; | ||
| drag_data["tab_type"] = p_type; |
There was a problem hiding this comment.
Note that changing this means that some users may need to update it as well, see gilzoide/godot-dockable-container#24
Maybe instead we could keep the type the same and add a drag_data["is_rearrange_tab"] = true or something.
There was a problem hiding this comment.
idk, consistent type makes more sense.
Technically this is not part of the API, so compatibility is not a concern here.
|
I reproduced the crash with a call stack. DetailsException has occurred: W32/0xC0000005 |
|
The errors should be fixed now. |
|
I don't think the switch should be instantaneous. In other places in the editor with the same mechanism, there's a brief pause before it happens. |
|
Which other place involves switching tabs and has a delay? |
|
Not tabs specifically, but in the inspector for example, dragging something to a folded category will only unfold it after a few milliseconds: Screencast_20250918_111256.webm |
|
As I already mentioned, the bottom panel (which is the closest to a tab bar with switch on hover) does not have delay: godot.windows.editor.dev.x86_64_vUT2lrkHKM.mp4If this PR adds a delay and #106164 gets merged, bottom panel will have the delay too. I can add it if this behavior change is ok (at least it will be consistent). |
|
I would be in favor of the delay, as this behavior is what I see when using other software. |
|
Added the delay. |
YeldhamDev
left a comment
There was a problem hiding this comment.
Windows warnings should be fixed, but overall looks good. Would be nice if the delay time would be centralized and shared by multiple UI elements, but that's for another PR.
This comment was marked as resolved.
This comment was marked as resolved.
Repiteo
left a comment
There was a problem hiding this comment.
scene/main/timer.h is no longer a transitive include
|
Thanks! |
Docks will open when hovered during dragging.
ayOjP0dLwt.mp4
Same behavior exists in bottom panel.
EDIT:
Reworked to add
switch_on_hoverto TabBar. Now it works everywhere.godot.windows.editor.dev.x86_64_8V0QtGUsXA.mp4
(pretty sure there was an issue for switch on hover for scenes)