Skip to content

Commit 2aa163b

Browse files
feat(ui): add default inpaint mask layer on canvas reset
1 parent f40900c commit 2aa163b

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

invokeai/frontend/web/src/common/components/SessionMenuItems.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { MenuItem } from '@invoke-ai/ui-library';
22
import { useAppDispatch } from 'app/store/storeHooks';
3-
import { allEntitiesDeleted } from 'features/controlLayers/store/canvasSlice';
3+
import { canvasReset } from 'features/controlLayers/store/actions';
4+
import { inpaintMaskAdded } from 'features/controlLayers/store/canvasSlice';
5+
import { $canvasManager } from 'features/controlLayers/store/ephemeral';
46
import { paramsReset } from 'features/controlLayers/store/paramsSlice';
57
import { memo, useCallback } from 'react';
68
import { useTranslation } from 'react-i18next';
@@ -11,7 +13,9 @@ export const SessionMenuItems = memo(() => {
1113
const dispatch = useAppDispatch();
1214

1315
const resetCanvasLayers = useCallback(() => {
14-
dispatch(allEntitiesDeleted());
16+
dispatch(canvasReset());
17+
dispatch(inpaintMaskAdded({ isSelected: true, isBookmarked: true }));
18+
$canvasManager.get()?.stage.fitBboxToStage();
1519
}, [dispatch]);
1620
const resetGenerationSettings = useCallback(() => {
1721
dispatch(paramsReset());

invokeai/frontend/web/src/features/controlLayers/store/canvasSlice.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,6 @@ export const {
16181618
entityArrangedToBack,
16191619
entityOpacityChanged,
16201620
entitiesReordered,
1621-
allEntitiesDeleted,
16221621
allEntitiesOfTypeIsHiddenToggled,
16231622
allNonRasterLayersIsHiddenToggled,
16241623
// bbox

invokeai/frontend/web/src/features/gallery/components/ImageContextMenu/ImageMenuItemNewCanvasFromImageSubMenu.tsx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ export const ImageMenuItemNewCanvasFromImageSubMenu = memo(() => {
2121
const onClickNewCanvasWithRasterLayerFromImage = useCallback(async () => {
2222
const { dispatch, getState } = store;
2323
await navigationApi.focusPanel('canvas', WORKSPACE_PANEL_ID);
24-
await newCanvasFromImage({ imageDTO, withResize: false, type: 'raster_layer', dispatch, getState });
24+
await newCanvasFromImage({
25+
imageDTO,
26+
withResize: false,
27+
withInpaintMask: true,
28+
type: 'raster_layer',
29+
dispatch,
30+
getState,
31+
});
2532
toast({
2633
id: 'SENT_TO_CANVAS',
2734
title: t('toast.sentToCanvas'),
@@ -32,7 +39,14 @@ export const ImageMenuItemNewCanvasFromImageSubMenu = memo(() => {
3239
const onClickNewCanvasWithControlLayerFromImage = useCallback(async () => {
3340
const { dispatch, getState } = store;
3441
await navigationApi.focusPanel('canvas', WORKSPACE_PANEL_ID);
35-
await newCanvasFromImage({ imageDTO, withResize: false, type: 'control_layer', dispatch, getState });
42+
await newCanvasFromImage({
43+
imageDTO,
44+
withResize: false,
45+
withInpaintMask: true,
46+
type: 'control_layer',
47+
dispatch,
48+
getState,
49+
});
3650
toast({
3751
id: 'SENT_TO_CANVAS',
3852
title: t('toast.sentToCanvas'),
@@ -43,7 +57,14 @@ export const ImageMenuItemNewCanvasFromImageSubMenu = memo(() => {
4357
const onClickNewCanvasWithRasterLayerFromImageWithResize = useCallback(async () => {
4458
const { dispatch, getState } = store;
4559
await navigationApi.focusPanel('canvas', WORKSPACE_PANEL_ID);
46-
await newCanvasFromImage({ imageDTO, withResize: true, type: 'raster_layer', dispatch, getState });
60+
await newCanvasFromImage({
61+
imageDTO,
62+
withResize: true,
63+
withInpaintMask: true,
64+
type: 'raster_layer',
65+
dispatch,
66+
getState,
67+
});
4768
toast({
4869
id: 'SENT_TO_CANVAS',
4970
title: t('toast.sentToCanvas'),
@@ -54,7 +75,14 @@ export const ImageMenuItemNewCanvasFromImageSubMenu = memo(() => {
5475
const onClickNewCanvasWithControlLayerFromImageWithResize = useCallback(async () => {
5576
const { dispatch, getState } = store;
5677
await navigationApi.focusPanel('canvas', WORKSPACE_PANEL_ID);
57-
await newCanvasFromImage({ imageDTO, withResize: true, type: 'control_layer', dispatch, getState });
78+
await newCanvasFromImage({
79+
imageDTO,
80+
withResize: true,
81+
withInpaintMask: true,
82+
type: 'control_layer',
83+
dispatch,
84+
getState,
85+
});
5886
toast({
5987
id: 'SENT_TO_CANVAS',
6088
title: t('toast.sentToCanvas'),

0 commit comments

Comments
 (0)