Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undoing the change of the Anchors Preset of a Control will not restore it's offset/position #85245

Closed
TheSofox opened this issue Nov 22, 2023 · 4 comments · Fixed by #85275
Closed

Comments

@TheSofox
Copy link
Contributor

TheSofox commented Nov 22, 2023

Godot version

4.2rc

System information

Godot v4.2.rc (fa4a653) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 31.0.15.3623) - Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 Threads)

Issue description

If you change the Anchors Preset of a Control, and then hit Undo, the previous Control will have its previous Preset restored, but it won't restore its previous position unless it was the default position of that preset

Video:

GodotLayoutUndoGlitch.mp4

Steps to reproduce

  1. Create a Container and put a Control in it. For example, create a Panel and put a Button in it.
  2. Access the Button's Layout, ensure Layout Mode is set to Anchors, and then change Anchor Preset to Bottom Right.
  3. Observe the Button is in the bottom right of the Panel
  4. Move the Button from its default position. Observe this new position.
  5. Set the Anchor Preset to Top Left (or any other). Note the button will change is position.
  6. Hit Undo (Ctrl+Z)

Expected:
The Button should return to it's previous position, as at the end of step 4.

Actual:
The button is instead returned to default position for Bottom Right, the position it was at at the end of Step 3.

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Nov 22, 2023

@TheSofox Remember that for GitHub video previews to work, you need to have a blank line before and after the video URL. I edited your post accordingly, but remember to do this in the future 🙂

@TheSofox
Copy link
Contributor Author

Made a pull request for fixing this issue. Also noticed it affected Layout Mode too so included a fix for that in the pull request.

@AThousandShips AThousandShips added this to the 4.3 milestone Nov 23, 2023
@hsandt
Copy link
Contributor

hsandt commented Mar 22, 2024

Note that changing Layout Mode from Anchors to Position will also disable Anchors Preset (the field will disappear), causing the same effect.

@TheSofox
Copy link
Contributor Author

TheSofox commented Mar 29, 2024

Yes, my PR is coded to account for that. If either Layout Mode or Anchors Preset is changed, the undo operation will revert the control's entire state, instead of just reverting a single property. I did a quick test to confirm all this.

@KoBeWi KoBeWi removed this from the 4.3 milestone Jul 26, 2024
@Repiteo Repiteo added this to the 4.4 milestone Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants