From d5e1daae826491d922f6f39269f679808ab6be97 Mon Sep 17 00:00:00 2001 From: Leopoldadmin Date: Mon, 22 Jun 2026 21:03:33 +0000 Subject: [PATCH] Add ChairTool for creating individual chairs --- frontend/src/tools/drawing/ChairTool.ts | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 frontend/src/tools/drawing/ChairTool.ts diff --git a/frontend/src/tools/drawing/ChairTool.ts b/frontend/src/tools/drawing/ChairTool.ts new file mode 100644 index 0000000..6d5d513 --- /dev/null +++ b/frontend/src/tools/drawing/ChairTool.ts @@ -0,0 +1,58 @@ +import { Tool } from '../Tool'; +import { YjsDocument } from '../../crdt/YjsDocument'; + +class ChairTool extends Tool { + private width: number = 45; // Default chair width + private height: number = 45; // Default chair height + + constructor(yjsDoc: YjsDocument) { + super(yjsDoc); + this.name = 'ChairTool'; + } + + onMouseDown(event: MouseEvent): void { + // Create chair element at click position + const x = event.clientX - this.width / 2; + const y = event.clientY - this.height / 2; + + this.yjsDoc.createElement({ + id: Date.now().toString(), + type: 'chair', + layerId: 'default', + x, + y, + width: this.width, + height: this.height, + properties: { + // Chair-specific properties can be added here + } + }); + } + + onMouseMove(event: MouseEvent): void { + // Preview chair at cursor position + } + + onMouseUp(event: MouseEvent): void { + // Handle mouse up if needed + } + + onKeyUp(event: KeyboardEvent): void { + // Handle key up events + if (event.key === 'Escape') { + this.reset(); + } + } + + reset(): void { + // Reset any state if needed + } + + // Set chair dimensions + setDimensions(width: number, height: number): void { + this.width = width; + this.height = height; + } +} + +export { ChairTool }; \ No newline at end of file