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

GridContainer does not position and resize its children in a grid #80922

Closed
SandroMaglione opened this issue Aug 23, 2023 · 4 comments
Closed
Labels

Comments

@SandroMaglione
Copy link

Godot version

v4.1.stable.official.970459615

System information

MacBook Pro - macOS 13.3.1

Issue description

I am having an hard time with layouts in general, and in this case specifically with GridContainer.

I tried to recreate the same example shown in the docs:

containers_grid

I create the same node tree, but the result looks different:

Screenshot 2023-08-23 at 11 05 59

I expect that the GridContainer would size its child nodes to fit the available space in 2 equally sized columns. As you can see, the buttons are not resized at all.

This is even worst when the child node is a custom layout. The GridContainer does not reside its children and they all have a 0px width, making the scene look empty.

Steps to reproduce

Try to recreate the example in the docs in a new Godot project should be enough to test the issue.

Minimal reproduction project

N/A

@SandroMaglione SandroMaglione changed the title GridContainer does not position its children in a grid GridContainer does not position and resize its children in a grid Aug 23, 2023
@KoBeWi
Copy link
Member

KoBeWi commented Aug 23, 2023

You need to enable set alignment with Expand flag (in the menu at the top toolbar).

@SandroMaglione
Copy link
Author

After some attempts at changing the expand values of both container and child nodes I was able to achieve horizontal stretching:

Screenshot 2023-08-23 at 13 00 38

The idea is to have Horizontal alignment set to fill and expand for child nodes (no need on the container):

Screenshot 2023-08-23 at 13 02 45 Screenshot 2023-08-23 at 13 02 06

@KoBeWi Is this correct?

@KoBeWi
Copy link
Member

KoBeWi commented Aug 23, 2023

Yes.

@SandroMaglione
Copy link
Author

Great! Thanks @KoBeWi

Extra note: In my case I wanted the horizontal layout to stretch (expand), while keeping the same height vertically. This can be achieved by setting a Custom Minimum Size in Layout for child nodes:

Screenshot 2023-08-23 at 13 09 28 Screenshot 2023-08-23 at 13 09 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants