Skip to content

Commit 40f7b0d

Browse files
psychedelicioushipsterusername
authored andcommitted
fix(ui): cursor disappearing on empty layers
1 parent 4904700 commit 40f7b0d

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

invokeai/frontend/web/src/features/controlLayers/konva/CanvasEntity/CanvasEntityTransformer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ export class CanvasEntityTransformer extends CanvasModuleBase {
296296
this.syncInteractionState();
297297
};
298298

299+
syncCursorStyle = () => {
300+
if (!this.parent.renderer.hasObjects()) {
301+
this.manager.stage.setCursor('not-allowed');
302+
} else {
303+
this.manager.stage.setCursor('default');
304+
}
305+
};
306+
299307
anchorStyleFunc = (anchor: Konva.Rect): void => {
300308
// Give the rotater special styling
301309
if (anchor.hasName('rotater')) {

invokeai/frontend/web/src/features/controlLayers/konva/CanvasTool/CanvasMoveToolModule.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { CanvasManager } from 'features/controlLayers/konva/CanvasManager';
22
import { CanvasModuleBase } from 'features/controlLayers/konva/CanvasModuleBase';
33
import type { CanvasToolModule } from 'features/controlLayers/konva/CanvasTool/CanvasToolModule';
44
import { getPrefixedId } from 'features/controlLayers/konva/util';
5-
import { noop } from 'lodash-es';
65
import type { Logger } from 'roarr';
76

87
export class CanvasMoveToolModule extends CanvasModuleBase {
@@ -24,8 +23,13 @@ export class CanvasMoveToolModule extends CanvasModuleBase {
2423
this.log.debug('Creating module');
2524
}
2625

27-
/**
28-
* This is a noop. Entity transformers handle cursor style when the move tool is active.
29-
*/
30-
syncCursorStyle = noop;
26+
syncCursorStyle = () => {
27+
const selectedEntity = this.manager.stateApi.getSelectedEntityAdapter();
28+
if (!selectedEntity) {
29+
this.manager.stage.setCursor('not-allowed');
30+
} else {
31+
// The cursor is on an entity, defer to transformer to handle the cursor
32+
selectedEntity.transformer.syncCursorStyle();
33+
}
34+
};
3135
}

invokeai/frontend/web/src/features/controlLayers/konva/CanvasTool/CanvasToolModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class CanvasToolModule extends CanvasModuleBase {
170170
} else if (segmentingAdapter) {
171171
segmentingAdapter.segmentAnything.syncCursorStyle();
172172
} else if (transformingAdapter) {
173-
// The transformer handles cursor style via events
173+
transformingAdapter.transformer.syncCursorStyle();
174174
} else if (this.manager.stateApi.$isFiltering.get()) {
175175
stage.setCursor('not-allowed');
176176
} else if (this.manager.stagingArea.$isStaging.get()) {

0 commit comments

Comments
 (0)