How does custom_minimum_size work?

Godot Version

Godot 4.2.1 stable


I’m trying to change the width of a container and make it grow from its left size, from what I undestand you achieve this by changing the custom_minimum_size and it works, but only on the editor, at runtime its inconsistent. But if the initial min size is equal to max value I possible need it stops working completly. I don’t undestand how It works at first I thought that if the size value is higher than the min_size nothing should change, but on the editor setting a low min_size resizes the container to the min_size.

Gif of the problem since the forum doesn’t display it

There you can see that if I make the starting min_size 280px shorter on the x axis It works, and then after hiding the bottom panel while the left panel is hidden too it breaks, and lastly I show how if the initial value of the min_size is 1280 the max value possible, it doesn’t work at all

This are the two functions, sorry for the trama they may cause, any feedback is welcome. I use toggle_DebugLPanel() tweens 2 containers along the x axis and then sets the min_size of the bottom panel, at run time the editor says this is working, but the actual size stops adjusting to the min size, so I’m confused about why it works both ways, is this a bug? The other function does the same but on the y axis and it also stops updating the size according to the min_size if it is initialized as its max value.

func toggle_DebugLPanel():
	if tweening_nodes.has(Debug_Info) or tweening_nodes.has(Debug_Conf):
	var tween    :Tween = create_tween()
	var end_pos  :float = -Debug_Conf.size.x if Debug_Conf.is_open else 0
	var duration :float = 0.1
	tween.tween_property(Debug_Info, "position:x", end_pos + Debug_Conf.size.x + 4, duration)
	tween.tween_property(Debug_Conf, "position:x", end_pos, duration)
	tween.tween_property(Debug_BPanel, "custom_minimum_size:x", get_viewport().size.x - (Debug_Conf.size.x + 4) * int(!Debug_Conf.is_open), duration)
	Debug_Conf.visible = true
	Debug_Conf.is_open = !Debug_Conf.is_open

	await tween.finished
	Debug_Conf.visible = Debug_Conf.is_open

func toggle_DebugBPanel():
	if tweening_nodes.has(Debug_BPanel):
	var tween     :Tween = create_tween().set_parallel(true)
	var duration  :float = 0.3
	var vp_size_y :int   = get_viewport().size.y
	var end_pos   :float = vp_size_y if Debug_BPanel.is_open else vp_size_y - Debug_BPanel.size.y
	var end_size  :float = 0 if Debug_BPanel.is_open else vp_size_y
	if Debug_BPanel.is_open:
		tween.tween_property(Debug_BPanel, "custom_minimum_size:y", end_size, duration)
		tween.tween_property(Debug_BPanel, "position:y", end_pos, duration).set_delay(0.13)

		tween.tween_property(Debug_BPanel, "position:y", end_pos, 0.2)
		tween.tween_property(Debug_BPanel, "custom_minimum_size:y", end_size, 0.1).set_delay(0.2)

	Debug_BPanel.is_open = !Debug_BPanel.is_open

	await tween.finished
	Debug_BPanel.visible = Debug_BPanel.is_open

After you tween the minimum size, try changing its size.y to 0. This should force the node to update back to its minimum size.

The container sizing flags could be at play here too, I would set them to be shrink_begin or shrink_end depending what you want.

1 Like

Forcing the node to update its size helps, but it also forgets it is anchored to the bottom right corner, after bashing my head against the wall for a while I hovered over the property container sizing:


My problem was that my nodes are containers but not inside a container as their parent is a CanvasLayer and so the way their size property is manipulated is different than when they are inside a container. But this was so confusing because it worked on the editor and it worked at runtime depending on the initial custom_minimum_size, also the category name Container Sizing seems a bit missleading to me, english is not my first language but I would call it Contained Sizing since this property appears on nodes that are containers themselves.

Anyway here is the final result on a minimal reproduction project

Here you can see that moving the B_Panel node inside the margin container solves the issue while using it as it is moves the node to the left on every key press

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.