Consolidate duplicated editor code, trim comments, refresh README
Split GraphCanvas (1076 -> 831 lines) into EdgeLayer and graphMenus; the port and marker menus were the same list and are now one function. Value specs of the inspector and the list tab share valueSpecs.ts, and the remaining copies (compound commands, type glyphs, typed asset lookup, name rule, play/editor world setup, marquee) are merged. Four copies had already drifted apart; merging them fixes: - "Disconnect N links" in the port menu is one undo step, not N - "+ Add collider" is hidden on a placed container instance, as in the hierarchy menu, instead of always failing - a bool property coerced from the text "false" becomes false - a port command on an unknown node type reports instead of crashing Comment-only edits leave the bundle byte-identical. README corrected in 35 places (step limit, jump-run clock, suite duration, 409 body, ...). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9212e61c4c
commit
8f92a06c84
96 files changed
+999
-1261
No files matched your search
@@ -5,11 +5,9 @@
|
||||
*/
|
||||
|
||||
export interface TextEditTarget {
|
||||
/** Called whenever value or selection changed. */
|
||||
onBridgeInput(value: string, selectionStart: number, selectionEnd: number): void;
|
||||
/** Called for navigation keys (Enter, Escape, Tab, arrows …). Return true to consume. */
|
||||
onBridgeKey(event: KeyboardEvent): boolean;
|
||||
/** The bridge lost DOM focus. */
|
||||
onBridgeBlur(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ export abstract class Widget extends Container {
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
// Focus hooks – called by the FocusManager.
|
||||
onFocus(): void {
|
||||
this.focused = true;
|
||||
this.invalidate();
|
||||
|
||||
+2
-7
@@ -17,13 +17,8 @@ interface LastPress {
|
||||
let last: LastPress = { key: null, button: -1, time: 0, x: 0, y: 0, count: 0 };
|
||||
|
||||
/**
|
||||
* How often `key` was pressed in a row with the same button – 2 on a double-click. Pixi counts
|
||||
* clicks only for the `click`/`pointertap` it synthesises and leaves `detail` at 0 on
|
||||
* `pointerdown`, so a press handler reading `e.detail` never sees a second click.
|
||||
*
|
||||
* `key` identifies what was hit and should survive a rebuild of the widget it belongs to: list
|
||||
* rows are thrown away and recreated whenever the list refreshes, which a selection – the first
|
||||
* click – can trigger.
|
||||
* Press count in a row (2 on a double-click), since Pixi leaves `detail` at 0 on `pointerdown`. `key`
|
||||
* must survive a rebuild of its widget: the first click's selection can recreate the list rows.
|
||||
*/
|
||||
export function pressCount(e: FederatedPointerEvent, key: unknown): number {
|
||||
const gap = e.timeStamp - last.time;
|
||||
|
||||
+2
-4
@@ -22,10 +22,8 @@ let session: Session | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
/**
|
||||
* A drag that left the widget it started in, e.g. an asset on its way to the viewport. The
|
||||
* source starts it and forgets it; whoever is under the pointer reads `activeDrag()` and, on
|
||||
* `pointerup`, acts. The session ends itself on release: it listens on the stage, which sees
|
||||
* every pointer event last, so a drop target still has the payload when its own handler runs.
|
||||
* A drag that left its source widget; whoever is under the pointer reads `activeDrag()` on `pointerup`.
|
||||
* The session ends via a stage listener, which fires last, so a drop target still sees the payload.
|
||||
*/
|
||||
export function startDrag(payload: DragPayload, label: string): void {
|
||||
endDrag();
|
||||
|
||||
@@ -50,3 +50,10 @@ export function drawGrid(g: Graphics, options: GridOptions): void {
|
||||
}
|
||||
|
||||
const GRID_COLOR = 0xffffff;
|
||||
|
||||
/** A rubber-band selection between two corners, in whatever space `g` draws. */
|
||||
export function drawBand(g: Graphics, a: { x: number; y: number }, b: { x: number; y: number }): void {
|
||||
g.rect(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.abs(b.x - a.x), Math.abs(b.y - a.y))
|
||||
.fill({ color: Theme.colors.marquee, alpha: 0.12 })
|
||||
.stroke({ width: 1, color: Theme.colors.marquee });
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ export { Widget, Box, type Size } from './Widget';
|
||||
export { HStack, VStack, Spacer, Stack, type StackOptions } from './layout/Stack';
|
||||
export { Theme, textStyle, type TextStyleToken } from './Theme';
|
||||
export { initUI, ui, type UIContext } from './UIContext';
|
||||
export { drawControlBox, drawGrid, type ControlBoxOptions, type GridOptions } from './draw';
|
||||
export { drawBand, drawControlBox, drawGrid, type ControlBoxOptions, type GridOptions } from './draw';
|
||||
export { clamp, centreY, formatBytes, formatNumber, NUMBER_DECIMALS, snapToStep, zoomFactor } from './math';
|
||||
export { activeDrag, type DragPayload, endDrag, onDragChange, startDrag } from './drag';
|
||||
export { Label, truncate } from './widgets/Label';
|
||||
|
||||
Reference in new issue
Block a user