Godot Version
4.4.1
Question
Edit:
Since my original text soup seems to be a little to vague, ill try to give a more concise description of my problem. I want to create a UI to display cards in a collection (think Hearthstone or MTG arena). The cards are 3D scenes, that wiggle a little for flavor when you mouse over them. I can display them in the UI with Viewport Containers without any problems. I want to use a ScrollContainer to display multiple cards in a row, and scroll horizontally. This UI should be able to adjust to any Height, so i can not just give the cards a fixed size. With the height of the containers determined by the parent, the width should automatically adjust. Currently, scrolling only happens when there are so many cards displayed, that they are shrunk to their minimum size, which is non adaptive, so the cards overlap.
TextureRect has the exact behaviour i want in “ExpandMode”:“FitWidthProportional”, but frustratingly, i cannot find it in any other control nodes.
Original post:
Hey everyone, i hope some UI wizard can figure something out for me. I want to have a scrolling image gallery, that displays multiple images and eventually extends horizontally. I am using a Scroll container, a Hboxcontainer and multiple margin containers. When i put imageRects inside these margin containers, everything works as it should, because i can set the “ExpandMode” to “FitWidthProportional” Forcing the Texture Rect to have a width that is based on the height, and thus making the Scroll container eventually having to scroll.
However my actual UI contains SubViewportContainers, instead of image Rects, since i want to display 3d elements. How do i force these SubViewportContainers (or margin containers or whatever) to ask the parent container for a width that fits their aspect ratio with regards of their heights. Essentially adjusting the minimum width, with respect to the current height.
I have fiddled around with "Aspect ration container"s, but i think they do exactly the opposite of what i want. They just force whatever is inside them to always have the same aspect. But they do not ask the parent container for space, with respect to their height. Why is it, that i can only find this “ExpandMode” on TextureRects?
The following does not work, since the containers cant ask for more width, proportional the their height:
It seems there is no Container that actually asks for space from the parent container, depending on the height or width.
I also posted this on reddit: https://www.reddit.com/r/godot/comments/1o4sqwy/help_with_scroll_container/



