From 6bedc948be7f259dc157b07cb4703e459a52f771 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 Sep 2026 16:59:17 +0200 Subject: [PATCH] Make the viewport label size one setting Scene labels used `small` (11 px), the Texture tab used `body` (13 px). Both now read `Theme.viewportLabelSize` through two tokens that differ only in colour. Dropping the per-frame `label.style.fill` assignment matters: textStyle() returns shared cached instances, so with both views on one token it would have recoloured the scene labels too. Co-Authored-By: Claude Opus 5 --- src/editor/texture/TextureCanvas.ts | 3 +-- src/ui/Theme.ts | 18 +++++++++++++++++- src/viewport/SceneViewport.ts | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/editor/texture/TextureCanvas.ts b/src/editor/texture/TextureCanvas.ts index 28cd9d97..25de8ae0 100644 --- a/src/editor/texture/TextureCanvas.ts +++ b/src/editor/texture/TextureCanvas.ts @@ -436,13 +436,12 @@ export class TextureCanvas extends Widget { return; } if (!label) { - label = new Text({ style: textStyle('body') }); + label = new Text({ style: textStyle('viewportLabel') }); this.labels.set(frame.id, label); this.labelLayer.addChild(label); } label.visible = true; if (label.text !== frame.name) label.text = frame.name; - label.style.fill = Theme.colors.text; const x = at.x + LABEL_INSET; const y = at.y + LABEL_INSET; label.position.set(x + LABEL_PAD, y + LABEL_PAD); diff --git a/src/ui/Theme.ts b/src/ui/Theme.ts index be0e002a..8be08cbc 100644 --- a/src/ui/Theme.ts +++ b/src/ui/Theme.ts @@ -6,6 +6,7 @@ export const Theme = { monoFont: '"JetBrains Mono", Consolas, "Courier New", monospace', fontSize: 13, smallFontSize: 11, + viewportLabelSize: 10, rowHeight: 26, controlHeight: 24, padding: 8, @@ -62,7 +63,16 @@ export const Theme = { const styleCache = new Map(); -export type TextStyleToken = 'body' | 'bodyBold' | 'muted' | 'small' | 'title' | 'mono' | 'accent'; +export type TextStyleToken = + | 'body' + | 'bodyBold' + | 'muted' + | 'small' + | 'title' + | 'mono' + | 'accent' + | 'viewportLabel' + | 'viewportLabelMuted'; /** Shared TextStyle instances so Pixi can cache glyph measurements per token. */ export function textStyle(token: TextStyleToken = 'body'): TextStyle { @@ -97,6 +107,12 @@ export function textStyle(token: TextStyleToken = 'body'): TextStyle { case 'accent': style = new TextStyle({ ...base, fill: Theme.colors.accentText, fontWeight: '600' }); break; + case 'viewportLabel': + style = new TextStyle({ ...base, fontSize: Theme.viewportLabelSize }); + break; + case 'viewportLabelMuted': + style = new TextStyle({ ...base, fontSize: Theme.viewportLabelSize, fill: Theme.colors.textMuted }); + break; } styleCache.set(token, style); return style; diff --git a/src/viewport/SceneViewport.ts b/src/viewport/SceneViewport.ts index 330e3aef..4623de40 100644 --- a/src/viewport/SceneViewport.ts +++ b/src/viewport/SceneViewport.ts @@ -294,7 +294,7 @@ export class SceneViewport extends WorldViewport { return; } if (!label) { - label = new Text({ text: '', style: textStyle('small') }); + label = new Text({ text: '', style: textStyle('viewportLabelMuted') }); label.eventMode = 'none'; this.labels.set(item.id, label); this.overlay.addChild(label);