Having trouble with expand

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Keks

I have a problem with expanding an image, i created a “center container” and put the image in a “textureRect” right below so the “textureRect” is the child of the “center container” and when i tried to enable expand on the texture rectangle then the image just disappears.

Is the bounding rectangle for the textureRect defined?

Becbunzen | 2020-06-03 10:39

Well, i don’t know what a bounding rectangle is, i figured out that it has something to do with min_size. And that it works for me at least even if that not the ideal sollution

Keks | 2020-06-03 12:28

:bust_in_silhouette: Reply From: Becbunzen

See https://docs.godotengine.org/en/stable/classes/class_texturerect.html

If true, the texture scales to fit its bounding rectangle.

To see details for bounding rectangle you need to go to one level up, which textureRect inherits from (see the structure at the top: Control < CanvasItem < Node < Object). Details here: https://docs.godotengine.org/en/stable/classes/class_control.html

Vector2 rect_size
The size of the node’s bounding rectangle, in pixels. Container nodes update this property automatically.

On the same page you can also see that setting rect_min_size is not what you want:

Vector2 rect_min_size
The minimum size of the node’s bounding rectangle. If you set it to a value greater than (0, 0), the node’s bounding rectangle will always have at least this size, even if its content is smaller. If it’s set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes.

Wow! Kicking myself over this one. Spent so long trying to fix it, only to realize that it was this. Thanks for keeping me from going further down that road of futility!

PoisonIvy | 2022-07-15 15:02