Repository: godot
Issue: Autowrap multiline buttons don't default to their content's height while using container layout inside VBoxContainer
Labels: bug,topic:gui

### Tested versions

- Reproducible in: v4.3.stable.mono.official [77dcf97d8]



### System information

Godot v4.3.stable.mono - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3713) - 12th Gen Intel(R) Core(TM) i7-12700K (20 Threads)

### Issue description

**Expected result:** 

Multiline buttons set to `self.size_flags_vertical = Control.SIZE_FILL` (or some other existing or new setting) should determine their height based on the text content (calculated on creation and on text change). If not asked to shrink or expand, they should default to that height inside containers.

Mockup:
![Image](https://github.com/user-attachments/assets/47a095c4-b836-4efa-9a8f-dc14dd69f444)

---

**Actual results:**

1. `self.size_flags_vertical = Control.SIZE_EXPAND_FILL`:

a) With long text - works as expected (?) and scrolls correctly too:
![Image](https://github.com/user-attachments/assets/2ef93ef6-83cd-4112-8df5-7633b4093be4)

b) With short text - works as expected - buttons fill available space:
![Image](https://github.com/user-attachments/assets/73ad5025-4ea8-4109-95d9-00a218bd3ecf)


2. `self.size_flags_vertical = Control.SIZE_EXPAND`:

a) With long text - button containers take 1 line, the text takes multiple lines and overflows, and there is empty space between buttons:
![Image](https://github.com/user-attachments/assets/5c864336-9c95-41b8-8a20-2a193376aae0)

b) With short text - the empty space stays the same:
![Image](https://github.com/user-attachments/assets/2abb18fc-353e-43d7-b4a0-80a3e785a524)

3. `self.size_flags_vertical = Control.SIZE_FILL`:

Regardless of text length, button containers always take 1 line, and both texts are drawn on top of each other:
![Image](https://github.com/user-attachments/assets/f5983b1e-3a1c-4c5a-b197-695529b01ba5)

---

So it seems to me there is no setting that would tell my multiline buttons to "take up as much space as you need for content, not more and not less", which I believe is not what was intended when this feature was released. (I'm new to Godot though, so I'll appreciate being corrected if I'm mistaken!)

---

**Code** (happy to provide more information if needed): 

Two custom buttons were created and inserted into a VBoxContainer from a script:

```
### interaction_set_container.gd
# container that updates the current set of buttons based on interaction_id received from currently existing button
func on_interaction_id_change(_interaction_id: str):   
  if _interaction_id == "INTERACTION_A":
		self.buttons = [
			InteractionButton.new("INTERACTION_B", tr("TEXT_B")),
			InteractionButton.new("INTERACTION_C", tr("TEXT_C")),
		]
  (...) # etc

	for child in self.buttons_container.get_children():
		self.buttons_container.remove_child(child)

	for button in self.buttons:
		button.connect("interaction_button_pressed", self.on_interaction_id_change)
		self.buttons_container.add_child(button)
```

```
### interaction_button.gd
# programatically created button that has text, emits ID, and doesn't do anything else
class_name InteractionButton
extends Button
signal interaction_button_pressed

var interaction_id: InteractionId.InteractionIds

func _init(_interaction_id: Istring, _label_text: String):
	self.interaction_id = _interaction_id
	self.text = _label_text
	self.theme = preload("res://interaction_set/interaction_button_theme.tres")

	self.autowrap_mode = TextServer.AUTOWRAP_WORD
	self.alignment = HORIZONTAL_ALIGNMENT_LEFT
	self.size_flags_vertical = Control.SIZE_EXPAND_FILL # tried also SIZE_FILL and SIZE_EXPAND; results below
	self.clip_text = false


func _pressed():
	interaction_button_pressed.emit(interaction_id)
```

Containers tree in the scene:
![Image](https://github.com/user-attachments/assets/bf6c87b6-c4aa-4f5a-b7ad-212e0c5eec15)

InteractionSetContainer layout settings:
![Image](https://github.com/user-attachments/assets/6e1e32bd-0c87-42d5-9892-5e447fa07f30)

### Steps to reproduce

1. Run the project (or use the code above).
2. Observe the issue.
3. Observe what changes with different `size_flags_vertical` InteractionButton settings.

### Minimal reproduction project (MRP)

[MyProject.zip](https://github.com/user-attachments/files/18137376/MyProject.zip)