0 votes

Hello, when i add an empty button in a PanelContainer in the editor toolbar via add_control_to_container(CONTAINER_TOOLBAR, the tool bar is resized vertically. Is it possible to avoid that ?

I have tried several things but nothing works, it seems that the minimum height of my PanelContainer (by default 14*14) is modified to a bigger value but i don't find why.

in Engine by (120 points)

Are you sure the Control you add to the toolbar (and everything inside it) is set to have a smaller size? Did you also checked margins?

2 Answers

0 votes

Yes, the button is empty, this is some code:

tool
extends EditorPlugin
var panel
func entertree():
panel = PanelContainer.new()
var b = Button.new()
panel.addchild(b)
prints(panel.get
childcount(), b.getchildcount())
prints(b.get
margin(MARGINTOP), b.getmargin(MARGINLEFT), b.getmargin(MARGINRIGHT), b.getmargin(MARGINBOTTOM))
prints(panel.get
margin(MARGINTOP), panel.getmargin(MARGINLEFT), panel.getmargin(MARGINRIGHT), panel.getmargin(MARGINBOTTOM))
prints(panel.get
minimumsize(), b.getminimumsize())
add
controltocontainer(CONTAINERTOOLBAR, panel)
prints(panel.get
minimumsize(), b.getminimum_size())

Result:

1 0 # children
0 0 0 0 # margins
0 0 0 0
(14, 14) (12, 20) # min size before
(26, 37) (12, 23) # min size after

The height of the other panels is 29.

by (120 points)
0 votes

You have to use a margin container.

by (40 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.