feat(ui): add CanvasToolView

It's nearly a noop but I think it makes sense to have a module for each tool...
This commit is contained in:
psychedelicious
2024-10-22 17:36:03 +10:00
parent b9c68a2e7e
commit e7a68c446d
2 changed files with 32 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import { CanvasToolColorPicker } from 'features/controlLayers/konva/CanvasTool/C
import { CanvasToolEraser } from 'features/controlLayers/konva/CanvasTool/CanvasToolEraser';
import { CanvasToolMove } from 'features/controlLayers/konva/CanvasTool/CanvasToolMove';
import { CanvasToolRect } from 'features/controlLayers/konva/CanvasTool/CanvasToolRect';
import { CanvasToolView } from 'features/controlLayers/konva/CanvasTool/CanvasToolView';
import {
calculateNewBrushSizeFromWheelDelta,
getIsPrimaryMouseDown,
@@ -61,6 +62,7 @@ export class CanvasToolModule extends CanvasModuleBase {
rect: CanvasToolRect;
colorPicker: CanvasToolColorPicker;
bbox: CanvasBboxModule;
view: CanvasToolView;
move: CanvasToolMove;
};
@@ -116,6 +118,7 @@ export class CanvasToolModule extends CanvasModuleBase {
rect: new CanvasToolRect(this),
colorPicker: new CanvasToolColorPicker(this),
bbox: new CanvasBboxModule(this),
view: new CanvasToolView(this),
move: new CanvasToolMove(this),
};

View File

@@ -0,0 +1,29 @@
import type { CanvasManager } from 'features/controlLayers/konva/CanvasManager';
import { CanvasModuleBase } from 'features/controlLayers/konva/CanvasModuleBase';
import type { CanvasToolModule } from 'features/controlLayers/konva/CanvasTool/CanvasToolModule';
import { getPrefixedId } from 'features/controlLayers/konva/util';
import type { Logger } from 'roarr';
export class CanvasToolView extends CanvasModuleBase {
readonly type = 'view_tool';
readonly id: string;
readonly path: string[];
readonly parent: CanvasToolModule;
readonly manager: CanvasManager;
readonly log: Logger;
constructor(parent: CanvasToolModule) {
super();
this.id = getPrefixedId(this.type);
this.parent = parent;
this.manager = this.parent.manager;
this.path = this.manager.buildPath(this);
this.log = this.manager.buildLogger(this);
this.log.debug('Creating module');
}
syncCursorStyle = () => {
this.manager.stage.setCursor(this.manager.stage.konva.stage.isDragging() ? 'grabbing' : 'grab');
};
}