From a4688c1a4b239716bc9eab48842cdf67ce4fbcec Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Sat, 14 Nov 2026 14:36:54 -0600 Subject: [PATCH] Long cards opened with show all get a Show less button Co-Authored-By: Claude Opus 5.5 --- tests/test_card_size.gd | 19 +++++++++++++++++++ ui/table_card_list.gd | 3 +++ ui/table_card_rows.gd | 9 +++++++++ 3 files changed, 31 insertions(+) diff --git a/tests/test_card_size.gd b/tests/test_card_size.gd index cdcafb4..fc9a1cb 100644 --- a/tests/test_card_size.gd +++ b/tests/test_card_size.gd @@ -10,6 +10,7 @@ func _init() -> void: await _test_resize() await _test_compact() await _test_play_drag_selects() + await _test_show_less() finish() @@ -86,3 +87,21 @@ func _test_play_drag_selects() -> void: _check(main.selection.has("road"), "it selects what the box touches") main.clear_selection() + +## A long card opened with "show all" has "▲ Show less" to fold it up again. +func _test_show_less() -> void: + var t := main.data.get_table("trinkets") + if not t.collapsed: + main.toggle_collapse("trinkets") + await _frames(2) + main.toggle_collapse("trinkets") + await _frames(2) + var less: Array = [] + for node in main.card_for("trinkets").find_children("*", "Button", true, false): + if node.has_meta("show_less"): + less.append(node) + _check(not t.collapsed and less.size() == 1, "an opened long card shows Show less") + if less.size() == 1: + (less[0] as Button).pressed.emit() + await _frames(2) + _check(t.collapsed, "Show less collapses it again") diff --git a/ui/table_card_list.gd b/ui/table_card_list.gd index 0526c4b..67be6c1 100644 --- a/ui/table_card_list.gd +++ b/ui/table_card_list.gd @@ -25,6 +25,9 @@ func fill(col: VBoxContainer, build: bool, ranged: bool, collapsed: bool) -> voi pad.size_flags_horizontal = Control.SIZE_EXPAND_FILL card.list_scroll.add_child(pad) col.add_child(card.list_scroll) + if card.table.entries.size() > TableCard.LONG_LIST: + # A long card opened with "show all" can be folded up again here. + col.add_child(card.rows_ui.make_less_row()) else: col.add_child(pad) diff --git a/ui/table_card_rows.gd b/ui/table_card_rows.gd index bf6f423..2f50783 100644 --- a/ui/table_card_rows.gd +++ b/ui/table_card_rows.gd @@ -260,6 +260,15 @@ func make_more_row(numw: float) -> PanelContainer: return more_row +## Under an opened long list: "▲ Show less", which collapses the card again. +func make_less_row() -> Button: + var less := TableCardEditing.footer_button("▲ Show less", Style.MUTED) + less.tooltip_text = "Collapse this card to its rolled result" + less.set_meta("show_less", true) + less.pressed.connect(func() -> void: card.main.toggle_collapse.call_deferred(card.table.id)) + return less + + func more_text() -> String: var table := card.table var hidden := table.entries.size() - card.rows.size()