mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): clean up a few bits and bobs
This commit is contained in:
parent
747eef9ccc
commit
fee293e289
@ -14,7 +14,7 @@ import {
|
|||||||
getPrefixedId,
|
getPrefixedId,
|
||||||
previewBlob,
|
previewBlob,
|
||||||
} from 'features/controlLayers/konva/util';
|
} from 'features/controlLayers/konva/util';
|
||||||
import type { CanvasV2State, GenerationMode, Rect } from 'features/controlLayers/store/types';
|
import type { GenerationMode, Rect } from 'features/controlLayers/store/types';
|
||||||
import type Konva from 'konva';
|
import type Konva from 'konva';
|
||||||
import { atom } from 'nanostores';
|
import { atom } from 'nanostores';
|
||||||
import type { Logger } from 'roarr';
|
import type { Logger } from 'roarr';
|
||||||
@ -38,7 +38,9 @@ export class CanvasManager {
|
|||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
path: string[];
|
path: string[];
|
||||||
container: HTMLDivElement;
|
|
||||||
|
store: AppStore;
|
||||||
|
socket: AppSocket;
|
||||||
|
|
||||||
rasterLayerAdapters: Map<string, CanvasLayerAdapter> = new Map();
|
rasterLayerAdapters: Map<string, CanvasLayerAdapter> = new Map();
|
||||||
controlLayerAdapters: Map<string, CanvasLayerAdapter> = new Map();
|
controlLayerAdapters: Map<string, CanvasLayerAdapter> = new Map();
|
||||||
@ -54,33 +56,14 @@ export class CanvasManager {
|
|||||||
cache: CanvasCacheModule;
|
cache: CanvasCacheModule;
|
||||||
renderer: CanvasRenderingModule;
|
renderer: CanvasRenderingModule;
|
||||||
|
|
||||||
log: Logger;
|
|
||||||
socket: AppSocket;
|
|
||||||
|
|
||||||
_store: AppStore;
|
|
||||||
prevState: CanvasV2State;
|
|
||||||
isFirstRender: boolean = true;
|
|
||||||
_isDebugging: boolean = false;
|
_isDebugging: boolean = false;
|
||||||
|
|
||||||
constructor(stage: Konva.Stage, container: HTMLDivElement, store: AppStore, socket: AppSocket) {
|
constructor(stage: Konva.Stage, container: HTMLDivElement, store: AppStore, socket: AppSocket) {
|
||||||
this.id = getPrefixedId(this.type);
|
this.id = getPrefixedId(this.type);
|
||||||
this.path = [this.id];
|
this.path = [this.id];
|
||||||
this.container = container;
|
this.store = store;
|
||||||
this._store = store;
|
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.stateApi = new CanvasStateApi(this._store, this);
|
this.stateApi = new CanvasStateApi(this.store, this);
|
||||||
|
|
||||||
this.prevState = this.stateApi.getState();
|
|
||||||
|
|
||||||
this.log = logger('canvas').child((message) => {
|
|
||||||
return {
|
|
||||||
...message,
|
|
||||||
context: {
|
|
||||||
...this.getLoggingContext(),
|
|
||||||
...message.context,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
this.stage = new CanvasStageModule(stage, container, this);
|
this.stage = new CanvasStageModule(stage, container, this);
|
||||||
this.worker = new CanvasWorkerModule(this);
|
this.worker = new CanvasWorkerModule(this);
|
||||||
@ -95,6 +78,16 @@ export class CanvasManager {
|
|||||||
this.filter = new CanvasFilter(this);
|
this.filter = new CanvasFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log = logger('canvas').child((message) => {
|
||||||
|
return {
|
||||||
|
...message,
|
||||||
|
context: {
|
||||||
|
...this.getLoggingContext(),
|
||||||
|
...message.context,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
enableDebugging() {
|
enableDebugging() {
|
||||||
this._isDebugging = true;
|
this._isDebugging = true;
|
||||||
this.logDebugInfo();
|
this.logDebugInfo();
|
||||||
@ -171,7 +164,7 @@ export class CanvasManager {
|
|||||||
|
|
||||||
const cleanupEventHandlers = setStageEventHandlers(this);
|
const cleanupEventHandlers = setStageEventHandlers(this);
|
||||||
const cleanupStage = this.stage.initialize();
|
const cleanupStage = this.stage.initialize();
|
||||||
const cleanupStore = this._store.subscribe(this.renderer.render);
|
const cleanupStore = this.store.subscribe(this.renderer.render);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
this.log.debug('Cleaning up canvas manager');
|
this.log.debug('Cleaning up canvas manager');
|
||||||
|
@ -51,11 +51,7 @@ export class CanvasStagingArea {
|
|||||||
this.konva.group.position({ x, y });
|
this.konva.group.position({ x, y });
|
||||||
|
|
||||||
if (this.selectedImage) {
|
if (this.selectedImage) {
|
||||||
const {
|
const { imageDTO } = this.selectedImage;
|
||||||
imageDTO,
|
|
||||||
// offsetX, // TODO(psyche): restore the crop in the node?
|
|
||||||
// offsetY // TODO(psyche): restore the crop in the node?
|
|
||||||
} = this.selectedImage;
|
|
||||||
|
|
||||||
if (!this.image) {
|
if (!this.image) {
|
||||||
const { image_name } = imageDTO;
|
const { image_name } = imageDTO;
|
||||||
@ -63,7 +59,6 @@ export class CanvasStagingArea {
|
|||||||
{
|
{
|
||||||
id: 'staging-area-image',
|
id: 'staging-area-image',
|
||||||
type: 'image',
|
type: 'image',
|
||||||
filters: [],
|
|
||||||
image: {
|
image: {
|
||||||
image_name: image_name,
|
image_name: image_name,
|
||||||
width,
|
width,
|
||||||
|
Loading…
Reference in New Issue
Block a user