mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): calculate renderable entities correctly in tool module
This commit is contained in:
parent
cd3da886d6
commit
fc6d244071
@ -25,6 +25,7 @@ import {
|
|||||||
entitySelected,
|
entitySelected,
|
||||||
eraserWidthChanged,
|
eraserWidthChanged,
|
||||||
fillChanged,
|
fillChanged,
|
||||||
|
selectAllRenderableEntities,
|
||||||
toolBufferChanged,
|
toolBufferChanged,
|
||||||
toolChanged,
|
toolChanged,
|
||||||
} from 'features/controlLayers/store/canvasV2Slice';
|
} from 'features/controlLayers/store/canvasV2Slice';
|
||||||
@ -198,6 +199,17 @@ export class CanvasStateApiModule {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRenderedEntityCount = () => {
|
||||||
|
const renderableEntities = selectAllRenderableEntities(this.getState());
|
||||||
|
let count = 0;
|
||||||
|
for (const entity of renderableEntities) {
|
||||||
|
if (entity.isEnabled) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
};
|
||||||
|
|
||||||
getSelectedEntity = () => {
|
getSelectedEntity = () => {
|
||||||
const state = this.getState();
|
const state = this.getState();
|
||||||
if (state.selectedEntityIdentifier) {
|
if (state.selectedEntityIdentifier) {
|
||||||
|
@ -219,7 +219,7 @@ export class CanvasToolModule {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const stage = this.manager.stage;
|
const stage = this.manager.stage;
|
||||||
const renderedEntityCount: number = 1; // TODO(psyche): this.manager should be renderable entity count
|
const renderedEntityCount = this.manager.stateApi.getRenderedEntityCount();
|
||||||
const toolState = this.manager.stateApi.getToolState();
|
const toolState = this.manager.stateApi.getToolState();
|
||||||
const selectedEntity = this.manager.stateApi.getSelectedEntity();
|
const selectedEntity = this.manager.stateApi.getSelectedEntity();
|
||||||
const cursorPos = this.manager.stateApi.$lastCursorPos.get();
|
const cursorPos = this.manager.stateApi.$lastCursorPos.get();
|
||||||
|
@ -24,8 +24,12 @@ import { atom } from 'nanostores';
|
|||||||
import { assert } from 'tsafe';
|
import { assert } from 'tsafe';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
CanvasControlLayerState,
|
||||||
CanvasEntityIdentifier,
|
CanvasEntityIdentifier,
|
||||||
CanvasEntityState,
|
CanvasEntityState,
|
||||||
|
CanvasInpaintMaskState,
|
||||||
|
CanvasRasterLayerState,
|
||||||
|
CanvasRegionalGuidanceState,
|
||||||
CanvasV2State,
|
CanvasV2State,
|
||||||
Coordinate,
|
Coordinate,
|
||||||
EntityBrushLineAddedPayload,
|
EntityBrushLineAddedPayload,
|
||||||
@ -170,7 +174,7 @@ function selectAllEntitiesOfType(state: CanvasV2State, type: CanvasEntityState['
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAllEntities(state: CanvasV2State): CanvasEntityState[] {
|
export function selectAllEntities(state: CanvasV2State): CanvasEntityState[] {
|
||||||
// These are in the same order as they are displayed in the list!
|
// These are in the same order as they are displayed in the list!
|
||||||
return [
|
return [
|
||||||
...state.inpaintMasks.entities.toReversed(),
|
...state.inpaintMasks.entities.toReversed(),
|
||||||
@ -181,6 +185,17 @@ function selectAllEntities(state: CanvasV2State): CanvasEntityState[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function selectAllRenderableEntities(
|
||||||
|
state: CanvasV2State
|
||||||
|
): (CanvasRasterLayerState | CanvasControlLayerState | CanvasInpaintMaskState | CanvasRegionalGuidanceState)[] {
|
||||||
|
return [
|
||||||
|
...state.rasterLayers.entities,
|
||||||
|
...state.controlLayers.entities,
|
||||||
|
...state.inpaintMasks.entities,
|
||||||
|
...state.regions.entities,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export const canvasV2Slice = createSlice({
|
export const canvasV2Slice = createSlice({
|
||||||
name: 'canvasV2',
|
name: 'canvasV2',
|
||||||
initialState,
|
initialState,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user