33
submitted 3 months ago* (last edited 3 months ago) by TheOfficial@programming.dev to c/godot@programming.dev

Solution: the scrollable container was also scrollable horizontally! I had to disable that and it finally expanded to the size of its contents.

Hi,

I found out Godot can be (ab)used to make a cross platform GUIs for applications and would like to make a window with a main container on the left and scrollable feed on the right. The scrollable feed should expand horizontally (max 20% of available space) depending on the size of the contents it has.

I've split the main GUI using an HBoxContainer with a VBoxContainer on the left (mainContainer) and a ScrollContainer (feedScroll) on the right with a VBoxContainer in that. When setting "Expand = true" on mainContainer, it just pushes aside the feedScroll which then has width of 0. The buttons have a min size, so I expected them to widen the vBoxContainer and succeedingly the feedScroll. Alas, the VBoxContainer does have the right width (as you can see in the image), but the feedScroll doesn't have a width.

Below is the scene.

gui.tscn

[gd_scene load_steps=3 format=3 uid="uid://c1jga0ql8cbyx"]

[ext_resource type="Script" uid="uid://ceyrteq5kukei" path="res://button.gd" id="1_80edf"]

[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_k6omp"]

[node name="gui" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="rootMargin" type="MarginContainer" parent="."]
material = SubResource("CanvasItemMaterial_k6omp")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="HBoxContainer" type="HBoxContainer" parent="rootMargin"]
layout_mode = 2

[node name="mainContent" type="VBoxContainer" parent="rootMargin/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3

[node name="feedScroll" type="ScrollContainer" parent="rootMargin/HBoxContainer"]
layout_mode = 2

[node name="VBoxContainer" type="VBoxContainer" parent="rootMargin/HBoxContainer/feedScroll"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/separation = 10

[node name="Button" type="Button" parent="rootMargin/HBoxContainer/feedScroll/VBoxContainer"]
custom_minimum_size = Vector2(200, 30)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
text = "I have a lot of text"
script = ExtResource("1_80edf")

[node name="Button2" type="Button" parent="rootMargin/HBoxContainer/feedScroll/VBoxContainer"]
layout_mode = 2
text = "This is a marginal text"

[node name="Button3" type="Button" parent="rootMargin/HBoxContainer/feedScroll/VBoxContainer"]
layout_mode = 2
text = "I have more text in here"

[node name="Button4" type="Button" parent="rootMargin/HBoxContainer/feedScroll/VBoxContainer"]
layout_mode = 2
text = "Quite a big button lad"

[connection signal="pressed" from="rootMargin/HBoxContainer/feedScroll/VBoxContainer/Button" to="rootMargin/HBoxContainer/feedScroll/VBoxContainer/Button" method="_on_pressed"]

Help would be appreciated. Thanks

top 2 comments
sorted by: hot top new old
[-] bjoern_tantau@swg-empire.de 12 points 3 months ago

Fun fact, the Godot editor was made with Godot.

[-] TheOfficial@programming.dev 2 points 3 months ago

That is very cool! A good demo of what is possible :)

this post was submitted on 26 Dec 2025
33 points (97.1% liked)

Godot

7544 readers
72 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS