godotengine / godot-proposals

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

Add linked flags to Control size properties (allows resizing from the inspector without changing the aspect ratio) #7014

Open hydroper opened 1 year ago

hydroper commented 1 year ago

Describe the project you are working on

N/A

Describe the problem or limitation you are having in your project

When you want to resize a node, generally you can change its scale values to something like (3, 3) (i.e. 3 times "larger").

However, the anchor presets in the editor currently ignore the node's scale property, so you get inconsistency when using the anchor presets. Thus, you need to alternatively resize the node, however that requires you to use the brain to multiply the size (x, y), or you use an external calculator, which unnecessarily takes time.

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

Add an option to prevent distortion while resizing a node in the editor, i.e. locking the ratio to n:n; similiar to using scale, but useful since scale is currently not taken into consideration within anchor presets.

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

A checkbox above the "Size" fields will appear in the editor, allowing to preventing distorting e.g. a bitmap (TextureRect).

image

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

No.

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

It is an editor functionality.

Calinou commented 1 year ago

This already exists in the form of linked properties (see Node2D and Node3D's scale properties), but these need to be enabled on a per-property basis.

hydroper commented 1 year ago

@Calinou I'm not sure I'm understanding you right, but in the start of the issue I already mentioned the scale properties. Yes, there is a lock button to the right of the scale property in the editor.

Calinou commented 1 year ago

@Calinou I'm not sure I'm understanding you right, but in the start of the issue I already mentioned the scale properties. Yes, there is a lock button to the right of the scale property in the editor.

What I mean is that properties need to be manually opted into displaying this "linked" button, as it doesn't make sense to display that icon for all Vector2/Vector3 properties. Feel free to open a pull request for this :slightly_smiling_face:

See how it's done for Node3D's scale property: https://github.com/godotengine/godot/blob/0f76ff2115ae56e6638e1e2bdb8851d470e6e0e3/scene/3d/node_3d.cpp#L1194

hydroper commented 1 year ago

I've learned that you can use times in the input boxes! So you can do e.g.

And the Godot editor will automatically resolve this multiplication.