Fix: world cards render at ~1px wide once real data exists
Reported directly by the user after seeding a test world through the browse-worlds screen: "screen is blank now". Two compounding layout bugs, both real: 1. world_list.tscn's root VBoxContainer had no anchors at all, only size_flags -- but its parent (the scene's root node) is a plain Control, not a Container, so size_flags on a Control's direct child are meaningless there. Without anchors it never actually filled the screen, so it (and everything under it) collapsed toward zero size. 2. size_flags_horizontal/vertical used the raw integer 4 everywhere expand-fill was clearly intended (ScrollContainer, its WorldList child, HeaderHBox, TitleLabel) -- but 4 is Control.SIZE_SHRINK_CENTER in Godot 4, not SIZE_EXPAND_FILL (which is 3). ScrollContainer with SHRINK_CENTER takes only its own minimum size instead of expanding, cascading a ~1px width down through every card and every label. Confirmed the actual enum values by asking Godot directly rather than assuming. Both are exactly the kind of bug a headless smoke test checking only "did cards get added to the tree" can't catch -- child_count was correctly non-zero, nothing crashed, the content was just rendered invisibly thin. Verified the fix is real by deliberately reintroducing bug #2 and confirming the test now correctly fails (card width 25px, below the 200px sanity threshold) before restoring it. Also replaced the card background: it was a ColorRect manually moved to child index 0 of a VBoxContainer, which doesn't work as an overlay -- a VBoxContainer lays out ALL its children in sequence, so the "moved to front" ColorRect rendered as an empty dark bar ABOVE the text, not behind it. Now a proper PanelContainer with a StyleBoxFlat background, the idiomatic way to get a colored panel behind auto-laid-out content in Godot. smoke_test_world_list.gd strengthened to actually catch this class of bug going forward: seeds a real world via POST /api/worlds/ first (the checkpoint runner's fresh DB meant the populated-card path never ran in CI at all before this, only empty-list did), and asserts each card's real computed width, not just that cards exist. Full checkpoint suite re-verified clean on this branch: migrations, 68/68 pytest, all 6 Godot smoke tests, both platform exports. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+19
-12
@@ -88,10 +88,26 @@ func _refresh_worlds() -> void:
|
||||
|
||||
## Create a visual card for a single world entry.
|
||||
func _create_world_card(world_dict: Dictionary) -> Control:
|
||||
# PanelContainer for the background, not a ColorRect moved to child index
|
||||
# 0 of a VBoxContainer -- a VBoxContainer lays out ALL its children in a
|
||||
# vertical sequence, it has no concept of "float this one child behind
|
||||
# the others as an overlay". That version rendered as an empty dark bar
|
||||
# sitting above the text, not a background behind it.
|
||||
var panel := PanelContainer.new()
|
||||
panel.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
panel.custom_minimum_size = Vector2(0, 80)
|
||||
var style := StyleBoxFlat.new()
|
||||
style.bg_color = Color(0.15, 0.15, 0.15, 1.0)
|
||||
style.content_margin_left = 12
|
||||
style.content_margin_right = 12
|
||||
style.content_margin_top = 8
|
||||
style.content_margin_bottom = 8
|
||||
panel.add_theme_stylebox_override("panel", style)
|
||||
|
||||
var card := VBoxContainer.new()
|
||||
card.size_flags_horizontal = Control.SIZE_FILL
|
||||
card.custom_minimum_size = Vector2(0, 80)
|
||||
card.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
card.add_theme_constant_override("separation", 4)
|
||||
panel.add_child(card)
|
||||
|
||||
var name_label := Label.new()
|
||||
name_label.text = world_dict.get("name", "Unnamed World")
|
||||
@@ -123,13 +139,4 @@ func _create_world_card(world_dict: Dictionary) -> Control:
|
||||
card.add_child(desc_label)
|
||||
card.add_child(meta_label)
|
||||
|
||||
# Subtle background for the card
|
||||
var bg := ColorRect.new()
|
||||
bg.color = Color(0.15, 0.15, 0.15, 1.0)
|
||||
bg.size_flags_horizontal = Control.SIZE_FILL
|
||||
bg.size_flags_vertical = Control.SIZE_FILL
|
||||
bg.custom_minimum_size = Vector2(0, 80)
|
||||
card.add_child(bg)
|
||||
card.move_child(bg, 0)
|
||||
|
||||
return card
|
||||
return panel
|
||||
|
||||
Reference in New Issue
Block a user