Skip to content

Control: anchors_preset keeps getting set to Custom even when manually set to something else #109761

@mgiuca

Description

@mgiuca

Tested versions

  • Reproducible in: 4.5.beta5
  • Not reproducible in: 4.4

System information

Godot v4.5.beta5 - Ubuntu 24.04.2 LTS 24.04 on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce GTX 1060 6GB (nvidia; 535.247.01) - Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 threads) - 7.69 GiB memory

Issue description

The anchors_preset property of Controls has started behaving very weirdly in 4.5. (Happens in beta5 but I have been seeing it for awhile on older betas.) Seen on controls that are not the top-level control of the scene, and have their layout_mode set to Anchors. Here are some of the weird behaviours:

  • When you set layout_mode to Anchors, the anchors_preset will automatically be set to -1 "Custom", even thought that isn't the default (the default value is 0 Top Left).
  • When you manually set it to any of the preset values, it instantly snaps back to "Custom". (Clicking the anchor preset has the desired effect of moving the control, but the preset you chose goes to Custom rather than the thing you picked.) In 4.4, if you choose, for example, "Center Top", it will stay showing "Center Top".
  • Clicking the "set to default" circular arrow button has no effect, it just stays on "Custom". There's no way to clear the "set to default" arrow from this property.
  • As I open and save scene files in my large project, I am noticing all the time that "anchors_preset = -1" is being added to my .tscn files and showing up as something I need to commit to revision control (if I revert it, it just keeps coming back).

All of these are related. I think basically Godot 4.4 would remember what preset you chose, but in 4.5 no matter what you do, it just sets up the actual anchor points and offsets correctly, and then goes "well you have customized it, so I am setting it to Custom". If this is the new intended behaviour, it would be good to change the default to -1 Custom, which would then fix most of the above awkwardness (the "set to default" arrow would disappear and the "anchors_preset = -1" would stop appearing in my git diffs).

Possibly related to #108442 which changed something to do with the anchor presets being set to custom.

Steps to reproduce

  1. Add a new control node (e.g. Label).
  2. Set Layout Mode to Anchors.
  3. Choose various values in the Anchors Preset drop-down, or click the "set to default" arrow.

Minimal reproduction project (MRP)

anchors-preset-test.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Unassessed

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions