From 16ad73adfb68985b1ef88ddf2a47af3ea02643a3 Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Wed, 11 Nov 2026 08:36:13 -0600 Subject: [PATCH] Group marks: member cards' top-right corner in the group's colour Groups get an optional colour (Colour menu on the group); uncoloured groups use the theme token GROUP. The group frame's border matches. Co-Authored-By: Claude Opus 5.5 --- core/table_group.gd | 6 ++++ docs/ARCHITECTURE.md | 4 ++- docs/DESIGN.md | 7 +++-- tests/test_group_marks.gd | 47 +++++++++++++++++++++++++++++ tests/test_group_marks.gd.uid | 1 + ui/actions.gd | 8 +++++ ui/builtin_themes.gd | 2 +- ui/group_card.gd | 2 ++ ui/group_mark.gd | 57 +++++++++++++++++++++++++++++++++++ ui/group_mark.gd.uid | 1 + ui/main_layout.gd | 4 +++ ui/style.gd | 2 ++ ui/table_card.gd | 5 ++- ui/table_card_skin.gd | 7 +++++ ui/theme_store.gd | 1 + 15 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 tests/test_group_marks.gd create mode 100644 tests/test_group_marks.gd.uid create mode 100644 ui/group_mark.gd create mode 100644 ui/group_mark.gd.uid diff --git a/core/table_group.gd b/core/table_group.gd index e6ddb70..2717dbc 100644 --- a/core/table_group.gd +++ b/core/table_group.gd @@ -25,6 +25,9 @@ var details: String = "" var members: Array[String] = [] ## The group this one sits inside ("" = on the spread itself). var parent: String = "" +## "#rrggbb", or "" for the theme's group colour (Style.GROUP). Marks the +## frame's border and each member card's top-right corner. +var color: String = "" func _init(p_id: String = "", p_name: String = "") -> void: @@ -73,6 +76,8 @@ func to_dict() -> Dictionary: d["details"] = details if parent != "": d["parent"] = parent + if color != "": + d["color"] = color return d @@ -83,6 +88,7 @@ static func from_dict(d: Dictionary) -> TableGroup: g.collapsed = bool(d.get("collapsed", false)) g.details = str(d.get("details", "")) g.parent = str(d.get("parent", "")) + g.color = str(d.get("color", "")) var src: Variant = d.get("members", []) if src is Array: for m: Variant in src: diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8c5942e..ac41390 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -147,6 +147,8 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - **2026-11-11:** `ui/deck_reveal.gd` (Deck mode: an animated roll's draws fade only when shown), `ui/entry_handle.gd` (Build: drag handle to reorder results; `TableCardEditing.move_entry` keeps ranges in place). PortLayer hides thread nodes under a card stacked above theirs. + `ui/group_mark.gd`: a member card's top-right corner in its group's colour (`TableGroup.color`, + else `Style.GROUP`); refreshed from `_board_changed`. - **Card visuals and input:** `ui/card_frame.gd` (border + shader), `ui/card_grip.gd` (resize), `ui/card_shield.gd` (zoomed out), `ui/sparkles.gd`; TableCard helpers `table_card_skin/input/ geometry/list/kind_rows.gd` (next to header/rows/editing/value/text). @@ -203,7 +205,7 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - Linux and Windows export presets exist (both include `templates/*.json, help/*.txt`); no Mac or Android preset yet. Both presets also pack `tests/` (harmless; could be excluded). - Loading a big board with every group expanded takes about 5 s (building `TableCard` nodes). -- Group frames are rectangles, so a non-member card lying inside one looks like a member. +- Group frames are rectangles; members are told apart by their coloured top-right corner. Pipes into a collapsed group can't be clicked. - Groups aren't kept in the Canvas and GraphML exports. Logic keys survive only in TableTower JSON. - `{= }` dice in live sheet and variable displays re-roll when the display refreshes. diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 5b2be49..b755c5e 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -55,6 +55,8 @@ Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminol - **2026-11-11 (branch `fonts-and-fixes`):** 13 theme fonts with text/title pickers; Deck mode fade waits for the animation; thread nodes hidden under higher cards; drag handles reorder results. Reroll rule settled by the thread option "Roll again if it comes up". + Group marks: a member card's top-right corner (and the group's border) takes the group's + colour (Colour ▸ on the group menu; uncoloured groups use the theme token GROUP). **Next, likely:** the user's feedback on the Perilous Void spread; Stage II of it; a size audit (§4). @@ -62,9 +64,8 @@ Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminol **Waiting on the user** - Android: export templates are installed (checksum verified); the Android SDK (build-tools, platform-tools) is not. Ask before downloading. No Android preset yet. -- A UI name for the Collection card kind (suggested 2026-11-11: Roster, Family, Ledger/Tally). -- Group frames: a non-member card inside a frame looks like a member. Options given 2026-11-11 - (push it out, hug the members, member colour band, dim the frame); waiting on the user's pick. +- A UI name for the Collection card kind. User floated "Sets" (2026-11-11); it clashes with "set" + as a verb/state ("Not set", "Set X to 7", "is set"). Alternatives offered: Roster, Ledger, Tally. - Thread string art (the user will draw it), then use it like `CardFrame` does for cards. - Repo privacy on Forgejo: needs Niles/sock's username and a token from the user. diff --git a/tests/test_group_marks.gd b/tests/test_group_marks.gd new file mode 100644 index 0000000..c8a500d --- /dev/null +++ b/tests/test_group_marks.gd @@ -0,0 +1,47 @@ +extends TestBase +## Group marks: a member card's top-right corner shows its group's colour (its +## own, else the theme's GROUP); a card that only lies inside the frame has +## none. The colour is saved and undoable. +## Run: godot --headless --path . -s res://tests/test_group_marks.gd -- --sample + + +func _init() -> void: + if not await start_main(): + return + main.data.load_dict({"format_version": 2, "id": "marks-test", "name": "Marks", "tables": [ + {"id": "a", "name": "Alpha", "x": 40, "y": 60, "entries": [{"id": "e1", "text": "One"}]}, + {"id": "b", "name": "Bravo", "x": 400, "y": 60, "entries": [{"id": "e1", "text": "Two"}]}, + {"id": "c", "name": "Charlie", "x": 40, "y": 500, "entries": [{"id": "e1", "text": "Three"}]}, + ]}) + main._rebuild_cards() + main.set_mode(Main.Mode.BUILD) + await _frames() + var g := main.data.add_group("G", ["a", "b"]) + main.mark_dirty() + await _frames() + var mark := main.card_for("a").group_mark + _check(mark.visible and mark._color == Style.GROUP, "a member shows the theme's group mark") + _check(not main.card_for("c").group_mark.visible, "a card outside the group has no mark") + + Actions.set_group_colour(main, g, "#3c8dd8") + await _frames() + _check(main.card_for("b").group_mark._color == Color("#3c8dd8"), "colouring the group recolours its members' marks") + _eq(TableGroup.from_dict(g.to_dict()).color, "#3c8dd8", "the group colour is saved") + main.undo_redo.undo() + await _frames() + _check(main.card_for("b").group_mark._color == Style.GROUP, "undo puts the theme colour back") + + # Lying inside the frame isn't membership: no mark until it joins. + var c := main.card_for("c") + c.position = main.data.groups[0].position + Vector2(20, 40) + await _frames() + _check(not c.group_mark.visible, "a card that only overlaps the frame stays unmarked") + main.data.add_to_group("c", main.data.groups[0].id) + main.mark_dirty() + await _frames() + _check(main.card_for("c").group_mark.visible, "joining the group marks it") + main.data.remove_from_group("c") + main.mark_dirty() + await _frames() + _check(not main.card_for("c").group_mark.visible, "leaving the group clears the mark") + finish() diff --git a/tests/test_group_marks.gd.uid b/tests/test_group_marks.gd.uid new file mode 100644 index 0000000..308bacf --- /dev/null +++ b/tests/test_group_marks.gd.uid @@ -0,0 +1 @@ +uid://cxb0m52mubkg1 diff --git a/ui/actions.gd b/ui/actions.gd index dc93e86..fcaa632 100644 --- a/ui/actions.gd +++ b/ui/actions.gd @@ -106,6 +106,13 @@ static func set_card_colour(m: Main, t: RollTable, hex: String) -> void: m.undo_redo._end_edit() +static func set_group_colour(m: Main, g: TableGroup, hex: String) -> void: + m.undo_redo._begin_edit() + g.color = hex + m.mark_dirty() + m.undo_redo._end_edit() + + ## `key` is a pipe key, "tid:eid>to". static func thread(m: Main, key: String) -> Array: var tid := key.get_slice(">", 0).get_slice(":", 0) @@ -140,6 +147,7 @@ static func group(m: Main, g: TableGroup) -> Array: var list: Array = [{"text": "Expand" if g.collapsed else "Collapse", "do": m.toggle_group.bind(g.id)}] if m.mode == Main.Mode.BUILD: list.append({"text": "Details…", "do": m.edit_group_details.bind(g.id)}) + list.append(colours(g.color, func(hex: String) -> void: set_group_colour(m, g, hex))) list.append({"text": "Save as template…", "do": m.save_template_from.bind([], "group", [g.id])}) list.append({"sep": ""}) list.append({"text": "Ungroup (keep the cards)", "do": m.ungroup.bind(g.id)}) diff --git a/ui/builtin_themes.gd b/ui/builtin_themes.gd index f8942ba..de84ffa 100644 --- a/ui/builtin_themes.gd +++ b/ui/builtin_themes.gd @@ -24,7 +24,7 @@ const TAROT := { "DASH": "#c6b395", "HOVER_ROW": "#efe2cb", "STRIPE": "#5c0e7510", "TRIM": "#823d08", "TRIM_DARK": "#4a2004", "THREAD": "#c07a2c", "THREAD_DARK": "#5a2a06", - "ACCENT": "#f2b84b", "ACCENT_DARK": "#6b4a0c", "LIT": "#fbe3a6", "FLICK": "#f2b84b59", + "ACCENT": "#f2b84b", "ACCENT_DARK": "#6b4a0c", "GROUP": "#f2b84b", "LIT": "#fbe3a6", "FLICK": "#f2b84b59", "PULSE": "#fff3d6", "GLOW": "#2fe39a", "OK_INK": "#04736e", "REF_INK": "#03635f", "REF_BG": "#d3eeea", "REF_INK_ON_BG": "#7fe8c9", "VALUE_INK": "#7a3f06", "VALUE_INK_ON_BG": "#f2b84b", "VALUE_BG": "#fbf0d8", "VALUE_BORDER": "#e0b56a", diff --git a/ui/group_card.gd b/ui/group_card.gd index f1180a1..bfaf6f9 100644 --- a/ui/group_card.gd +++ b/ui/group_card.gd @@ -125,6 +125,8 @@ func _draw() -> void: draw_style_box(_stack_box, Rect2(off, size)) return var r := Rect2(Vector2.ZERO, size) + # The border in the group's colour, matching its members' corner marks. + Style.bordered(_frame_box, 2, Color(GroupMark.color_of(group), 0.55)) draw_style_box(_frame_drop if _drop or _selected else _frame_box, r) draw_style_box(_band_box, Rect2(0, 0, size.x, TableGroup.TITLE_H)) diff --git a/ui/group_mark.gd b/ui/group_mark.gd new file mode 100644 index 0000000..12fd30e --- /dev/null +++ b/ui/group_mark.gd @@ -0,0 +1,57 @@ +class_name GroupMark +extends Control +## The top-right corner of a card in a group, in the group's colour (its own, +## else Style.GROUP), so members are easy to tell from cards that only lie +## inside the group's frame. On the beaded frame it recolours that corner +## piece; on a plain card it draws a bracket over the corner. +## +## Like CardFrame it draws around the host card's whole rectangle, whatever box +## the container gives it. + +## Plain cards: how far the bracket runs along each edge, and its width. +const ARM := 26.0 +const WIDTH := 4.0 +const RADIUS := 10.0 + +var _color := Color(0, 0, 0, 0) + + +func _init() -> void: + mouse_filter = MOUSE_FILTER_IGNORE + texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS + visible = false + + +## The colour of a group's mark and border. +static func color_of(g: TableGroup) -> Color: + return Color.from_string(g.color, Style.GROUP) if g.color != "" else Style.GROUP + + +## Shows the mark for the card's group, or hides it (null). +func show_for(g: TableGroup) -> void: + var c := color_of(g) if g else Color(0, 0, 0, 0) + if c == _color and visible == (g != null): + return + _color = c + visible = g != null + material = CardFrame.material_for(c) if g and Style.CARD_FRAME == "ornate" else null + queue_redraw() + + +func _draw() -> void: + var host := get_parent() as Control + if host == null: + return + if Style.CARD_FRAME == "ornate": + var r := Rect2(-position, host.size).grow(CardFrame.OUTSET) + draw_set_transform(Vector2(r.end.x, r.position.y), 0.0, Vector2(-1, 1)) + draw_texture_rect(CardFrame.CORNER, Rect2(Vector2.ZERO, Vector2(CardFrame.CORNER_W, CardFrame.CORNER_H) * CardFrame.S), false) + draw_set_transform(Vector2.ZERO) + return + # Plain: an L along the top and right edges, round where the card is. + var r := Rect2(-position, host.size) + var c := Vector2(r.end.x - RADIUS, r.position.y + RADIUS) + var inset := WIDTH / 2.0 + draw_arc(c, RADIUS - inset, -PI / 2.0, 0.0, 12, _color, WIDTH, true) + draw_line(Vector2(r.end.x - ARM, r.position.y + inset), Vector2(c.x, r.position.y + inset), _color, WIDTH, true) + draw_line(Vector2(r.end.x - inset, c.y), Vector2(r.end.x - inset, r.position.y + ARM), _color, WIDTH, true) diff --git a/ui/group_mark.gd.uid b/ui/group_mark.gd.uid new file mode 100644 index 0000000..a7c4f06 --- /dev/null +++ b/ui/group_mark.gd.uid @@ -0,0 +1 @@ +uid://whio32hdl6gm diff --git a/ui/main_layout.gd b/ui/main_layout.gd index 8681029..e1cdbc1 100644 --- a/ui/main_layout.gd +++ b/ui/main_layout.gd @@ -176,6 +176,10 @@ func _board_changed() -> void: m.view_rev += 1 m.edit_rev += 1 m.top_bar._schedule_endless_check() + for c in m.cards.values(): + (c as TableCard).skin.sync_group() + for gn in m.board.groups.get_children(): + (gn as CanvasItem).queue_redraw() if m.mode == Main.Mode.BUILD: m.refresh_live() if m.inspector: diff --git a/ui/style.gd b/ui/style.gd index 4436a83..22c57f7 100644 --- a/ui/style.gd +++ b/ui/style.gd @@ -33,6 +33,8 @@ static var THREAD_DARK := Color("#4f2b12") ## Lit and selected things. static var ACCENT := Color("#f3c450") static var ACCENT_DARK := Color("#6e5410") +## Marks group members (a card's top-right corner) when the group has no colour. +static var GROUP := Color("#f3c450") static var LIT := Color("#f8e4a2") static var FLICK := Color(0.953, 0.769, 0.314, 0.35) static var PULSE := Color("#fff6d2") diff --git a/ui/table_card.gd b/ui/table_card.gd index c8e57f5..bd0b3b5 100644 --- a/ui/table_card.gd +++ b/ui/table_card.gd @@ -55,6 +55,7 @@ var geometry: TableCardGeometry var list_ui: TableCardList ## The ornamental border (null when the theme has none). var frame: CardFrame +var group_mark: GroupMark ## The resize handle (CardGrip), kept as the last child. var grip: CardGrip ## Takes the mouse while zoomed out (CardShield). @@ -96,6 +97,8 @@ func setup(p_main: Main, p_table: RollTable) -> void: if Style.CARD_FRAME == "ornate": frame = CardFrame.new() add_child(frame) + group_mark = GroupMark.new() + add_child(group_mark) grip = CardGrip.new(self) add_child(grip) shield = CardShield.new(main, _on_header_input, open_menu_on, func() -> void: main.rolling.start_roll(table.id)) @@ -115,7 +118,7 @@ func _on_rules_view_changed(_v: Variant = null) -> void: func rebuild() -> void: for c in get_children(): - if c == frame or c == grip or c == shield: + if c == frame or c == group_mark or c == grip or c == shield: continue remove_child(c) c.queue_free() diff --git a/ui/table_card_skin.gd b/ui/table_card_skin.gd index f54251b..ad9d319 100644 --- a/ui/table_card_skin.gd +++ b/ui/table_card_skin.gd @@ -18,6 +18,13 @@ func sync_frame() -> void: else: for sb: StyleBoxFlat in [card._style_normal, card._style_dragging]: Style.bordered(sb, 3 if own.a > 0.0 else 0, own) + sync_group() + + +## The top-right corner mark for the card's group (GroupMark). +func sync_group() -> void: + if card.group_mark: + card.group_mark.show_for(card.main.data.group_of(card.table.id)) func apply_style() -> void: diff --git a/ui/theme_store.gd b/ui/theme_store.gd index b538cf1..6ba57fa 100644 --- a/ui/theme_store.gd +++ b/ui/theme_store.gd @@ -36,6 +36,7 @@ const TOKENS := [ ["TRIM_DARK", "Trim, dark", false], ["THREAD_DARK", "Threads, dark edge", false], ["ACCENT_DARK", "Highlight, dark", false], + ["GROUP", "Group mark (groups without a colour)", false], ["LIT", "Lit result", false], ["FLICK", "Rolling flicker", false], ["PULSE", "Thread pulse", false],