godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

GraphEdit/GraphNode selection strategies #5390

Open maximkulkin opened 2 years ago

maximkulkin commented 2 years ago

Describe the project you are working on

Dialog system for games featuring graph representation of dialog flow

Describe the problem or limitation you are having in your project

I'm using comment graph nodes as containers for other nodes. With current box selection implementation it is impossible to select nodes inside comment node without selecting the comment node itself.

https://user-images.githubusercontent.com/10785/189471303-70de7b56-1a8a-4461-8653-a0bd50e87c0f.mp4

On the video it shows that doing box selection selects the comment nodes as well (even if selection box will start outside of comment node and then cover inner nodes, it will still select comment node because current strategy is to select every node which rectangle intersects selection box.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

GraphNode in 4.x got selectable property which controls if node can be selected or not. But just marking comment node as non-selectable is a bad solution, because I would still like to be able to select the comment node and move it around, but only if it is selected by clicking on its title or box selected by completely covering it.

My proposal is to replace that boolean property with a flags property which will control different selection options:

Enabling box selection with intersection will select node even if box selection fully covers node and box selection with full cover option is turned off.

Add option to GraphEdit to enable box selection (turned on by default). This will allow completely disabling box selection if need (to avoid consuming GUI events and drawing useless selection box).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Modify GraphEdit gui_input code to check if graph node has corresponding selection option enabled when selecting nodes.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Default settings on both GraphEdit and GraphNode will preserve current behavior: all graph node selection options are turned on by default, box selection is enabled in GraphEdit.

Is there a reason why this should be core and not an add-on in the asset library?

GraphEdit is an important core component for building rich editor extensions and it would be nice to have customizable. Some things like box selection are not exposed to outside and can not be customized, so implementing functionality in and addon is not possible.

Calinou commented 2 years ago
  • box selection selects graph node if it intersects graph node
  • box selection selects graph node if it fully covers graph node

I feel there should also be a third option, "box selection selects graph node if it covers at least 50% of the graph node" (or "covers its center"). I find "whole selection required" systems to be more frustrating than anything.

maximkulkin commented 2 years ago

Are there an examples of systems doing that? I would like to check what the user experience is like.