Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

refactor(editor): shared UI primitives + modal focus layer

yhh81fdc978c2cb
diff --git a/desktop/src/components/AddComponentMenu.tsx b/desktop/src/components/AddComponentMenu.tsx
index 8be30551a..926a40a48 100644
--- a/desktop/src/components/AddComponentMenu.tsx
+++ b/desktop/src/components/AddComponentMenu.tsx
@@ -11,6 +11,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { Search } from 'lucide-react';
import { ComponentIcon } from '@/components/icons';
+import { useDialogFocus } from '@/components/dialogFocus';
import { CATEGORY_ORDER } from '@/engine/schema';
export interface AddComponentEntry {
@@ -53,6 +54,8 @@ export function AddComponentMenu({
const [active, setActive] = useState(0);
const inputRef = useRef<HTMLInputElement>(null);
const activeRef = useRef<HTMLButtonElement>(null);
+ const shellRef = useRef<HTMLDivElement>(null);
+ useDialogFocus(shellRef);
// Focus the search on open (type-to-filter immediately).
useEffect(() => {
@@ -119,7 +122,7 @@ export function AddComponentMenu({
return createPortal(
<div className="ac-scrim open" onMouseDown={onClose}>
- <div className="ac" role="dialog" onMouseDown={(e) => e.stopPropagation()}>
+ <div ref={shellRef} className="ac" role="dialog" aria-modal="true" aria-label="Add component" tabIndex={-1} onMouseDown={(e) => e.stopPropagation()}>
<div className="ac-search">
<Search size={15} strokeWidth={1.9} />
<input
diff --git a/desktop/src/components/CreatePopover.tsx b/desktop/src/components/CreatePopover.tsx
index b97c031d2..24c5b9829 100644
--- a/desktop/src/components/CreatePopover.tsx
+++ b/desktop/src/components/CreatePopover.tsx
@@ -13,6 +13,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { Search, Box, Image, Video, Lightbulb, Sparkles, LayoutDashboard, ToggleLeft, SlidersHorizontal } from 'lucide-react';
import { flattenCatalog, matchCatalog, type CatalogEntry, type EntityTemplate } from '@/engine/entityTemplates';
+import { useDialogFocus } from '@/components/dialogFocus';
const ICONS: Record<string, typeof Box> = {
Empty: Box,
@@ -50,6 +51,8 @@ export function CreatePopover({
const [active, setActive] = useState(0);
const inputRef = useRef<HTMLInputElement>(null);
const activeRef = useRef<HTMLButtonElement>(null);
+ const shellRef = useRef<HTMLDivElement>(null);
+ useDialogFocus(shellRef);
const all = useMemo(() => flattenCatalog(), []);
const results = useMemo(() => matchCatalog(all, query), [all, query]);
@@ -86,7 +89,7 @@ export function CreatePopover({
return createPortal(
<div className="ac-scrim open" onMouseDown={onClose}>
- <div className="ac" role="dialog" onMouseDown={(e) => e.stopPropagation()}>
+ <div ref={shellRef} className="ac" role="dialog" aria-modal="true" aria-label="Create entity" tabIndex={-1} onMouseDown={(e) => e.stopPropagation()}>
<div className="ac-search">
<Search size={15} strokeWidth={1.9} />
<input
diff --git a/desktop/src/components/DirtyDot.tsx b/desktop/src/components/DirtyDot.tsx
new file mode 100644
index 000000000..b25a86b2e
--- /dev/null
+++ b/desktop/src/components/DirtyDot.tsx
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file DirtyDot.tsx
+ * @brief The shared unsaved-changes marker — one dot, one color (the viewport
+ * selection orange), everywhere a document can be dirty: the menubar
+ * scene title, asset-editor toolbars, and dock tabs.
+ */
+export function DirtyDot({ title = 'Unsaved changes' }: { title?: string }) {
+ return (
+ <span className="dirty-dot" title={title}>
+ ●
+ </span>
+ );
+}
diff --git a/desktop/src/components/Modal.tsx b/desktop/src/components/Modal.tsx
index b8738d286..f108bda64 100644
--- a/desktop/src/components/Modal.tsx
+++ b/desktop/src/components/Modal.tsx
@@ -5,9 +5,10 @@
* general dialog primitive: dismiss on backdrop press / Escape, with a
* titled header, scrollable body, and an optional footer (action row).
*/
-import { useEffect, type ReactNode } from 'react';
+import { useEffect, useRef, type ReactNode } from 'react';
import { createPortal } from 'react-dom';
import { X } from 'lucide-react';
+import { useDialogFocus } from './dialogFocus';
export function Modal({
title,
@@ -22,6 +23,9 @@ export function Modal({
footer?: ReactNode;
width?: number;
}) {
+ const winRef = useRef<HTMLDivElement>(null);
+ useDialogFocus(winRef);
+
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
@@ -33,10 +37,13 @@ export function Modal({
return createPortal(
<div className="modal-backdrop" onMouseDown={onClose}>
<div
+ ref={winRef}
className="modal"
style={{ width }}
role="dialog"
+ aria-modal="true"
aria-label={title}
+ tabIndex={-1}
onMouseDown={(e) => e.stopPropagation()}
>
<div className="modal__head">
diff --git a/desktop/src/components/Segmented.tsx b/desktop/src/components/Segmented.tsx
new file mode 100644
index 000000000..82461c5e0
--- /dev/null
+++ b/desktop/src/components/Segmented.tsx
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file Segmented.tsx
+ * @brief The shared segmented control — an inset well of mutually-exclusive
+ * buttons with an accent-filled active segment. One implementation
+ * behind every view/mode switch (Content Browser grid/list, Settings
+ * enums, Launcher layout, Tileset modes). Styled by theme/controls.css.
+ */
+import type { ReactNode } from 'react';
+
+export interface SegmentedOption<T extends string> {
+ value: T;
+ label?: string;
+ icon?: ReactNode;
+ /** Tooltip; doubles as the accessible name for icon-only segments. */
+ title?: string;
+}
+
+export function Segmented<T extends string>({
+ value,
+ options,
+ onChange,
+ ariaLabel,
+}: {
+ value: T;
+ options: SegmentedOption<T>[];
+ onChange: (v: T) => void;
+ ariaLabel?: string;
+}) {
+ return (
+ <div className="seg" role="radiogroup" aria-label={ariaLabel}>
+ {options.map((o) => (
+ <button
+ key={o.value}
+ type="button"
+ role="radio"
+ aria-checked={value === o.value}
+ className={`${value === o.value ? 'on' : ''}${o.icon && !o.label ? ' ic' : ''}`}
+ title={o.title}
+ aria-label={!o.label ? o.title : undefined}
+ onClick={() => onChange(o.value)}
+ >
+ {o.icon}
+ {o.label}
+ </button>
+ ))}
+ </div>
+ );
+}
diff --git a/desktop/src/components/Select.tsx b/desktop/src/components/Select.tsx
new file mode 100644
index 000000000..f2bce0e8a
--- /dev/null
+++ b/desktop/src/components/Select.tsx
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file Select.tsx
+ * @brief The shared themed dropdown — replaces native <select> everywhere so
+ * lists match the editor (same popover, hover, check mark) and stay
+ * keyboard-operable: Enter/Space opens focused on the current option,
+ * arrows move, Enter picks, Escape returns focus to the trigger.
+ *
+ * Two trigger looks: 'input' (standalone, input-well styling — the
+ * default) and 'field' (fills an inspector `.field.dropdown` wrapper,
+ * like Details' EnumControl). List styling reuses the `.dd-*` popover
+ * vocabulary.
+ */
+import { useEffect, useRef, type CSSProperties } from 'react';
+import { ChevronDown, Check } from 'lucide-react';
+import { Popover, usePopover } from './Popover';
+
+export interface SelectOption<T extends string> {
+ value: T;
+ label?: string;
+}
+
+export function Select<T extends string>({
+ value,
+ options,
+ onChange,
+ ariaLabel,
+ variant = 'input',
+ className,
+ style,
+}: {
+ value: T;
+ options: SelectOption<T>[];
+ onChange: (v: T) => void;
+ ariaLabel?: string;
+ variant?: 'input' | 'field';
+ /** Extra trigger classes (e.g. a panel's sizing class). */
+ className?: string;
+ style?: CSSProperties;
+}) {
+ const pop = usePopover();
+ const trigger = useRef<HTMLButtonElement>(null);
+ const listRef = useRef<HTMLDivElement>(null);
+ const cur = options.find((o) => o.value === value);
+
+ const close = () => {
+ pop.close();
+ trigger.current?.focus();
+ };
+ const toggle = () => {
+ if (pop.isOpen) close();
+ else pop.open(trigger.current);
+ };
+
+ // Seed focus on the current option so arrow keys work immediately.
+ useEffect(() => {
+ if (!pop.isOpen) return;
+ const raf = requestAnimationFrame(() => {
+ const list = listRef.current;
+ const target =
+ list?.querySelector<HTMLButtonElement>('.dd-opt.on') ??
+ list?.querySelector<HTMLButtonElement>('.dd-opt');
+ target?.focus();
+ });
+ return () => cancelAnimationFrame(raf);
+ }, [pop.isOpen]);
+
+ const onListKey = (e: React.KeyboardEvent) => {
+ if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
+ e.preventDefault();
+ const items = [...(listRef.current?.querySelectorAll<HTMLButtonElement>('.dd-opt') ?? [])];
+ if (!items.length) return;
+ const i = items.indexOf(document.activeElement as HTMLButtonElement);
+ const next = e.key === 'ArrowDown' ? Math.min(items.length - 1, i + 1) : Math.max(0, i - 1);
+ items[next]?.focus();
+ };
+
+ const triggerClass =
+ variant === 'field' ? 'dd-trigger' : `sel-trigger${className ? ` ${className}` : ''}`;
+
+ return (
+ <>
+ <button
+ ref={trigger}
+ type="button"
+ className={triggerClass}
+ style={style}
+ aria-label={ariaLabel}
+ aria-haspopup="listbox"
+ aria-expanded={pop.isOpen}
+ onMouseDown={(e) => e.stopPropagation()}
+ onClick={toggle}
+ >
+ <span className="dd-val">{cur ? cur.label ?? cur.value : String(value)}</span>
+ <ChevronDown size={12} strokeWidth={2} />
+ </button>
+ {pop.anchor && (
+ <Popover anchor={pop.anchor} width={Math.max(pop.anchor.width, 120)} onClose={close}>
+ <div className="dd-list" role="listbox" ref={listRef} onKeyDown={onListKey}>
+ {options.map((o) => (
+ <button
+ key={o.value}
+ type="button"
+ role="option"
+ aria-selected={o.value === value}
+ className={`dd-opt${o.value === value ? ' on' : ''}`}
+ onClick={() => {
+ onChange(o.value);
+ close();
+ }}
+ >
+ <span className="dd-opt-label">{o.label ?? o.value}</span>
+ {o.value === value && <Check size={12} strokeWidth={2.4} />}
+ </button>
+ ))}
+ </div>
+ </Popover>
+ )}
+ </>
+ );
+}
diff --git a/desktop/src/components/SettingsDialog.tsx b/desktop/src/components/SettingsDialog.tsx
index 5bd0abe88..25c73a3bf 100644
--- a/desktop/src/components/SettingsDialog.tsx
+++ b/desktop/src/components/SettingsDialog.tsx
@@ -16,6 +16,9 @@ import { useEditorStore } from '@/store/editorStore';
import { useSettings } from '@/store/settingsStore';
import { settingsRegistry } from '@/settings/registry';
import { eventToChord, formatKeybinding } from '@/commands/keybinding';
+import { useDialogFocus } from '@/components/dialogFocus';
+import { Segmented } from '@/components/Segmented';
+import { Select } from '@/components/Select';
import type { Setting, NumberSetting, KeybindingSetting, StringListSetting, MatrixSetting, FlagListSetting } from '@/settings/types';
// A bound list setting's getter returns a fresh array each call; useShallow below
@@ -225,31 +228,32 @@ function Control({ setting }: { setting: Setting }) {
aria-checked={Boolean(value)}
tabIndex={0}
onClick={() => setValue(setting.id, !value)}
+ onKeyDown={(e) => {
+ if (e.key === ' ' || e.key === 'Enter') {
+ e.preventDefault();
+ setValue(setting.id, !value);
+ }
+ }}
/>
);
case 'enum':
if (setting.segmented) {
return (
- <div className="set-seg">
- {setting.options.map((o) => (
- <button
- key={o.value}
- type="button"
- className={value === o.value ? 'on' : ''}
- onClick={() => setValue(setting.id, o.value)}
- >
- {o.label}
- </button>
- ))}
- </div>
+ <Segmented
+ value={String(value)}
+ onChange={(v) => setValue(setting.id, v)}
+ ariaLabel={setting.label}
+ options={setting.options.map((o) => ({ value: o.value, label: o.label }))}
+ />
);
}
return (
- <select className="set-sel" value={String(value)} onChange={(e) => setValue(setting.id, e.target.value)}>
- {setting.options.map((o) => (
- <option key={o.value} value={o.value}>{o.label}</option>
- ))}
- </select>
+ <Select
+ ariaLabel={setting.label}
+ value={String(value)}
+ options={setting.options.map((o) => ({ value: o.value, label: o.label }))}
+ onChange={(v) => setValue(setting.id, v)}
+ />
);
case 'number':
return <NumberControl setting={setting} />;
@@ -325,6 +329,8 @@ function Group({ label, settings }: { label: string; settings: Setting[] }) {
export function SettingsDialog() {
const close = () => useEditorStore.getState().setSettingsOpen(false);
+ const winRef = useRef<HTMLDivElement>(null);
+ useDialogFocus(winRef);
const [open, setOpen] = useState(false);
const [query, setQuery] = useState('');
const sections = settingsRegistry.allSections();
@@ -362,7 +368,15 @@ export function SettingsDialog() {
return createPortal(
<div className={`set-scrim${open ? ' open' : ''}`} onMouseDown={close}>
- <div className="set-win" role="dialog" aria-label="Settings" onMouseDown={(e) => e.stopPropagation()}>
+ <div
+ ref={winRef}
+ className="set-win"
+ role="dialog"
+ aria-modal="true"
+ aria-label="Settings"
+ tabIndex={-1}
+ onMouseDown={(e) => e.stopPropagation()}
+ >
<div className="set-head">
<span className="set-title">
<span className="ic"><SettingsIcon size={16} strokeWidth={1.8} /></span>
diff --git a/desktop/src/components/Tooltip.tsx b/desktop/src/components/Tooltip.tsx
index 1d1f93006..cf0789871 100644
--- a/desktop/src/components/Tooltip.tsx
+++ b/desktop/src/components/Tooltip.tsx
@@ -75,7 +75,7 @@ function Tooltip({
}, [anchor, onDismiss]);
return createPortal(
- <div ref={ref} className="tooltip" style={{ left: pos.left, top: pos.top }}>
+ <div ref={ref} className="tooltip" role="tooltip" style={{ left: pos.left, top: pos.top }}>
{children}
</div>,
document.body,
@@ -111,6 +111,13 @@ export function useTooltip<T>(render: (payload: T) => ReactNode, delay = OPEN_DE
timer.current = window.setTimeout(() => setTarget({ anchor, payload }), delay);
},
onMouseLeave: close,
+ // Keyboard focus is deliberate — show the card without the hover delay.
+ onFocus: (ev: React.FocusEvent) => {
+ const anchor = ev.currentTarget as HTMLElement;
+ if (timer.current != null) clearTimeout(timer.current);
+ setTarget({ anchor, payload });
+ },
+ onBlur: close,
}),
[close, delay],
);
diff --git a/desktop/src/components/dialogFocus.ts b/desktop/src/components/dialogFocus.ts
new file mode 100644
index 000000000..067a8b8f1
--- /dev/null
+++ b/desktop/src/components/dialogFocus.ts
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file dialogFocus.ts
+ * @brief Shared modality behavior for every dialog/palette shell — one hook
+ * that remembers the opener, seeds focus inside the container, traps
+ * Tab within it, and restores focus on close. Pair it with
+ * role="dialog" aria-modal="true" on the container.
+ */
+import { useEffect, type RefObject } from 'react';
+
+const FOCUSABLE =
+ 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
+
+/** Visible-and-focusable elements inside the container, in DOM order. */
+function focusables(container: HTMLElement): HTMLElement[] {
+ return [...container.querySelectorAll<HTMLElement>(FOCUSABLE)].filter(
+ (el) => el.getClientRects().length > 0,
+ );
+}
+
+/**
+ * Modal focus management for the container behind `ref` (give it tabIndex={-1}
+ * so it can take the seed focus). Runs for the container's whole mount — mount
+ * a dialog only while it is open.
+ */
+export function useDialogFocus(ref: RefObject<HTMLElement | null>): void {
+ useEffect(() => {
+ const container = ref.current;
+ if (!container) return;
+ const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
+
+ // Seed focus inside — unless the shell already autofocused its own field
+ // (command palettes / settings focus their search input on mount).
+ if (!container.contains(document.activeElement)) container.focus();
+
+ // Trap Tab: cycle within the container; recapture if focus escaped.
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key !== 'Tab') return;
+ const items = focusables(container);
+ if (items.length === 0) {
+ e.preventDefault();
+ container.focus();
+ return;
+ }
+ const first = items[0];
+ const last = items[items.length - 1];
+ const active = document.activeElement;
+ const inside = active instanceof HTMLElement && container.contains(active);
+ if (e.shiftKey && (!inside || active === first)) {
+ e.preventDefault();
+ last.focus();
+ } else if (!e.shiftKey && (!inside || active === last)) {
+ e.preventDefault();
+ first.focus();
+ }
+ };
+ window.addEventListener('keydown', onKey, true);
+ return () => {
+ window.removeEventListener('keydown', onKey, true);
+ // Hand focus back to whoever opened the dialog (if still in the DOM).
+ if (opener?.isConnected) opener.focus();
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+}
diff --git a/desktop/src/launcher/Launcher.tsx b/desktop/src/launcher/Launcher.tsx
index 3c8862d64..da6f804ea 100644
--- a/desktop/src/launcher/Launcher.tsx
+++ b/desktop/src/launcher/Launcher.tsx
@@ -5,6 +5,7 @@ import { ArrowRight, Clock, FolderOpen, LayoutGrid, Plus, Rows3, Search, X } fro
import { useEditorStore } from '@/store/editorStore';
import { ProjectStore } from '@/project/ProjectStore';
import { WindowControls } from '@/layout/WindowControls';
+import { Segmented } from '@/components/Segmented';
import type { RecentEntry, TemplateEntry } from '@/project/format';
import { version } from '../../package.json';
@@ -103,24 +104,15 @@ function RecentView({
spellCheck={false}
/>
</label>
- <div className="lc-seg" role="group" aria-label="View">
- <button
- type="button"
- className={`lc-seg__btn${layout === 'grid' ? ' is-active' : ''}`}
- onClick={() => setLayout('grid')}
- title="Grid"
- >
- <LayoutGrid size={14} strokeWidth={1.9} />
- </button>
- <button
- type="button"
- className={`lc-seg__btn${layout === 'list' ? ' is-active' : ''}`}
- onClick={() => setLayout('list')}
- title="List"
- >
- <Rows3 size={14} strokeWidth={1.9} />
- </button>
- </div>
+ <Segmented
+ value={layout}
+ onChange={setLayout}
+ ariaLabel="View"
+ options={[
+ { value: 'grid', icon: <LayoutGrid size={14} strokeWidth={1.9} />, title: 'Grid' },
+ { value: 'list', icon: <Rows3 size={14} strokeWidth={1.9} />, title: 'List' },
+ ]}
+ />
</div>
</header>
diff --git a/desktop/src/layout/DockLayout.tsx b/desktop/src/layout/DockLayout.tsx
index 061ced5d6..1a19c3e40 100644
--- a/desktop/src/layout/DockLayout.tsx
+++ b/desktop/src/layout/DockLayout.tsx
@@ -1,13 +1,16 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
-import { useEffect, useState, type FC, type ReactNode } from 'react';
+import { useEffect, useState, useSyncExternalStore, type FC, type ReactNode } from 'react';
import {
DockviewReact,
type DockviewReadyEvent,
type IDockviewPanelProps,
+ type IDockviewPanelHeaderProps,
type IDockviewHeaderActionsProps,
} from 'dockview';
-import { ChevronDown } from 'lucide-react';
+import { ChevronDown, X } from 'lucide-react';
+import { DirtyDot } from '@/components/DirtyDot';
+import { panelDirtySource } from '@/layout/panelDirty';
import { Outliner } from '@/panels/Outliner';
import { Viewport } from '@/panels/Viewport';
import { Details } from '@/panels/Details';
@@ -121,6 +124,37 @@ function ensureBottomTabs(api: DockviewReadyEvent['api']) {
}
}
+// Custom tab content: title + the shared dirty dot (asset editors) + a close
+// button that only shows on hover / on the active tab, so the strip stays calm.
+function EstellaTab(props: IDockviewPanelHeaderProps) {
+ const source = panelDirtySource(props.api.id);
+ const dirty = useSyncExternalStore(source.subscribe, source.isDirty);
+ const [title, setTitle] = useState(props.api.title ?? props.api.id);
+ useEffect(() => {
+ const d = props.api.onDidTitleChange((e) => setTitle(e.title));
+ return () => d.dispose();
+ }, [props.api]);
+ return (
+ <div className="dv-estella-tab">
+ <span className="tab-title">{title}</span>
+ {dirty && <DirtyDot />}
+ <button
+ type="button"
+ className="tab-x"
+ title="Close"
+ aria-label={`Close ${title}`}
+ onPointerDown={(e) => e.stopPropagation()}
+ onClick={(e) => {
+ e.stopPropagation();
+ props.api.close();
+ }}
+ >
+ <X size={12} strokeWidth={2} />
+ </button>
+ </div>
+ );
+}
+
// A collapse/expand chevron in every dock group's header (the design's `.pcol`).
// Collapses the group to its tab bar by height; hidden on the Viewport/Game group
// (the center stage isn't an accordion). State follows the live group height, so
@@ -179,6 +213,7 @@ export function DockLayout() {
<DockviewReact
className="dockview-theme-abyss dockview-theme-estella"
components={components}
+ defaultTabComponent={EstellaTab}
rightHeaderActionsComponent={CollapseHeaderAction}
onReady={onReady}
/>
diff --git a/desktop/src/layout/MenuBar.tsx b/desktop/src/layout/MenuBar.tsx
index 9b21d467f..e120c32c6 100644
--- a/desktop/src/layout/MenuBar.tsx
+++ b/desktop/src/layout/MenuBar.tsx
@@ -7,6 +7,7 @@
// region; the menus, dropdowns, and window controls opt out of dragging.
import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
import { WindowControls } from '@/layout/WindowControls';
+import { DirtyDot } from '@/components/DirtyDot';
import { LAYOUT_KEY } from '@/layout/DockLayout';
import { useEditorStore } from '@/store/editorStore';
import { ProjectStore } from '@/project/ProjectStore';
@@ -226,7 +227,7 @@ export function MenuBar() {
<span className="mono">untitled</span>
</>
)}
- {dirty && <span className="dirty" title="Unsaved changes">●</span>}
+ {dirty && <DirtyDot />}
</div>
) : null}
<WindowControls />
diff --git a/desktop/src/layout/panelDirty.ts b/desktop/src/layout/panelDirty.ts
new file mode 100644
index 000000000..54d9f0e30
--- /dev/null
+++ b/desktop/src/layout/panelDirty.ts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file panelDirty.ts
+ * @brief Maps dock-panel ids to their document's unsaved state, so the dock
+ * tab can show the shared dirty dot. Every asset editor's document is
+ * an AssetDocument singleton (uniform subscribe + dirty).
+ */
+import { FsmGraphDocument } from '@/fsm/FsmGraphDocument';
+import { BtDocument } from '@/bt/BtDocument';
+import { MaterialGraphDocument } from '@/material/MaterialGraphDocument';
+import { TilesetDocument } from '@/tileset/TilesetDocument';
+import { TimelineDocument } from '@/timeline/TimelineDocument';
+
+export interface DirtySource {
+ subscribe(cb: () => void): () => void;
+ isDirty(): boolean;
+}
+
+const SOURCES: Record<string, DirtySource> = {
+ statemachine: { subscribe: FsmGraphDocument.subscribe, isDirty: () => FsmGraphDocument.dirty },
+ behaviortree: { subscribe: BtDocument.subscribe, isDirty: () => BtDocument.dirty },
+ materialgraph: { subscribe: MaterialGraphDocument.subscribe, isDirty: () => MaterialGraphDocument.dirty },
+ tileset: { subscribe: TilesetDocument.subscribe, isDirty: () => TilesetDocument.dirty },
+ sequencer: { subscribe: TimelineDocument.subscribe, isDirty: () => TimelineDocument.dirty },
+};
+
+const NONE: DirtySource = { subscribe: () => () => {}, isDirty: () => false };
+
+/** The dirty source for a dock panel (a no-op source for panels without one). */
+export function panelDirtySource(panelId: string): DirtySource {
+ return SOURCES[panelId] ?? NONE;
+}
diff --git a/desktop/src/main.tsx b/desktop/src/main.tsx
index 2773ebccf..a1b0a24f7 100644
--- a/desktop/src/main.tsx
+++ b/desktop/src/main.tsx
@@ -12,6 +12,7 @@ import '@fontsource/jetbrains-mono/500.css';
import './theme/tokens.css';
import './theme/global.css';
+import './theme/controls.css';
// dockview base styles first, then our override layer on top of them.
import 'dockview/dist/styles/dockview.css';
import './theme/dockview-theme.css';
diff --git a/desktop/src/panels/BtTreeEditor.tsx b/desktop/src/panels/BtTreeEditor.tsx
index 9647bea7f..b6b9d0648 100644
--- a/desktop/src/panels/BtTreeEditor.tsx
+++ b/desktop/src/panels/BtTreeEditor.tsx
@@ -20,6 +20,8 @@ import {
import { BtDocument } from '@/bt/BtDocument';
import { EditorHistory } from '@/engine/EditorHistory';
import { NodeGraphCanvas, type CanvasNode, type MenuItem } from '@/panels/NodeGraphCanvas';
+import { Select } from '@/components/Select';
+import { DirtyDot } from '@/components/DirtyDot';
type BtCanvasNode = BtNode & CanvasNode;
@@ -82,7 +84,7 @@ export function BtTreeEditor() {
const toolbar = (
<>
- <span className="ng-doc-title">{filePath.split('/').pop()}{dirty && <span className="ng-dirty" title="Unsaved">●</span>}</span>
+ <span className="ng-doc-title">{filePath.split('/').pop()}{dirty && <DirtyDot />}</span>
<span style={{ flex: 1 }} />
{selected && def.root.id !== selected && (
<button type="button" className="ng-btn" title="Delete node"
@@ -156,9 +158,12 @@ export function BtTreeEditor() {
<div className="ng-inspector">
<div className="ng-insp-title">Node</div>
<label className="ng-field">Type
- <select className="ng-input" value={selNode.type} onChange={e => patch(selNode.id, { type: e.target.value as BtNodeType })}>
- {BT_TYPES.map(s => <option key={s.type} value={s.type}>{s.label}</option>)}
- </select>
+ <Select
+ ariaLabel="Node type"
+ value={selNode.type}
+ options={BT_TYPES.map(s => ({ value: s.type, label: s.label }))}
+ onChange={v => patch(selNode.id, { type: v })}
+ />
</label>
{(selNode.type === 'action' || selNode.type === 'condition') && (
@@ -182,10 +187,15 @@ export function BtTreeEditor() {
)}
{selNode.type === 'parallel' && (
<label className="ng-field">Success policy
- <select className="ng-input" value={selNode.policy ?? 'all'} onChange={e => patch(selNode.id, { policy: e.target.value as 'all' | 'one' })}>
- <option value="all">all children</option>
- <option value="one">any child</option>
- </select>
+ <Select
+ ariaLabel="Success policy"
+ value={selNode.policy ?? 'all'}
+ options={[
+ { value: 'all', label: 'all children' },
+ { value: 'one', label: 'any child' },
+ ]}
+ onChange={v => patch(selNode.id, { policy: v })}
+ />
</label>
)}
@@ -193,9 +203,13 @@ export function BtTreeEditor() {
<>
<div className="ng-insp-sub">Add child</div>
<div className="ng-row">
- <select className="ng-input" style={{ flex: 1 }} value={addType} onChange={e => setAddType(e.target.value as BtNodeType)}>
- {BT_TYPES.map(s => <option key={s.type} value={s.type}>{s.label}</option>)}
- </select>
+ <Select
+ ariaLabel="Child node type"
+ style={{ flex: 1 }}
+ value={addType}
+ options={BT_TYPES.map(s => ({ value: s.type, label: s.label }))}
+ onChange={setAddType}
+ />
<button type="button" className="ng-btn" onClick={() => addChild(selNode.id, addType)}>+ Add</button>
</div>
</>
diff --git a/desktop/src/panels/ContentBrowser.tsx b/desktop/src/panels/ContentBrowser.tsx
index 927a61aac..cad8f79b5 100644
--- a/desktop/src/panels/ContentBrowser.tsx
+++ b/desktop/src/panels/ContentBrowser.tsx
@@ -5,6 +5,7 @@ import { ChevronRight, Search, LayoutGrid, List, Import, FolderOpen, FolderPlus,
import { AssetIcon, assetTint } from '@/components/icons';
import { ContextMenu, type MenuItem } from '@/components/Menu';
import { useTooltip } from '@/components/Tooltip';
+import { Segmented } from '@/components/Segmented';
import { ProjectStore } from '@/project/ProjectStore';
import { Toasts } from '@/store/Toasts';
import { useSelection } from '@/store/selectionStore';
@@ -697,14 +698,15 @@ export function ContentBrowser() {
>
<ArrowDownUp size={14} strokeWidth={2} />
</button>
- <div className="cb-seg">
- <button type="button" className={view === 'grid' ? 'on' : ''} title="Grid view" onClick={() => setView('grid')}>
- <LayoutGrid size={13} strokeWidth={1.9} />
- </button>
- <button type="button" className={view === 'list' ? 'on' : ''} title="List view" onClick={() => setView('list')}>
- <List size={13} strokeWidth={1.9} />
- </button>
- </div>
+ <Segmented
+ value={view}
+ onChange={setView}
+ ariaLabel="View"
+ options={[
+ { value: 'grid', icon: <LayoutGrid size={13} strokeWidth={1.9} />, title: 'Grid view' },
+ { value: 'list', icon: <List size={13} strokeWidth={1.9} />, title: 'List view' },
+ ]}
+ />
<button type="button" className="cb-ghost" title="New Folder" onClick={() => void newFolder()}>
<FolderPlus size={13} strokeWidth={1.9} />
</button>
diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsx
index f024bedfc..637c2ae29 100644
--- a/desktop/src/panels/Details.tsx
+++ b/desktop/src/panels/Details.tsx
@@ -62,6 +62,7 @@ import {
} from '@/material/materialInspectorModel';
import { ContextMenu } from '@/components/Menu';
import { Popover, usePopover } from '@/components/Popover';
+import { Select } from '@/components/Select';
import { AddComponentMenu } from '@/components/AddComponentMenu';
import type { InspectorComponent, InspectorField, InspectorFieldValue, EntityId, NodeKind, EnumOption, AssetType, GradientValue, GradientStop, CurveValue, CurveKey, DimensionValue } from '@/types';
@@ -471,16 +472,24 @@ export function BoolControl({
onEnd,
onChange,
}: ControlGesture & { value: boolean; mixed?: boolean; onChange: (v: boolean) => void }) {
+ const commit = () => {
+ onBegin?.();
+ // From a mixed state, the first toggle commits everyone to enabled.
+ onChange(mixed ? true : !value);
+ onEnd?.();
+ };
return (
<span
className={`toggle${value ? ' on' : ''}${mixed ? ' mixed' : ''}`}
role="switch"
aria-checked={mixed ? 'mixed' : value}
- onClick={() => {
- onBegin?.();
- // From a mixed state, the first click commits everyone to enabled.
- onChange(mixed ? true : !value);
- onEnd?.();
+ tabIndex={0}
+ onClick={commit}
+ onKeyDown={(e) => {
+ if (e.key === ' ' || e.key === 'Enter') {
+ e.preventDefault();
+ commit();
+ }
}}
/>
);
@@ -1078,24 +1087,21 @@ function FieldRow({ entities, comp, field, write }: { entities: EntityId[]; comp
if (dynOpts) {
const cur = String(field.value);
control = (
- <span className="field">
- <select
- className="dyn-enum"
+ <span className="field dropdown">
+ <Select
+ variant="field"
value={cur}
- onMouseDown={(e) => e.stopPropagation()}
- onChange={(e) => {
+ ariaLabel={field.key}
+ options={[
+ ...(dynOpts.includes(cur) ? [] : [{ value: cur, label: cur || '(none)' }]),
+ ...dynOpts.map((o) => ({ value: o })),
+ ]}
+ onChange={(v) => {
begin();
- apply(e.target.value);
+ apply(v);
end();
}}
- >
- {!dynOpts.includes(cur) && <option value={cur}>{cur || '(none)'}</option>}
- {dynOpts.map((o) => (
- <option key={o} value={o}>
- {o}
- </option>
- ))}
- </select>
+ />
</span>
);
} else
@@ -1607,18 +1613,28 @@ function BindingRow({ binding, onChange, onRemove }: { binding: Binding; onChang
case 'gpAxis': fields = num('axis'); break;
case 'stick':
fields = (
- <select className="im-in" value={String(b.stick)} onChange={(e) => set({ stick: e.target.value })}>
- <option value="left">Left</option>
- <option value="right">Right</option>
- </select>
+ <Select
+ className="im-in"
+ ariaLabel="Stick"
+ value={b.stick === 'right' ? 'right' : 'left'}
+ options={[
+ { value: 'left', label: 'Left' },
+ { value: 'right', label: 'Right' },
+ ]}
+ onChange={(v) => set({ stick: v })}
+ />
);
break;
}
return (
<div className="im-binding">
- <select className="im-in kind" value={binding.kind} onChange={(e) => onChange(defaultBinding(e.target.value as Binding['kind']))}>
- {BINDING_KINDS.map((k) => <option key={k.kind} value={k.kind}>{k.label}</option>)}
- </select>
+ <Select
+ className="im-in kind"
+ ariaLabel="Binding kind"
+ value={binding.kind}
+ options={BINDING_KINDS.map((k) => ({ value: k.kind, label: k.label }))}
+ onChange={(v) => onChange(defaultBinding(v))}
+ />
{fields}
<button type="button" className="im-x" onClick={onRemove} title="Remove binding">×</button>
</div>
@@ -1678,11 +1694,17 @@ function InputMapAssetInspector({ path }: { path: string }) {
if (e.target.value.trim() && e.target.value !== name) commit(imap.renameAction(map, name, e.target.value));
}}
/>
- <select className="im-in" value={def.type} onChange={(e) => commit(imap.setActionType(map, name, e.target.value as ActionType))}>
- <option value="button">Button</option>
- <option value="axis">Axis</option>
- <option value="axis2d">Axis 2D</option>
- </select>
+ <Select
+ className="im-in"
+ ariaLabel="Action type"
+ value={def.type}
+ options={[
+ { value: 'button', label: 'Button' },
+ { value: 'axis', label: 'Axis' },
+ { value: 'axis2d', label: 'Axis 2D' },
+ ]}
+ onChange={(v) => commit(imap.setActionType(map, name, v as ActionType))}
+ />
<button type="button" className="im-x" onClick={() => commit(imap.removeAction(map, name))} title="Remove action">×</button>
</div>
{def.bindings.map((bnd, i) => (
diff --git a/desktop/src/panels/MaterialGraphEditor.tsx b/desktop/src/panels/MaterialGraphEditor.tsx
index f064769af..af81ca8e2 100644
--- a/desktop/src/panels/MaterialGraphEditor.tsx
+++ b/desktop/src/panels/MaterialGraphEditor.tsx
@@ -25,6 +25,7 @@ import { MaterialGraphDocument } from '@/material/MaterialGraphDocument';
import { saveMaterialGraph } from '@/material/openMaterialGraph';
import { EditorHistory } from '@/engine/EditorHistory';
import { NumField, ColorControl } from '@/panels/Details';
+import { DirtyDot } from '@/components/DirtyDot';
const NODE_W = 168;
const HEADER_H = 28;
@@ -174,7 +175,7 @@ export function MaterialGraphEditor() {
<Trash2 size={13} strokeWidth={1.9} />
</button>
)}
- <span className="mg-title">{filePath.split('/').pop()}{dirty && <span className="mg-dot" title="Unsaved">●</span>}</span>
+ <span className="mg-title">{filePath.split('/').pop()}{dirty && <DirtyDot />}</span>
<span style={{ flex: 1 }} />
<button type="button" className="primary" disabled={!dirty} onClick={() => void saveMaterialGraph(filePath, graph)}>
<Save size={13} strokeWidth={1.9} /> Save
diff --git a/desktop/src/panels/Sequencer.tsx b/desktop/src/panels/Sequencer.tsx
index 75e0f26c2..02eddf201 100644
--- a/desktop/src/panels/Sequencer.tsx
+++ b/desktop/src/panels/Sequencer.tsx
@@ -26,6 +26,7 @@ import { useSequencerStore } from '@/store/sequencerStore';
import { useSelection } from '@/store/selectionStore';
import { SceneModel } from '@/engine/SceneModel';
import { ContextMenu, type MenuItem } from '@/components/Menu';
+import { DirtyDot } from '@/components/DirtyDot';
import { SequencerCurve } from '@/panels/SequencerCurve';
import {
buildTimelineRows, visibleRows, frameCount, timeToPct, pctToTime, findChannel, muteKey,
@@ -354,7 +355,7 @@ function SequencerBody() {
title="Save animation"
onClick={() => void TimelineCommands.save()}
>
- <Save size={14} /><span>{TimelineDocument.meta.dirty ? 'Save*' : 'Save'}</span>
+ <Save size={14} /><span>Save{TimelineDocument.meta.dirty && <DirtyDot />}</span>
</button>
</div>
diff --git a/desktop/src/panels/StateMachineEditor.tsx b/desktop/src/panels/StateMachineEditor.tsx
index 5d23cd223..e92c790ab 100644
--- a/desktop/src/panels/StateMachineEditor.tsx
+++ b/desktop/src/panels/StateMachineEditor.tsx
@@ -23,6 +23,8 @@ import {
import { FsmGraphDocument } from '@/fsm/FsmGraphDocument';
import { EditorHistory } from '@/engine/EditorHistory';
import { NodeGraphCanvas, type CanvasNode } from '@/panels/NodeGraphCanvas';
+import { Select } from '@/components/Select';
+import { DirtyDot } from '@/components/DirtyDot';
type FsmCanvasNode = FsmState & CanvasNode;
@@ -82,7 +84,7 @@ export function StateMachineEditor() {
<>
<button type="button" className="ng-btn" onClick={addStateAt} title="Add state"><Plus size={13} strokeWidth={2} /> State</button>
{(selState || selEdge) && <button type="button" className="ng-btn" title="Delete selected" onClick={deleteSelected}><Trash2 size={13} strokeWidth={1.9} /></button>}
- <span className="ng-doc-title">{filePath.split('/').pop()}{dirty && <span className="ng-dirty" title="Unsaved">●</span>}</span>
+ <span className="ng-doc-title">{filePath.split('/').pop()}{dirty && <DirtyDot />}</span>
<span style={{ flex: 1 }} />
<button type="button" className="ng-btn primary" disabled={!dirty} onClick={save}><Save size={13} strokeWidth={1.9} /> Save</button>
</>
@@ -192,9 +194,12 @@ function TransitionInspector({ def, edgeId }: { def: FsmDefinition; edgeId: stri
<div>
<div className="ng-insp-title">Transition</div>
<label className="ng-field">Target
- <select className="ng-input" value={t.to} onChange={(e) => patch({ to: e.target.value })}>
- {def.states.map((s) => <option key={s.name} value={s.name}>{s.name}</option>)}
- </select>
+ <Select
+ ariaLabel="Target state"
+ value={t.to}
+ options={def.states.map((s) => ({ value: s.name }))}
+ onChange={(v) => patch({ to: v })}
+ />
</label>
<label className="ng-field">Trigger (event)
<input className="ng-input" defaultValue={t.trigger ?? ''} key={`trg-${edgeId}`} placeholder="event name"
@@ -209,9 +214,13 @@ function TransitionInspector({ def, edgeId }: { def: FsmDefinition; edgeId: stri
<div className="ng-row">
<input className="ng-input" style={{ flex: 1 }} defaultValue={g?.key ?? ''} key={`gk-${edgeId}`} placeholder="key"
onBlur={(e) => patchGuard({ key: e.target.value.trim() })} />
- <select className="ng-input" style={{ width: 62 }} value={g?.op ?? '=='} onChange={(e) => patchGuard({ op: e.target.value as CompareOp })}>
- {OPS.map((op) => <option key={op} value={op}>{op}</option>)}
- </select>
+ <Select
+ ariaLabel="Guard operator"
+ style={{ width: 62 }}
+ value={g?.op ?? '=='}
+ options={OPS.map((op) => ({ value: op }))}
+ onChange={(op) => patchGuard({ op })}
+ />
</div>
{g && g.op !== 'truthy' && g.op !== 'falsy' && (
<label className="ng-field">Value
diff --git a/desktop/src/panels/TilesetEditor.tsx b/desktop/src/panels/TilesetEditor.tsx
index 12c91b93d..d9b1f2138 100644
--- a/desktop/src/panels/TilesetEditor.tsx
+++ b/desktop/src/panels/TilesetEditor.tsx
@@ -20,8 +20,11 @@ import {
import { Save, Plus, Trash2 } from 'lucide-react';
import {
TB_N, TB_E, TB_S, TB_W, TB_NE, TB_SE, TB_SW, TB_NW,
- type TilesetAsset, type TerrainMode,
+ type TilesetAsset,
} from 'esengine';
+import { Segmented } from '@/components/Segmented';
+import { Select } from '@/components/Select';
+import { DirtyDot } from '@/components/DirtyDot';
import { TilesetDocument } from '@/tileset/TilesetDocument';
import { TilesetCommands } from '@/tileset/TilesetCommands';
import { ProjectStore } from '@/project/ProjectStore';
@@ -289,15 +292,25 @@ export function TilesetEditor() {
<GridField label="Margin" value={mg} onCommit={(n) => editGrid({ margin: n })} />
<GridField label="Spacing" value={sp} onCommit={(n) => editGrid({ spacing: n })} />
<span className="ts-sep" />
- <div className="ts-modes">
- <button type="button" className={mode === 'collision' ? 'is-active' : ''} onClick={() => setMode('collision')}>Collision</button>
- <button type="button" className={mode === 'terrain' ? 'is-active' : ''} onClick={() => setMode('terrain')}>Terrain</button>
- </div>
+ <Segmented
+ value={mode}
+ onChange={setMode}
+ ariaLabel="Edit mode"
+ options={[
+ { value: 'collision', label: 'Collision' },
+ { value: 'terrain', label: 'Terrain' },
+ ]}
+ />
{mode === 'collision' && (
- <div className="ts-modes">
- <button type="button" className={shape === 'box' ? 'is-active' : ''} onClick={() => setShape('box')}>Box</button>
- <button type="button" className={shape === 'polygon' ? 'is-active' : ''} onClick={() => setShape('polygon')}>Polygon</button>
- </div>
+ <Segmented
+ value={shape}
+ onChange={setShape}
+ ariaLabel="Collision shape"
+ options={[
+ { value: 'box', label: 'Box' },
+ { value: 'polygon', label: 'Polygon' },
+ ]}
+ />
)}
<span className="ts-sep" />
<label className="ts-field">
@@ -310,7 +323,7 @@ export function TilesetEditor() {
{cols}×{rows}{mode === 'collision' ? ` · ${solidCount} solid` : ''}
</span>
<button type="button" className="ts-save" onClick={() => void TilesetCommands.save()} disabled={!meta.dirty}>
- <Save size={13} /> Save{meta.dirty ? ' •' : ''}
+ <Save size={13} /> Save{meta.dirty && <DirtyDot />}
</button>
</div>
@@ -338,13 +351,15 @@ export function TilesetEditor() {
className="ts-tname" value={terrain.name}
onChange={(e) => TilesetCommands.updateTerrain(activeSet, { name: e.target.value })}
/>
- <select
+ <Select
+ ariaLabel="Terrain mode"
value={terrain.mode}
- onChange={(e) => TilesetCommands.updateTerrain(activeSet, { mode: e.target.value as TerrainMode })}
- >
- <option value="edge">Edge (4-bit)</option>
- <option value="corner">Corner (blob)</option>
- </select>
+ options={[
+ { value: 'edge', label: 'Edge (4-bit)' },
+ { value: 'corner', label: 'Corner (blob)' },
+ ]}
+ onChange={(v) => TilesetCommands.updateTerrain(activeSet, { mode: v })}
+ />
<button type="button" className="ts-trm" title="Delete terrain"
onClick={() => { TilesetCommands.removeTerrain(activeSet); setActiveSet(0); }}>
<Trash2 size={13} />
diff --git a/desktop/src/theme/chrome.css b/desktop/src/theme/chrome.css
index f21d10ed9..152be3354 100644
--- a/desktop/src/theme/chrome.css
+++ b/desktop/src/theme/chrome.css
@@ -41,7 +41,6 @@
.menubar-title { font-size: var(--fs-xs); color: var(--text-mute); display: flex; align-items: center; gap: 6px; padding-right: 12px; }
.menubar-title strong { color: var(--text-dim); font-weight: 600; }
.menubar-title .sep { opacity: 0.5; }
-.menubar-title .dirty { color: var(--sel); font-size: 0.7em; line-height: 1; margin-left: -2px; }
/* The 72px traffic-light gutter is macOS-only; Windows/Linux draw their own
controls, so reclaim the left edge and let the controls reach the right corner. */
diff --git a/desktop/src/theme/content.css b/desktop/src/theme/content.css
index 2ed7a04d7..8a51f4d2d 100644
--- a/desktop/src/theme/content.css
+++ b/desktop/src/theme/content.css
@@ -43,10 +43,6 @@
.crumbs .cr.cur { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--text-mute); }
.cb-search { width: 200px; height: 26px; flex-shrink: 0; }
-.cb-seg { display: flex; gap: 1px; background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px; flex-shrink: 0; }
-.cb-seg button { width: 26px; height: 22px; display: grid; place-items: center; color: var(--text-mute); border-radius: var(--r-xs); }
-.cb-seg button.on { color: var(--on-accent); background: var(--acc); }
-.cb-seg button:hover:not(.on) { color: var(--text); }
.cb-add { height: 26px; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; background: var(--acc); color: var(--on-accent); font-weight: 600; font-size: var(--fs-xs); border-radius: var(--r-sm); transition: background var(--t-fast); flex-shrink: 0; }
.cb-add:hover { background: var(--acc-hi); }
.cb-add:disabled { opacity: 0.45; }
diff --git a/desktop/src/theme/controls.css b/desktop/src/theme/controls.css
new file mode 100644
index 000000000..f107facf2
--- /dev/null
+++ b/desktop/src/theme/controls.css
@@ -0,0 +1,57 @@
+/* =============================================================================
+ @file controls.css
+ @brief Shared control primitives — small, reusable widgets used across panels
+ (Segmented, DirtyDot). Panel-specific chrome stays in the panel's own
+ stylesheet; anything two panels share belongs here.
+ ========================================================================== */
+
+/* — Segmented control (components/Segmented.tsx) — */
+.seg {
+ display: inline-flex;
+ gap: 1px;
+ padding: 1px;
+ background: var(--inset);
+ border: 1px solid var(--border);
+ border-radius: var(--r-sm);
+ flex-shrink: 0;
+}
+.seg button {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 5px;
+ height: 22px;
+ padding: 0 9px;
+ color: var(--text-dim);
+ font-size: var(--fs-xs);
+ border-radius: var(--r-xs);
+ transition: color var(--t-fast), background var(--t-fast);
+}
+.seg button.ic { width: 26px; padding: 0; }
+.seg button:hover:not(.on) { color: var(--text); }
+.seg button.on { background: var(--acc); color: var(--on-accent); }
+
+/* — Select trigger, standalone input look (components/Select.tsx). The 'field'
+ variant reuses the inspector's .dd-trigger; the popover list is the shared
+ .dd-* vocabulary (inspector.css). — */
+.sel-trigger {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ min-height: 22px;
+ padding: 2px 4px 2px 7px;
+ background: var(--input);
+ border: 1px solid var(--line);
+ border-radius: var(--r-sm);
+ color: var(--text);
+ font-size: var(--fs-sm);
+ cursor: pointer;
+ min-width: 0;
+ transition: border-color var(--t-fast);
+}
+.sel-trigger:hover { border-color: var(--line-strong); }
+.sel-trigger > svg { color: var(--text-mute); flex-shrink: 0; }
+.sel-trigger .dd-val { flex: 1; }
+
+/* — Unsaved-changes dot (components/DirtyDot.tsx) — */
+.dirty-dot { color: var(--sel); font-size: 0.7em; line-height: 1; }
diff --git a/desktop/src/theme/dockview-theme.css b/desktop/src/theme/dockview-theme.css
index 79102baf5..115e5f9f3 100644
--- a/desktop/src/theme/dockview-theme.css
+++ b/desktop/src/theme/dockview-theme.css
@@ -99,6 +99,40 @@
z-index: 1;
}
+/* Custom tab body (defaultTabComponent): title + dirty dot + hover-reveal close.
+ The outer .dv-tab keeps the strip geometry; this styles only the content. */
+.dockview-theme-estella .dv-estella-tab {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ height: 100%;
+ min-width: 0;
+}
+.dockview-theme-estella .dv-estella-tab .tab-title {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.dockview-theme-estella .dv-estella-tab .tab-x {
+ width: 16px;
+ height: 16px;
+ display: grid;
+ place-items: center;
+ margin-right: -6px;
+ border-radius: var(--r-xs);
+ color: var(--text-faint);
+ opacity: 0;
+ transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
+}
+.dockview-theme-estella .dv-tab:hover .tab-x,
+.dockview-theme-estella .dv-tab.dv-active-tab .tab-x {
+ opacity: 1;
+}
+.dockview-theme-estella .dv-estella-tab .tab-x:hover {
+ color: var(--text);
+ background: var(--srf-4);
+}
+
/* Region legibility: a faint top edge-light gives each docked panel content a crisp
upper hairline, so the four regions parse as distinct stacked surfaces at a glance —
the design's "light hairlines for dividers" language applied per-panel, without
diff --git a/desktop/src/theme/launcher.css b/desktop/src/theme/launcher.css
index 2445d0dc6..5a7af2459 100644
--- a/desktop/src/theme/launcher.css
+++ b/desktop/src/theme/launcher.css
@@ -210,30 +210,6 @@
color: var(--text-faint);
}
-.lc-seg {
- display: flex;
- gap: 2px;
- padding: 2px;
- background: var(--input);
- border: 1px solid var(--line);
- border-radius: var(--r-md);
-}
-.lc-seg__btn {
- display: grid;
- place-items: center;
- width: 28px;
- height: 24px;
- border-radius: var(--r-xs);
- color: var(--text-dim);
-}
-.lc-seg__btn:hover {
- color: var(--text-hi);
-}
-.lc-seg__btn.is-active {
- background: var(--raised);
- color: var(--star-hi);
-}
-
/* ----------------------------------------------------------- grid cards --- */
.proj-grid {
display: grid;
diff --git a/desktop/src/theme/material.css b/desktop/src/theme/material.css
index 4b60eb493..bff0eda58 100644
--- a/desktop/src/theme/material.css
+++ b/desktop/src/theme/material.css
@@ -31,7 +31,6 @@
.mg-bar .mg-add, .mg-bar .mg-del { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; background: var(--srf-3); border: 1px solid var(--border-line); border-radius: var(--r-sm); color: var(--text); cursor: pointer; }
.mg-bar .mg-add:hover, .mg-bar .mg-del:hover { background: var(--srf-4); }
.mg-title { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text); }
-.mg-dot { color: var(--acc-hi); font-size: 10px; }
.mg-palette { position: absolute; top: 32px; left: 10px; z-index: 10; display: flex; flex-direction: column; min-width: 130px; padding: 4px; background: var(--srf-2); border: 1px solid var(--border-line); border-radius: var(--r-sm); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.mg-palette button { text-align: left; padding: 5px 8px; background: none; border: none; border-radius: var(--r-sm); color: var(--text); cursor: pointer; font-size: var(--fs-xs); }
.mg-palette button:hover { background: var(--srf-4); }
diff --git a/desktop/src/theme/nodegraph.css b/desktop/src/theme/nodegraph.css
index fb21436e3..c92dfdad7 100644
--- a/desktop/src/theme/nodegraph.css
+++ b/desktop/src/theme/nodegraph.css
@@ -148,9 +148,6 @@
color: var(--text-dim);
margin-left: 4px;
}
-/* Unsaved marker — same voice as the menubar's scene dirty dot. */
-.ng-dirty { color: var(--sel); font-size: 0.7em; line-height: 1; }
-
/* — side inspector — */
.ng-inspector {
width: 232px;
diff --git a/desktop/src/theme/settings.css b/desktop/src/theme/settings.css
index 046a94939..4b65c9014 100644
--- a/desktop/src/theme/settings.css
+++ b/desktop/src/theme/settings.css
@@ -172,17 +172,6 @@
.set-row:hover .set-reset.show, .set-row.changed .set-reset.show { opacity: 0.85; }
.set-reset.show { cursor: pointer; }
-.set-sel {
- height: 27px;
- min-width: 130px;
- background: var(--inset);
- border: 1px solid var(--border);
- border-radius: var(--r-sm);
- color: var(--text);
- padding: 0 8px;
- outline: none;
- font-size: var(--fs-sm);
-}
.set-num {
width: 92px;
height: 27px;
@@ -196,7 +185,7 @@
font-size: var(--fs-xs);
text-align: right;
}
-.set-sel:focus, .set-num:focus { border-color: var(--acc); box-shadow: 0 0 0 2px var(--acc-soft); }
+.set-num:focus { border-color: var(--acc); box-shadow: 0 0 0 2px var(--acc-soft); }
.set-slider { flex: 1; max-width: 130px; }
.set-key {
@@ -226,9 +215,6 @@
transition: box-shadow var(--t-fast);
}
.set-swatch.on { box-shadow: 0 0 0 2px var(--srf-2), 0 0 0 4px var(--acc); }
-.set-seg { display: flex; background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
-.set-seg button { padding: 4px 11px; font-size: var(--fs-xs); color: var(--text-dim); transition: color var(--t-fast), background var(--t-fast); }
-.set-seg button.on { background: var(--acc); color: var(--on-accent); }
/* Pill toggle (the design's `.toggle`; not yet in the shared theme). */
.toggle {
diff --git a/desktop/src/theme/tileset.css b/desktop/src/theme/tileset.css
index 44140f8e5..fb7560eac 100644
--- a/desktop/src/theme/tileset.css
+++ b/desktop/src/theme/tileset.css
@@ -93,18 +93,6 @@
}
.ts-cell.is-solid:hover { background: rgba(240, 100, 90, 0.5); }
-/* Mode switch (collision / terrain) */
-.ts-modes { display: inline-flex; border: 1px solid var(--line, #2a2d33); border-radius: 3px; overflow: hidden; }
-.ts-modes button {
- background: var(--control, #24272d);
- color: var(--text-dim, #9aa0aa);
- border: none;
- padding: 3px 10px;
- cursor: pointer;
- font: inherit;
-}
-.ts-modes button.is-active { background: var(--star, #4c8fd6); color: var(--on-accent, #fff); }
-
/* Terrain set bar */
.ts-terrains {
display: flex;