godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.33k stars 21.24k forks source link

Snapping Controls margins doesn't work after rotating their Rect #35277

Open henriiquecampos opened 4 years ago

henriiquecampos commented 4 years ago

Godot version: Godot 3.2.rc1

OS/device including version: Solus 4 Gnome

Issue description: When ou try to drag the margin of a rotated Control node they don't snap anymore. Might be related to #23030

Steps to reproduce:

  1. Add a Control to the scene
  2. Activate snap to grid
  3. Try to move its margin in the editor, e.g. with the Selection Mode on drag the margin
  4. Now rotate the Control
  5. Try to move its margin in the editor again

bug-report

groud commented 4 years ago

Well yes, how would you want a control to snap to a grid it is not aligned to ? Maybe a local grid, but that is not the same thing.

Edit : What you describe here is expected, so I moved to to enhancement.

henriiquecampos commented 4 years ago

What do you mean by "a grid they are not aligned to"? I didn't get it. The rotation offsets their position somehow?

Their position keep snapping even when rotated, is just the margins that stop snapping after the rotation.

I don't think this is expected, other applications are consistent: you rotate the object, it will keep the snapping regardless.

groud commented 4 years ago

Their position keep snapping even when rotated, is just the margins that stop snapping after the rotation.

The position is a like a point, even if rotated you can easily snap it to a 2D grid. The margin is a single value on one of the side of the control, it cannot be snapped unless it is parallel to one of the grid axis.

I don't think this is expected, other applications are consistent: you rotate the object, it will keep the snapping regardless.

By expected I mean this is not a bug. I disabled the snapping if the control does not align with the grid, on purpose.

On your example, it is rotated by 90°. We could allow snapping for nodes rotated by multiples of 90° to snap to the grid, but that is an enhancement.