feat(ui): hide bbox button when no canvas session active

This commit is contained in:
psychedelicious 2024-07-08 17:17:51 +10:00
parent bdc428cdd8
commit e795de5647

View File

@ -1,4 +1,5 @@
import { ButtonGroup } from '@invoke-ai/ui-library'; import { ButtonGroup } from '@invoke-ai/ui-library';
import { useAppSelector } from 'app/store/storeHooks';
import { BboxToolButton } from 'features/controlLayers/components/BboxToolButton'; import { BboxToolButton } from 'features/controlLayers/components/BboxToolButton';
import { BrushToolButton } from 'features/controlLayers/components/BrushToolButton'; import { BrushToolButton } from 'features/controlLayers/components/BrushToolButton';
import { EraserToolButton } from 'features/controlLayers/components/EraserToolButton'; import { EraserToolButton } from 'features/controlLayers/components/EraserToolButton';
@ -11,6 +12,20 @@ import { useCanvasResetLayerHotkey } from 'features/controlLayers/hooks/useCanva
export const ToolChooser: React.FC = () => { export const ToolChooser: React.FC = () => {
useCanvasResetLayerHotkey(); useCanvasResetLayerHotkey();
useCanvasDeleteLayerHotkey(); useCanvasDeleteLayerHotkey();
const isCanvasSessionActive = useAppSelector((s) => s.canvasV2.session.isActive);
if (isCanvasSessionActive) {
return (
<ButtonGroup isAttached>
<BrushToolButton />
<EraserToolButton />
<RectToolButton />
<MoveToolButton />
<ViewToolButton />
<BboxToolButton />
</ButtonGroup>
);
}
return ( return (
<ButtonGroup isAttached> <ButtonGroup isAttached>
@ -19,7 +34,6 @@ export const ToolChooser: React.FC = () => {
<RectToolButton /> <RectToolButton />
<MoveToolButton /> <MoveToolButton />
<ViewToolButton /> <ViewToolButton />
<BboxToolButton />
</ButtonGroup> </ButtonGroup>
); );
}; };