Merge branch 'main' into t2i_resolution_hack

This commit is contained in:
Kent Keirsey
2024-10-31 22:08:38 -04:00
committed by GitHub
6 changed files with 48 additions and 7 deletions

View File

@@ -285,6 +285,10 @@ export abstract class CanvasEntityAdapterBase<
this.subscriptions.add(
this.manager.stateApi.createStoreSubscription(selectIsolatedLayerPreview, this.syncVisibility)
);
this.subscriptions.add(
this.manager.stateApi.createStoreSubscription(selectIsolatedStagingPreview, this.syncVisibility)
);
this.subscriptions.add(this.manager.stateApi.createStoreSubscription(selectIsStaging, this.syncVisibility));
this.subscriptions.add(this.manager.stateApi.$filteringAdapter.listen(this.syncVisibility));
this.subscriptions.add(this.manager.stateApi.$transformingAdapter.listen(this.syncVisibility));
this.subscriptions.add(this.manager.stateApi.$segmentingAdapter.listen(this.syncVisibility));

View File

@@ -296,6 +296,14 @@ export class CanvasEntityTransformer extends CanvasModuleBase {
this.syncInteractionState();
};
syncCursorStyle = () => {
if (!this.parent.renderer.hasObjects()) {
this.manager.stage.setCursor('not-allowed');
} else {
this.manager.stage.setCursor('default');
}
};
anchorStyleFunc = (anchor: Konva.Rect): void => {
// Give the rotater special styling
if (anchor.hasName('rotater')) {
@@ -591,6 +599,13 @@ export class CanvasEntityTransformer extends CanvasModuleBase {
syncInteractionState = () => {
this.log.trace('Syncing interaction state');
if (this.manager.stagingArea.$isStaging.get()) {
// While staging, the layer should not be interactable
this.parent.konva.layer.listening(false);
this._setInteractionMode('off');
return;
}
if (this.parent.segmentAnything?.$isSegmenting.get()) {
// When segmenting, the layer should listen but the transformer should not be interactable
this.parent.konva.layer.listening(true);

View File

@@ -59,7 +59,9 @@ export class CanvasProgressImageModule extends CanvasModuleBase {
this.hasActiveGeneration = true;
} else {
this.hasActiveGeneration = false;
this.$lastProgressEvent.set(null);
if (!this.manager.stagingArea.$isStaging.get()) {
this.$lastProgressEvent.set(null);
}
}
})
);

View File

@@ -680,4 +680,20 @@ export class CanvasStateApiModule extends CanvasModuleBase {
* Whether the shift key is currently pressed.
*/
$shiftKey = $shift;
repr = () => {
return {
id: this.id,
type: this.type,
path: this.path,
$filteringAdapter: this.$filteringAdapter.get()?.entityIdentifier,
$isFiltering: this.$isFiltering.get(),
$transformingAdapter: this.$transformingAdapter.get()?.entityIdentifier,
$isTransforming: this.$isTransforming.get(),
$rasterizingAdapter: this.$rasterizingAdapter.get()?.entityIdentifier,
$isRasterizing: this.$isRasterizing.get(),
$segmentingAdapter: this.$segmentingAdapter.get()?.entityIdentifier,
$isSegmenting: this.$isSegmenting.get(),
};
};
}

View File

@@ -2,7 +2,6 @@ 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 CanvasMoveToolModule extends CanvasModuleBase {
@@ -24,8 +23,13 @@ export class CanvasMoveToolModule extends CanvasModuleBase {
this.log.debug('Creating module');
}
/**
* This is a noop. Entity transformers handle cursor style when the move tool is active.
*/
syncCursorStyle = noop;
syncCursorStyle = () => {
const selectedEntity = this.manager.stateApi.getSelectedEntityAdapter();
if (!selectedEntity) {
this.manager.stage.setCursor('not-allowed');
} else {
// The cursor is on an entity, defer to transformer to handle the cursor
selectedEntity.transformer.syncCursorStyle();
}
};
}

View File

@@ -170,7 +170,7 @@ export class CanvasToolModule extends CanvasModuleBase {
} else if (segmentingAdapter) {
segmentingAdapter.segmentAnything.syncCursorStyle();
} else if (transformingAdapter) {
// The transformer handles cursor style via events
transformingAdapter.transformer.syncCursorStyle();
} else if (this.manager.stateApi.$isFiltering.get()) {
stage.setCursor('not-allowed');
} else if (this.manager.stagingArea.$isStaging.get()) {