mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): CanvasControlAdapter
This commit is contained in:
parent
00f39b977e
commit
667a156817
@ -10,7 +10,7 @@ export class CanvasControlAdapter {
|
|||||||
static GROUP_NAME = `${CanvasControlAdapter.NAME_PREFIX}_group`;
|
static GROUP_NAME = `${CanvasControlAdapter.NAME_PREFIX}_group`;
|
||||||
static OBJECT_GROUP_NAME = `${CanvasControlAdapter.NAME_PREFIX}_object-group`;
|
static OBJECT_GROUP_NAME = `${CanvasControlAdapter.NAME_PREFIX}_object-group`;
|
||||||
|
|
||||||
private controlAdapterState: ControlAdapterEntity;
|
private state: ControlAdapterEntity;
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
manager: CanvasManager;
|
manager: CanvasManager;
|
||||||
@ -24,8 +24,8 @@ export class CanvasControlAdapter {
|
|||||||
|
|
||||||
image: CanvasImage | null;
|
image: CanvasImage | null;
|
||||||
|
|
||||||
constructor(controlAdapterState: ControlAdapterEntity, manager: CanvasManager) {
|
constructor(state: ControlAdapterEntity, manager: CanvasManager) {
|
||||||
const { id } = controlAdapterState;
|
const { id } = state;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.konva = {
|
this.konva = {
|
||||||
@ -70,21 +70,21 @@ export class CanvasControlAdapter {
|
|||||||
this.konva.layer.add(this.konva.transformer);
|
this.konva.layer.add(this.konva.transformer);
|
||||||
|
|
||||||
this.image = null;
|
this.image = null;
|
||||||
this.controlAdapterState = controlAdapterState;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
async render(controlAdapterState: ControlAdapterEntity) {
|
async render(state: ControlAdapterEntity) {
|
||||||
this.controlAdapterState = controlAdapterState;
|
this.state = state;
|
||||||
|
|
||||||
// Update the layer's position and listening state
|
// Update the layer's position and listening state
|
||||||
this.konva.group.setAttrs({
|
this.konva.group.setAttrs({
|
||||||
x: controlAdapterState.position.x,
|
x: state.position.x,
|
||||||
y: controlAdapterState.position.y,
|
y: state.position.y,
|
||||||
scaleX: 1,
|
scaleX: 1,
|
||||||
scaleY: 1,
|
scaleY: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const imageObject = controlAdapterState.processedImageObject ?? controlAdapterState.imageObject;
|
const imageObject = state.processedImageObject ?? state.imageObject;
|
||||||
|
|
||||||
let didDraw = false;
|
let didDraw = false;
|
||||||
|
|
||||||
@ -108,9 +108,9 @@ export class CanvasControlAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateGroup(didDraw: boolean) {
|
updateGroup(didDraw: boolean) {
|
||||||
this.konva.layer.visible(this.controlAdapterState.isEnabled);
|
this.konva.layer.visible(this.state.isEnabled);
|
||||||
|
|
||||||
this.konva.group.opacity(this.controlAdapterState.opacity);
|
this.konva.group.opacity(this.state.opacity);
|
||||||
const isSelected = this.manager.stateApi.getIsSelected(this.id);
|
const isSelected = this.manager.stateApi.getIsSelected(this.id);
|
||||||
const selectedTool = this.manager.stateApi.getToolState().selected;
|
const selectedTool = this.manager.stateApi.getToolState().selected;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user