Plugin and editor tool bar

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Brice
:warning: Old Version Published before Godot 3 was released.

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.

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?

Zylann | 2016-11-18 14:29

:bust_in_silhouette: Reply From: Brice

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

tool
extends EditorPlugin
var panel
func _enter_tree():
panel = PanelContainer.new()
var b = Button.new()
panel.add_child(b)
prints(panel.get_child_count(), b.get_child_count())
prints(b.get_margin(MARGIN_TOP), b.get_margin(MARGIN_LEFT), b.get_margin(MARGIN_RIGHT), b.get_margin(MARGIN_BOTTOM))
prints(panel.get_margin(MARGIN_TOP), panel.get_margin(MARGIN_LEFT), panel.get_margin(MARGIN_RIGHT), panel.get_margin(MARGIN_BOTTOM))
prints(panel.get_minimum_size(), b.get_minimum_size())
add_control_to_container(CONTAINER_TOOLBAR, panel)
prints(panel.get_minimum_size(), b.get_minimum_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.

:bust_in_silhouette: Reply From: char0xff

You have to use a margin container.