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 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-08 16:59:17 +02:00
1 parent 0b34bdd990
commit 6bedc948be
3 files changed
+19 -4

No files matched your search

+1 -2
View File
@@ -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);
+17 -1
View File
@@ -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<string, TextStyle>();
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;
+1 -1
View File
@@ -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);