TableTower/ui/chevron_button.gd
RobinFiredrake ebe81d9f1e Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.

ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00

43 lines
1.3 KiB
GDScript

class_name ChevronButton
extends Button
## Collapse/expand toggle: a chevron pointing down when open, right when collapsed.
var open: bool = true:
set(value):
open = value
queue_redraw()
## Drawn in light colours for the felt (see use_felt_colors).
var on_felt := false
func _init() -> void:
custom_minimum_size = Vector2(26, 26)
flat = false
focus_mode = FOCUS_ALL
var normal := Style.box(Color(0, 0, 0, 0), 6)
var hover := Style.box(Style.CARD_HOVER, 6)
Style.skin_button(self, normal, hover, hover, Style.MUTED)
mouse_entered.connect(queue_redraw)
mouse_exited.connect(queue_redraw)
func _draw() -> void:
var c := size / 2.0
var pts: PackedVector2Array
if open:
pts = PackedVector2Array([c + Vector2(-4, -2), c + Vector2(0, 2), c + Vector2(4, -2)])
else:
pts = PackedVector2Array([c + Vector2(-2, -4), c + Vector2(2, 0), c + Vector2(-2, 4)])
if on_felt:
draw_polyline(pts, Style.ON_BG if is_hovered() else Style.ON_BG_MUTED, 2.0, true)
else:
draw_polyline(pts, Style.INK if is_hovered() else Style.MUTED, 2.0, true)
## Light colours, for a chevron on the felt (group title bars).
func use_felt_colors() -> void:
on_felt = true
var normal := Style.box(Color(0, 0, 0, 0), 6)
var hover := Style.box(Color(1, 1, 1, 0.08), 6)
Style.skin_button(self, normal, hover, hover, Style.ON_BG_MUTED)
queue_redraw()