Files
InvokeAI/invokeai/frontend/web/src/features/controlLayers/hooks/useCanvasIsBusy.ts
psychedelicious e5792278b9 feat(ui): revised canvas "busyness" state tracking
Track various canvas states:
- Filtering an entity
- Transforming an entity
- Rasterizing an entity
- Compositing
- Busy (derived from all of the above)

Also track individual entity states:
- Locked
- Disabled
- All of type are hidden
- Has objects
- Interactable (derived from all of the above)

These states then gate various actions. For example:
- Cannot invoke while the canvas is busy.
- Cannot transform, filter, duplicate, or delete when the canvas is busy.

Tool interaction restrictions are not yet implemented.
2024-09-13 22:33:34 +10:00

17 lines
529 B
TypeScript

import { useStore } from '@nanostores/react';
import { useCanvasManager } from 'features/controlLayers/contexts/CanvasManagerProviderGate';
export const useCanvasIsBusy = () => {
const canvasManager = useCanvasManager();
/**
* Whether the canvas is busy:
* - While staging
* - While an entity is transforming
* - While an entity is filtering
* - While the canvas is doing some other long-running operation, like rasterizing a layer
*/
const isBusy = useStore(canvasManager.$isBusy);
return isBusy;
};