feat(ui): add CanvasToolMove

It's essentially 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:35:21 +10:00
parent 371a1b1af3
commit b9c68a2e7e
2 changed files with 34 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import { CanvasModuleBase } from 'features/controlLayers/konva/CanvasModuleBase'
import { CanvasToolBrush } from 'features/controlLayers/konva/CanvasTool/CanvasToolBrush';
import { CanvasToolColorPicker } from 'features/controlLayers/konva/CanvasTool/CanvasToolColorPicker';
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 {
calculateNewBrushSizeFromWheelDelta,
@@ -60,6 +61,7 @@ export class CanvasToolModule extends CanvasModuleBase {
rect: CanvasToolRect;
colorPicker: CanvasToolColorPicker;
bbox: CanvasBboxModule;
move: CanvasToolMove;
};
/**
@@ -114,6 +116,7 @@ export class CanvasToolModule extends CanvasModuleBase {
rect: new CanvasToolRect(this),
colorPicker: new CanvasToolColorPicker(this),
bbox: new CanvasBboxModule(this),
move: new CanvasToolMove(this),
};
this.konva = {

View File

@@ -0,0 +1,31 @@
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 { noop } from 'lodash-es';
import type { Logger } from 'roarr';
export class CanvasToolMove extends CanvasModuleBase {
readonly type = 'move_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');
}
/**
* This is a noop. Entity transformers handle cursor style when the move tool is active.
*/
syncCursorStyle = noop;
}