From b96fc02c0b9d22ff79f4826e95ef94471af6bf46 Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Sat, 14 Nov 2026 13:55:46 -0600 Subject: [PATCH] =?UTF-8?q?Group=20marks:=20a=20clear=20corner=20tab=20in?= =?UTF-8?q?=20every=20theme,=20fixed=20default=20colour,=20Any=20colour?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mark recoloured each theme's corner art, which was thin and often hard to see. Now it's a filled corner tab with a contrasting outline, the same in every theme; collapsed groups show it too. Groups without a colour are blue everywhere (was the theme's highlight gold). Colour menus for cards, threads and groups end with a full colour picker. Co-Authored-By: Claude Opus 5.5 --- core/table_group.gd | 5 ++-- help/topics.txt | 6 +++-- tests/test_group_marks.gd | 15 ++++++++++-- ui/actions.gd | 20 +++++++++------ ui/colour_dialog.gd | 19 +++++++++++++++ ui/colour_dialog.gd.uid | 1 + ui/group_card_compact.gd | 3 +++ ui/group_mark.gd | 51 ++++++++++++++++++++------------------- ui/theme_store.gd | 1 - 9 files changed, 82 insertions(+), 39 deletions(-) create mode 100644 ui/colour_dialog.gd create mode 100644 ui/colour_dialog.gd.uid diff --git a/core/table_group.gd b/core/table_group.gd index 2717dbc..55c9cc9 100644 --- a/core/table_group.gd +++ b/core/table_group.gd @@ -25,8 +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. +## "#rrggbb", or "" for the default (GroupMark.DEFAULT_COLOR, the same in +## every theme). Marks the frame's border and each member card's top-right +## corner, and a collapsed group's own corner. var color: String = "" diff --git a/help/topics.txt b/help/topics.txt index 83d4cf4..c93ab94 100644 --- a/help/topics.txt +++ b/help/topics.txt @@ -176,7 +176,9 @@ Result text can do more than plain words: ## Groups - Drag a box on empty space to select several cards and groups (hold Ctrl or Shift to add to the selection), or Ctrl-click or Shift-click cards. Dragging any selected card or group moves them all. - Press [b]Ctrl+G[/b] to put them in a group: a frame that moves and collapses as one. -- Drag cards into or out of a group. The group's ⋯ menu renames, saves as a template, ungroups or deletes it. +- Drag cards into or out of a group. The group's ⋯ menu renames, colours, saves as a template, ungroups or deletes it. +- Each card in a group has a small tab in its top-right corner in the group's colour, and a collapsed group shows the same tab. Groups without a colour are blue in every theme. +- To put whole groups inside a new group, select every card in them (or the collapsed group) along with the rest, then press Ctrl+G. - [b]Spread ▾ → Pack collapsed groups[/b] moves collapsed groups together to close the gaps. ## Templates @@ -206,7 +208,7 @@ Groups can hold other groups. Select a group (drag a box around it) along with a # Colours and themes - [b]View ▾ → Theme…[/b] picks a theme and lets you change its colours, the background and panel gradients, the background pattern, the card border and the logo. Changes to a built-in theme are saved as a theme of your own. -- Give a card or a thread its own colour from its right-click menu ([b]Colour[/b]) or in the inspector, to sort things at a glance. +- Give a card, a thread or a group its own colour from its right-click menu ([b]Colour[/b]) or in the inspector, to sort things at a glance. [b]Any colour…[/b] at the end of the menu opens a full colour picker. # List view [b]List view[/b] (View ▾, ☰ or right-click the spread) shows every card as a plain list, for when you'd rather not use the spread. diff --git a/tests/test_group_marks.gd b/tests/test_group_marks.gd index c8a500d..bf68b47 100644 --- a/tests/test_group_marks.gd +++ b/tests/test_group_marks.gd @@ -20,7 +20,7 @@ func _init() -> void: 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(mark.visible and mark._color == GroupMark.DEFAULT_COLOR, "a member shows the default group mark (the same in every theme)") _check(not main.card_for("c").group_mark.visible, "a card outside the group has no mark") Actions.set_group_colour(main, g, "#3c8dd8") @@ -29,7 +29,7 @@ func _init() -> void: _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") + _check(main.card_for("b").group_mark._color == GroupMark.DEFAULT_COLOR, "undo puts the default colour back") # Lying inside the frame isn't membership: no mark until it joins. var c := main.card_for("c") @@ -44,4 +44,15 @@ func _init() -> void: main.mark_dirty() await _frames() _check(not main.card_for("c").group_mark.visible, "leaving the group clears the mark") + _check(GroupMark.outline_for(Color.WHITE) != GroupMark.outline_for(Color.BLACK), "the tab's outline stands out from light and dark colours") + main.toggle_group(g.id) + await _frames() + var marks: Array = main.group_node(g.id).find_children("*", "GroupMark", true, false) + _check(marks.size() == 1 and (marks[0] as GroupMark).visible and (marks[0] as GroupMark)._color == GroupMark.color_of(g), "a collapsed group shows its own corner tab") + var menu := Actions.group(main, g) + var colour_menu: Dictionary = {} + for item: Dictionary in menu: + if str(item.get("text", "")) == "Colour": + colour_menu = item + _check((colour_menu.get("sub", []) as Array).any(func(item: Dictionary) -> bool: return str(item["text"]).ends_with("Any colour…")), "the group Colour menu ends with Any colour…") finish() diff --git a/ui/actions.gd b/ui/actions.gd index 4a476af..6a68b00 100644 --- a/ui/actions.gd +++ b/ui/actions.gd @@ -66,11 +66,17 @@ static func popup_at(host: Control, list: Array, at: Vector2) -> PopupMenu: return pm -## A "Colour ▸" submenu: Theme plus the ColorChoice presets. -static func colours(current: String, on_pick: Callable) -> Dictionary: - var sub: Array = [{"text": ("✓ " if current == "" else "") + "Theme colour", "do": on_pick.bind("")}] +## A "Colour ▸" submenu: the default (`default_label`), the ColorChoice +## presets and, with `m`, "Any colour…" (a full colour picker). +static func colours(current: String, on_pick: Callable, m: Main = null, default_label: String = "Theme colour") -> Dictionary: + var sub: Array = [{"text": ("✓ " if current == "" else "") + default_label, "do": on_pick.bind("")}] + var matched := current == "" for p: Array in ColorChoice.PRESETS: - sub.append({"text": ("✓ " if current.to_lower() == str(p[1]) else "") + str(p[0]), "do": on_pick.bind(str(p[1]))}) + var on := current.to_lower() == str(p[1]) + matched = matched or on + sub.append({"text": ("✓ " if on else "") + str(p[0]), "do": on_pick.bind(str(p[1]))}) + if m: + sub.append({"text": ("✓ " if not matched else "") + "Any colour…", "do": func() -> void: ColourDialog.open(m, current, on_pick)}) return {"text": "Colour", "tip": COLOUR_TIP, "sub": sub} @@ -91,7 +97,7 @@ static func card(m: Main, t: RollTable) -> Array: if build: list.append({"sep": ""}) list.append({"text": "Table settings…", "do": m.request_table_settings.bind(t.id)}) - list.append(colours(t.color, func(hex: String) -> void: set_card_colour(m, t, hex))) + list.append(colours(t.color, func(hex: String) -> void: set_card_colour(m, t, hex), m)) list.append({"text": "Save as template…", "do": m.save_template_from.bind([t.id], "card")}) list.append({"sep": ""}) list.append({"text": "Delete table", "do": m.delete_table.bind(t.id)}) @@ -137,7 +143,7 @@ static func thread(m: Main, key: String) -> Array: e.pipe_color[to] = hex m.mark_dirty() m.board.geometry_rev += 1 - m.undo_redo._end_edit())) + m.undo_redo._end_edit(), m)) list.append({"sep": ""}) list.append({"text": "Delete thread", "do": m.remove_pipe.bind(key)}) return list @@ -147,7 +153,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(colours(g.color, func(hex: String) -> void: set_group_colour(m, g, hex), m, "Default (blue)")) 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/colour_dialog.gd b/ui/colour_dialog.gd new file mode 100644 index 0000000..f4082f4 --- /dev/null +++ b/ui/colour_dialog.gd @@ -0,0 +1,19 @@ +class_name ColourDialog +extends RefCounted +## "Any colour…" from a right-click Colour menu: a pop-up with a full colour +## picker (wheel, sliders and hex code). Choose calls `on_pick` with "#rrggbb". + + +static func open(main: Main, start: String, on_pick: Callable) -> ModalCard: + var dialog := ModalCard.new("Choose a colour", 360.0) + var picker := ColorPicker.new() + picker.edit_alpha = false + picker.color = Color.from_string(start, GroupMark.DEFAULT_COLOR) + picker.presets_visible = false + dialog.body.add_child(picker) + dialog.add_button("Cancel", "plain", dialog.close) + dialog.add_button("Choose", "primary", func() -> void: + dialog.close() + on_pick.call("#" + picker.color.to_html(false))) + main.add_child(dialog) + return dialog diff --git a/ui/colour_dialog.gd.uid b/ui/colour_dialog.gd.uid new file mode 100644 index 0000000..2fe04a9 --- /dev/null +++ b/ui/colour_dialog.gd.uid @@ -0,0 +1 @@ +uid://3cajehoxahyr diff --git a/ui/group_card_compact.gd b/ui/group_card_compact.gd index aeb501b..364133c 100644 --- a/ui/group_card_compact.gd +++ b/ui/group_card_compact.gd @@ -24,6 +24,9 @@ static func build(card: GroupCard) -> void: panel.accept_event() ) card.add_child(panel) + var mark := GroupMark.new() + panel.add_child(mark) + mark.show_for(group) var column := TableCard.vbox(0) panel.add_child(column) diff --git a/ui/group_mark.gd b/ui/group_mark.gd index 1453c3b..20c24cb 100644 --- a/ui/group_mark.gd +++ b/ui/group_mark.gd @@ -1,17 +1,20 @@ 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 a framed card it recolours that corner -## piece; on a plain card it draws a bracket over the corner. +## The top-right corner of a card in a group: a filled corner tab in the +## group's colour (its own, else DEFAULT_COLOR), with an outline that stands +## out from it, so members are easy to tell from cards that only lie inside +## the group's frame. The same tab, in the group's own colour, marks a +## collapsed group. It looks the same in every theme, so a theme change +## doesn't change how groups look. ## -## Like CardFrame it draws around the host card's whole rectangle, whatever box -## the container gives it. +## Like CardFrame it draws over the host'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 +## The colour of a group without a colour of its own, in every theme. +const DEFAULT_COLOR := Color("#3a7bd5") +## How far the tab runs along each edge, and its outline's width. +const SIZE := 22.0 +const OUTLINE := 2.0 var _color := Color(0, 0, 0, 0) @@ -24,7 +27,13 @@ func _init() -> void: ## 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 + return Color.from_string(g.color, DEFAULT_COLOR) if g.color != "" else DEFAULT_COLOR + + +## A colour that stands out against `fill`: near-black on light colours, +## white on dark ones. +static func outline_for(fill: Color) -> Color: + return Color(0.08, 0.06, 0.1) if fill.get_luminance() > 0.55 else Color(1, 1, 1, 0.95) ## Shows the mark for the card's group, or hides it (null). @@ -34,7 +43,6 @@ func show_for(g: TableGroup) -> void: return _color = c visible = g != null - material = FrameSet.active.material_for(c) if g and FrameSet.active else null queue_redraw() @@ -42,17 +50,10 @@ func _draw() -> void: var host := get_parent() as Control if host == null: return - var fs := FrameSet.active - if fs: - var r := Rect2(-position, host.size).grow(fs.outset) - draw_set_transform(Vector2(r.end.x, r.position.y), 0.0, Vector2(-1, 1)) - draw_texture_rect(fs.corner, Rect2(Vector2.ZERO, fs.corner_drawn()), 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) + var corner := Vector2(r.end.x, r.position.y) + var tab := PackedVector2Array([corner, corner + Vector2(-SIZE, 0), corner + Vector2(0, SIZE)]) + draw_colored_polygon(tab, _color) + var edge := outline_for(_color) + draw_polyline(PackedVector2Array([corner + Vector2(-SIZE, 0), corner + Vector2(0, SIZE)]), edge, OUTLINE, true) + draw_polyline(PackedVector2Array([corner + Vector2(-SIZE, 0), corner, corner + Vector2(0, SIZE)]), edge, OUTLINE, true) diff --git a/ui/theme_store.gd b/ui/theme_store.gd index 0572cc8..4e2ecdc 100644 --- a/ui/theme_store.gd +++ b/ui/theme_store.gd @@ -37,7 +37,6 @@ 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],