Skip to content

Add ability to drag-toggle visibility in scene tree editor#118634

Open
mihe wants to merge 1 commit intogodotengine:masterfrom
mihe:scene-visibility-drag
Open

Add ability to drag-toggle visibility in scene tree editor#118634
mihe wants to merge 1 commit intogodotengine:masterfrom
mihe:scene-visibility-drag

Conversation

@mihe
Copy link
Copy Markdown
Contributor

@mihe mihe commented Apr 16, 2026

Resolves godotengine/godot-proposals#5488.
Supersedes #102009.

This adds the ability to drag-toggle the visibility of nodes in the scene node editor, where the toggled state of the first node is applied to any subsequent node whose visibility button you drag across.

Unlike #102009 this involves no Tree changes (which seemed to be a point of contention there) and is instead contained almost entirely within the gui_input handler of SceneTreeEditor.

visibility-dragging.webm

A couple of noteworthy quirks:

  1. The undo action is created when you release the mouse button, meaning after we've already changed the visibility states. There may potentially be some edge-cases where we never actually put the changes on the undo stack.
  2. Since we don't suppress the Tree button handling when starting the drag operation, the visibility button you start from will be in a pressed state for the duration of the drag.

Disclaimer: AI tooling was used to review this change, which prompted a few minor changes, all of which have been carefully reviewed to the best of my ability.

Comment thread editor/scene/scene_tree_editor.cpp Outdated
@mihe mihe force-pushed the scene-visibility-drag branch from 7a23a04 to 682b68d Compare April 16, 2026 08:44
@KoBeWi KoBeWi requested a review from a team April 16, 2026 12:45
Comment thread editor/scene/scene_tree_editor.cpp Outdated
Comment thread editor/scene/scene_tree_editor.cpp Outdated
@kleonc
Copy link
Copy Markdown
Member

kleonc commented Apr 16, 2026

Seems the drag is not being interrupted/reset on focus lost, this can lead to incorrect state. To see it in action
(tested on Windows 10):

  1. Start drag-toggling the visibility buttons by LMB press.
  2. Alt+Tab to another app.
  3. LMB release.
  4. Alt+Tab back to Godot.
  5. Hover the mouse over the visibility buttons, it's still in drag-toggling state (with mouse not pressed anymore).

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented Apr 16, 2026

On that note, maybe there should be a way to cancel the drag? Like RMB or Escape.

@mihe mihe force-pushed the scene-visibility-drag branch 2 times, most recently from c52838a to bc18531 Compare April 16, 2026 15:17
@mihe
Copy link
Copy Markdown
Contributor Author

mihe commented Apr 16, 2026

Seems the drag is not being interrupted/reset on focus lost, this can lead to incorrect state.

Fixed (?) by resetting the drag state on NOTIFICATION_APPLICATION_FOCUS_OUT/NOTIFICATION_WM_WINDOW_FOCUS_OUT.

On that note, maybe there should be a way to cancel the drag? Like RMB or Escape.

I assume ui_cancel is meant to do that kind of thing, and seems to be what Viewport uses to stop its dragging as well, so I just copied what it was doing. Viewport does however not respect ui_cancel when bound to a mouse button, which seems like it might be a bug, but I copied it anyway.

@mihe mihe force-pushed the scene-visibility-drag branch from bc18531 to ab39979 Compare April 16, 2026 15:36
@mihe
Copy link
Copy Markdown
Contributor Author

mihe commented Apr 16, 2026

On that note, maybe there should be a way to cancel the drag? Like RMB or Escape.

It turned out that Viewport was in fact stopping its dragging on RMB as well (which perhaps was why you suggested it) so I threw that in as well.

Comment thread editor/scene/scene_tree_editor.cpp Outdated
Comment thread editor/scene/scene_tree_editor.cpp Outdated
Copy link
Copy Markdown
Contributor

@passivestar passivestar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works as expected. A much needed UX improvement.

Co-authored-by: Kasper Arnklit Frandsen <kasper.arnklit@gmail.com>
@mihe mihe force-pushed the scene-visibility-drag branch from ab39979 to 96a5791 Compare April 16, 2026 20:20
@mihe mihe modified the milestones: 4.x, 4.8 Apr 16, 2026
Copy link
Copy Markdown
Member

@Calinou Calinou left a 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 (including undo/redo and crossing gaps of nodes without visibility toggles). Code looks good to me.

@keestak
Copy link
Copy Markdown

keestak commented Apr 24, 2026

This pr looks good, I included the extra api for a generic click and drag in my own pr because it was requested in the issue I linked and this doesn't, but it's probably cleaner as a result. I'll close my pr since this one supersedes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow toggling visibility of several nodes in the Scene tree dock by click-and-dragging (and/or on all selected nodes at once)

7 participants