Cards: thicker coloured header, Build move handle, green selection glow
New theme colours: Card header (themes without it get a shade between the card face and Card shading) and Selected (default Morgan's eye glint). The card the inspector shows glows too, so one selected card is easy to see. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e944fa27d
commit
4a1b365985
9 changed files with 65 additions and 7 deletions
|
|
@ -53,6 +53,10 @@ func _test_sections() -> void:
|
|||
await _frames()
|
||||
_eq(_open_keys(), ["card"], "selecting the card opens only the card section")
|
||||
_check(insp.fields.has("name"), "the card's fields are active")
|
||||
var card := main.card_for("work")
|
||||
var panel := card.get_theme_stylebox("panel") as StyleBoxFlat
|
||||
_check(card._inspected and panel.border_color == Style.SELECTED, "the inspected card glows in the Selected colour")
|
||||
_check(card.find_children("*", "CardMoveHandle", true, false).size() == 1, "Build shows a move handle on the header")
|
||||
|
||||
|
||||
func _test_open_by_hand() -> void:
|
||||
|
|
|
|||
27
ui/card_move_handle.gd
Normal file
27
ui/card_move_handle.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
class_name CardMoveHandle
|
||||
extends Control
|
||||
## The dotted handle at the left of a card's header in Build: shows where to
|
||||
## grab the card to move it. It only draws; the header under it does the
|
||||
## dragging. (The resize corner is CardGrip.)
|
||||
|
||||
const DOT := 1.8
|
||||
const STEP := 6.0
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
custom_minimum_size = Vector2(14, 30)
|
||||
size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
mouse_default_cursor_shape = Control.CURSOR_MOVE
|
||||
tooltip_text = "Drag to move the card"
|
||||
mouse_entered.connect(queue_redraw)
|
||||
mouse_exited.connect(queue_redraw)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var hot := get_global_rect().has_point(get_global_mouse_position())
|
||||
var color := Style.INK if hot else Style.MUTED
|
||||
for col in 2:
|
||||
for row in 4:
|
||||
var at := Vector2(size.x / 2.0 + (col - 0.5) * STEP, size.y / 2.0 + (row - 1.5) * STEP)
|
||||
draw_circle(at, DOT, color)
|
||||
1
ui/card_move_handle.gd.uid
Normal file
1
ui/card_move_handle.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b8et3sky3yjby
|
||||
|
|
@ -111,6 +111,7 @@ func _mark_cards() -> void:
|
|||
var card := c as TableCard
|
||||
if card and card.has_method("set_selected_entry"):
|
||||
card.set_selected_entry(eid if card.table.id == tid else "")
|
||||
card.set_inspected(card.table.id == tid)
|
||||
|
||||
|
||||
func set_collapsed(on: bool) -> void:
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ static var FLICK := Color(0.953, 0.769, 0.314, 0.35)
|
|||
static var PULSE := Color("#fff6d2")
|
||||
## Magic sparkle colour for glows and particles.
|
||||
static var GLOW := Color("#f3c450")
|
||||
## The glowing outline of a selected card in Build (Morgan's eye glint).
|
||||
static var SELECTED := Color("#0fd077")
|
||||
## The band behind a card's title. Themes that don't set it get a shade
|
||||
## between the card face and Card shading (ThemeStore.apply).
|
||||
static var CARD_HEAD := Color("#e6d8bd")
|
||||
static var DANGER := Color("#e0574a")
|
||||
static var DANGER_INK := Color("#a33a2c")
|
||||
static var BAD_INK_ON_BG := Color("#ffb1a3")
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ var _style_dragging: StyleBoxFlat
|
|||
var _style_drop: StyleBoxFlat
|
||||
var _style_selected: StyleBoxFlat
|
||||
var _selected := false
|
||||
## True while the inspector shows this card (Build): it glows like a selected card.
|
||||
var _inspected := false
|
||||
## The result picked in the inspector (copper bar), or "".
|
||||
var _selected_eid := ""
|
||||
|
||||
|
|
@ -227,7 +229,14 @@ func refresh_live() -> void:
|
|||
header_ui.refresh_live()
|
||||
|
||||
|
||||
## Build-mode selection (Main.selection): a copper ring around the card.
|
||||
## The card the inspector shows: glows like a selected card in Build.
|
||||
func set_inspected(on: bool) -> void:
|
||||
if _inspected != on:
|
||||
_inspected = on
|
||||
skin.apply_style()
|
||||
|
||||
|
||||
## Build-mode selection (Main.selection): a glowing ring around the card.
|
||||
func set_selected(on: bool) -> void:
|
||||
if _selected != on:
|
||||
_selected = on
|
||||
|
|
|
|||
|
|
@ -30,10 +30,14 @@ func make(build: bool, ranged: bool) -> Control:
|
|||
var table := card.table
|
||||
var main := card.main
|
||||
var header := PanelContainer.new()
|
||||
var hs := Style.box(Color(0, 0, 0, 0), 0, [12, 10, 10, 9])
|
||||
# A thicker band in its own colour: the place to grab the card.
|
||||
var hs := Style.box(Style.CARD_HEAD, 8, [12, 13, 10, 12])
|
||||
hs.corner_radius_bottom_left = 0
|
||||
hs.corner_radius_bottom_right = 0
|
||||
hs.border_width_bottom = 1
|
||||
hs.border_color = Style.RULE
|
||||
header.add_theme_stylebox_override("panel", hs)
|
||||
header.custom_minimum_size.y = 56
|
||||
header.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
header.mouse_default_cursor_shape = Control.CURSOR_MOVE
|
||||
header.gui_input.connect(card._on_header_input.bind(header))
|
||||
|
|
@ -43,6 +47,8 @@ func make(build: bool, ranged: bool) -> Control:
|
|||
header.add_child(head_box)
|
||||
head_box.add_child(row)
|
||||
|
||||
if build:
|
||||
row.add_child(CardMoveHandle.new())
|
||||
if card.can_collapse():
|
||||
var chevron := ChevronButton.new()
|
||||
chevron.open = not table.collapsed
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func apply_style() -> void:
|
|||
s = card._style_drop
|
||||
elif card._rolling:
|
||||
s = card._style_rolling
|
||||
elif card._selected:
|
||||
elif card._selected or (card._inspected and card.main.mode == Main.Mode.BUILD):
|
||||
s = card._style_selected
|
||||
elif card._dragging:
|
||||
s = card._style_dragging
|
||||
|
|
@ -115,10 +115,10 @@ func build_styles() -> void:
|
|||
card._style_drop.shadow_size = 16
|
||||
card._style_drop.shadow_offset = Vector2(0, 8)
|
||||
card._style_selected = card._style_normal.duplicate() as StyleBoxFlat
|
||||
Style.bordered(card._style_selected, 3, Style.TRIM)
|
||||
card._style_selected.set_expand_margin_all(4)
|
||||
card._style_selected.shadow_color = Color(Style.TRIM, 0.5)
|
||||
card._style_selected.shadow_size = 14
|
||||
Style.bordered(card._style_selected, 4, Style.SELECTED)
|
||||
card._style_selected.set_expand_margin_all(6)
|
||||
card._style_selected.shadow_color = Color(Style.SELECTED, 0.65)
|
||||
card._style_selected.shadow_size = 24
|
||||
card._style_selected.shadow_offset = Vector2.ZERO
|
||||
card._style_dragging = card._style_normal.duplicate() as StyleBoxFlat
|
||||
card._style_dragging.shadow_color = Color(0, 0, 0, 0.4)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ const TOKENS := [
|
|||
["ACCENT", "Highlight (lit and selected)", true],
|
||||
["TRIM", "Trim and headings", true],
|
||||
["GLOW", "Magic sparkles", true],
|
||||
["SELECTED", "Selected card outline", true],
|
||||
["CARD_HEAD", "Card header", true],
|
||||
["BG", "Background (flat)", false],
|
||||
["BG_DEEP", "Background shadow", false],
|
||||
["BG_HOVER", "Background buttons, hover", false],
|
||||
|
|
@ -125,6 +127,9 @@ static func apply(t: Dictionary) -> void:
|
|||
for row: Array in TOKENS:
|
||||
var tok: String = row[0]
|
||||
sc.set(tok, Color.from_string(str(colors[tok]), _fallback[tok]) if colors.has(tok) else _fallback[tok])
|
||||
if not colors.has("CARD_HEAD"):
|
||||
# Darker than the card face, so card text stays readable in every theme.
|
||||
Style.CARD_HEAD = Style.CARD.lerp(Style.CARD_SHADE, 0.85)
|
||||
Style.BG_FILL = t.get("background", {})
|
||||
Style.PANEL_FILL = t.get("panel", {})
|
||||
Style.PATTERN = str(t.get("pattern", "dots"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue