godotengine / godot-proposals

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

Show an icon in the scene tree view for each node that has a non empty editor_description #9950

Open Gnumaru opened 2 weeks ago

Gnumaru commented 2 weeks ago

Describe the project you are working on

More than one godot project.

Describe the problem or limitation you are having in your project

I use node comments as way of documenting some details of some nodes, but it is very hard later on to know wich nodes have comments and which doesn't. Hovering over the nodes shows the comment but I should previously know at the first place if the node has a comment or not, otherwise I would need to keep hovering node over node to know which one has a comment a wich one doesn't.

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

When the node has a non empty editor_description, a new icon would be showed in the scene tree view to the right of the node name, alongside the other icons.

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

Several things about a node already have icons at the right of the node name in the scene tree view, like if it is in one or more node groups or if it is locked.

image

There could be a new icon that shows if the node has a comment or not. When clicked, it could directly open up the text edit popup for the editor_description. In the mockup bellow I used the "D" character to indicate (D)escription, but it could also mean (D)ocumentation or (D)ocumented

image

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

I suppose it can. I'm really not familiar with using addons to hack parts of the editor UI that are not meant to be changed, but I have a hunch it could be done with an addon.

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

None besides the usefullness of the feature, wich I admit I'm merely supposing. I think that the editor_description of a node is a great thing, but I suppose it is something few people use due to usability issues. If there where things to help using it, like the icon proposed here, the feature would be more used.

Calinou commented 2 weeks ago

I thought about doing this, but when you see the discussion in https://github.com/godotengine/godot-proposals/issues/7715, you can see the scene tree dock icons are pretty cluttered already :slightly_smiling_face:

Gnumaru commented 2 weeks ago

FRET NOT, for I have the perfect proposal for this😂.

https://github.com/godotengine/godot-proposals/issues/9951

Gnumaru commented 2 weeks ago

I was able to put an icon into the scene tree view using a tool script

image

but I had to disable the button because clicking it also toggles the visibility for some reason. I couldn't freely chose the button position for some reason. Also when I click in an empty space in the scene tree view or if I click the script button in the root node, the icons disappear. I've used the code bellow:

@tool
extends Node
@export var button:bool:
    get: return false
    set(p):
        if not p or not Engine.is_editor_hint(): return
        var vscenetreepath:String = '/root/@EditorNode@17147/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@VSplitContainer@27/@TabContainer@29/Scene/@SceneTreeEditor@4247/@Tree@4231'
        var veditorrootwindow:Window = get_tree().root
        var veditedscenetreetree:Tree = veditorrootwindow.get_node(vscenetreepath) as Tree
        var vscenetreeitem:TreeItem = veditedscenetreetree.get_root()
        while is_instance_valid(vscenetreeitem):
            var vnodepath:NodePath = vscenetreeitem.get_metadata(0) as NodePath
            var vnode:Node = veditorrootwindow.get_node(vnodepath)
            if vnode.editor_description.length() > 0:
                var vhasdescription:bool
                for i in vscenetreeitem.get_button_count(0):
                    vhasdescription = vscenetreeitem.get_button_tooltip_text(0, i) == 'editor_description'
                    if vhasdescription: break
                if not vhasdescription:
                    vscenetreeitem.add_button(0, load('res://D.png'), -1, true, 'editor_description')
            vscenetreeitem = vscenetreeitem.get_next_visible()

image

passivestar commented 2 weeks ago

D is a bit cryptic, a sticky note icon would be more descriptive imo

image

Gnumaru commented 2 weeks ago

Got it.

image