Files
web-cad/frontend/src/interaction/session.ts
T
2026-08-26 21:14:46 +02:00

35 lines
916 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* session.ts Minimaler Werkzeug-Sitzungszustand (Task A2).
*
* phase 'idle' : kein Ziehen aktiv, Tool wartet auf down
* phase 'active' : down ist erfolgt; Tool zieht/zeichnet bis up/cancel
*
* Der Dispatcher nutzt das, um move-Events nur während aktiver Sitzung an
* Handler durchzureichen (und als Guard gegen verlorene up-Events).
*/
export type ToolPhase = 'idle' | 'active';
export class ToolSession {
private current: ToolPhase = 'idle';
/** Ist eine Zeichensitzung aktiv (zwischen down und up)? */
get isActive(): boolean {
return this.current === 'active';
}
/** Aktuelle Phase. */
get phase(): ToolPhase {
return this.current;
}
/** Startet eine Sitzung (nach einem gültigen down). */
begin(): void {
this.current = 'active';
}
/** Beendet die Sitzung regulär (up) oder abgebrochen (cancel/ESC). */
end(): void {
this.current = 'idle';
}
}