Long cards opened with show all get a Show less button
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0ec50cc1fc
commit
a4688c1a4b
3 changed files with 31 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ func _init() -> void:
|
||||||
await _test_resize()
|
await _test_resize()
|
||||||
await _test_compact()
|
await _test_compact()
|
||||||
await _test_play_drag_selects()
|
await _test_play_drag_selects()
|
||||||
|
await _test_show_less()
|
||||||
finish()
|
finish()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,3 +87,21 @@ func _test_play_drag_selects() -> void:
|
||||||
_check(main.selection.has("road"), "it selects what the box touches")
|
_check(main.selection.has("road"), "it selects what the box touches")
|
||||||
main.clear_selection()
|
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")
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ func fill(col: VBoxContainer, build: bool, ranged: bool, collapsed: bool) -> voi
|
||||||
pad.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
pad.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
card.list_scroll.add_child(pad)
|
card.list_scroll.add_child(pad)
|
||||||
col.add_child(card.list_scroll)
|
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:
|
else:
|
||||||
col.add_child(pad)
|
col.add_child(pad)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,15 @@ func make_more_row(numw: float) -> PanelContainer:
|
||||||
return more_row
|
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:
|
func more_text() -> String:
|
||||||
var table := card.table
|
var table := card.table
|
||||||
var hidden := table.entries.size() - card.rows.size()
|
var hidden := table.entries.size() - card.rows.size()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue