godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Replace hardcoded `TextureProgressBar`'s radial reference cross with internal `Marker2D` node #11225

Open arkology opened 1 day ago

arkology commented 1 day ago

Describe the project you are working on

Editor plugins?

Describe the problem or limitation you are having in your project

It is impossible to remove TextureProgressBar's radial reference cross from editor (or change its appearance), so usage of this node in plugins is limited.

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

Replace hardcoded radial reference cross with editor-only internal Marker2D node. This will no only unblock TextureProgressBar (its radial modes) usage in plugins, but also remove hardcoded stuff (better code?).

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

Calling set_fill_mode() will add child Marker2D node to TextureProgressBar. Current hardcoded reference cross drawing code will be replaced with reference_cross_marker->set_position(p); Inside plugin it will be possible to access this Marker2D node and then you could remove it.

Some mockups of how it will look: Current Prototype
1024x1024 Godot_v4 4-dev2_win64_Lksr6p93Qr godot windows editor dev x86_64_PLyyQBxnf3
48x48 Godot_v4 4-dev2_win64_duNiAhNCOF godot windows editor dev x86_64_6ZL3ie810C

Implementing this could fix issues https://github.com/godotengine/godot/issues/46266 and https://github.com/godotengine/godot/issues/96859.

Currently I working on implementing this, so suggestions about functionality implementations are appreciated. For example, right now I don't have 100% consensus about how exactly to implement addition of Marker2D in set_fill_mode() - should it be created or deleted every time mode changes (radial <-> linear), or created in TextureProgressBar constructor and then just added as child while calling set_fill_mode() (actually, second option sounds better).

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

Could not be worked around, as reference cross is hardcoded.

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

Because radial reference cross drawing is directly hardcoded in NOTIFICATION_DRAW code.

arkology commented 15 hours ago

Possible alternatives for fixing original issues:

Pros: 1) Easier for user to setup.

Cons: 1) This property will always be present, even in release builds. 2) Reference cross will still be that big and hide part of textures, which may be important for low-res textures. 3) Impossible to customise reference cross from plugins.

Pros: 1) Looks more simular to functionality of other nodes. 2) More stuff could be added later like editing range value and offset using gizmo.

Cons: 1) Reference cross will be visible only when node is selected