Reputation: 343
I admit I have not been using godot for very long but I cannot seem to get control nodes to act predictably. I have been able to get close but not with a color background. I tried adding a colorRect and then godot goes completely bonkers. I do not understand how it could have results like that. I have tried every random combination of controls I can think of.
on the left is a broken version with a colorRect. the one on the right is as close to what I want but does not have a colorRect. for some reason the colorrect has completely evaporated. also removing a child node on left does not remove it completely. on the right the children stack properly in the vboxcontainer but on the left, the children stack on top of each other. the row is its own scene, it contains a child scene. that scene has the first scene as children.
I have no idea how to troubleshoot this.
Here is the scene tree for the almost working one on the right.
here is the scene tree for one of the many attempts to add a background color.
I hope someone knows how to do this.
***EDIT Is there a control that works like a jpanel? is there a way I can get access to the layout manager?
***EDIT why does the layout manager in a Container not work like the layout manager in a hboxContainer?
***EDIT
ColorbrickNode is inside of an hbox. that hbox has only two children. those two children should be half of the width of the hbox. look at the size of colorbrickNode, the +- buttons are children of it. how should this be working? how can children be outside of the confines of a control and still be visible?
Upvotes: 3
Views: 4759
Reputation: 343
I got it. I used a margin container. why does a margin container have the functionality but a vanilla container does not have? who knows. why is there a margin container when every container has the ability to set margins? who knows. A margin container has the ability to set the size of its children. a margin container has the ability to have children components stack on top of each other. a margin container should be the default container. the name is very misleading. it is not graphicaly perfect but it is very close.
Upvotes: 2
Reputation: 40220
I think I understand the issue. At least why the ColorRect
turns to a line. I'm assuming you have set its layout to "Full Rect", right? Guessing. But you have NOT set its size flags.
When the ColorRect
inside a container, that container is what will dictate how it is sized and positioned. In this case the container is a HBoxContainer
, right? I'm not sure where you are adding the instances, I'm guessing here. A HBoxContainer
would set its children as columns. So they take the full height, as we see the ColorRect
do. And to decide how much horizontal space it takes… Well, it takes as little as possible, so you get a line.
The VBoxContainer
inside the ColorRect
, on the other hand, has a minimum size. So it overflows the ColorRect
. Yes, we could imagine that could set its minimum size based on its contents… Except, it is not Container
.
Now, to tell a Container
(such as the HBoxContainer
) to size its children differently, you would set the size flags of said children.
I have covered how Control
s are positioned and sized in more detail in other answers here and here.
Upvotes: 1