-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Update size and anchors tutorial #8855
base: master
Are you sure you want to change the base?
Update size and anchors tutorial #8855
Conversation
bf946e2
to
0101d29
Compare
0101d29
to
461a918
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to understand the currently available Godot Docs on this topic and came across this PR when I finally understood the terminology had changed significantly. In reading it, I discovered you can do it all with the mouse, and I thought it should be mentioned in the page.
My suggestions would be:
- Instead of a note saying "Read the section at the end" just have the section there
- Add mouse control information, which makes setting anchors much easier. It even makes it so you don't need to know what the values mean.
With mouse information, this could probably be along the lines of:
- Anchor Presets
- Drag and drop the green handles to show where the control is relative to. Drag the control to where it should be.
- Inspector Anchor Points and Anchor Offset information (Precision placement of a control)
- Centering a control
Instead of manually adjusting the margin and anchor values for every node, you | ||
can use the toolbar's Layout menu, above the viewport. This offers multiple | ||
common presets (e.g. top right, bottom left, center, full rect, bottom wide). | ||
|
||
.. image:: img/layout_dropdown_menu.webp | ||
|
||
After picking a preset (bottom right in the image below), you can also offset | ||
the control node manually by simply dragging it away: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This is also available from the Inspector > Layout > Anchors Preset. I'm not sure either is preferred, but so much happens in the Inspector that it's probably worth knowing you can also adjust it there.
.. note:: | ||
|
||
The simplest approach to control node positioning is to pick a layout | ||
preset from the toolbar above the viewport (see the section at the end). | ||
We go into a bit more detail here for demonstration purposes, and so you | ||
can get a better understanding of how the layout system works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of the note, the Anchor Presets should just be here, because if that solves all of the problems the user has they don't need to keep reading to learn information they aren't going to use.
This is done by first selecting **Anchors** under Layout > Layout Mode and then | ||
**Custom** Under Layout > Anchors Preset. This opens up a menu where we can | ||
edit the **Anchor Points** and **Anchor Offset** properties. Each control | ||
has four anchor points and their corresponding offsets: left, right, bottom, | ||
and top. Anchor points represent a distance in the range of [0, 1] relative to | ||
the equivalent point of the parent control or (in case there is no parent | ||
control) the viewport. | ||
|
||
.. image:: img/margin.webp | ||
|
||
The other important group of properties that affects positioning is the | ||
anchor offsets. The *anchor points* adjust where the *anchor offsets* | ||
are relative *to*. Each individual anchor point can be adjusted from the | ||
beginning to the end of the parent. So the vertical (top, bottom) anchor points | ||
adjust from 0 (top of parent) to 1.0 (bottom of parent) with 0.5 being the | ||
center, and the control anchor offsets will be placed relative to that point. | ||
The horizontal (left, right) anchor points similarly adjust from left to right | ||
of the parent. | ||
|
||
Note that when you wish the edge of a control to be above or left of the | ||
anchor point, you must change the margin value to be negative. | ||
anchor point, you must change the anchor offset value to be negative. | ||
|
||
For example: when horizontal anchors are changed to 1, the margin values | ||
become relative to the top-right corner of the parent control or viewport. | ||
For example: when the horizontal anchors are changed to 1, the anchor offset | ||
values become relative to the top-right corner of the parent control or | ||
viewport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be done with mouse control by dragging the green anchor handles to set the anchor points along with setting the offset by dragging the node to where you want. With snapping and being able to see where they end up visually, it's an easier path to setting the anchors that doesn't require knowing the numbers.
Seeing #7106 wasn't ready to be merged and went inactive, and that no rewrite has happened yet, I tried addressing some of the comments on there, but kept the rest of the tutorial as close to the original as possible. I also updated & added images.
Edit: The latest force-push was a slightly better image for showing anchors.