mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: ✨ discard current inpaint item
This commit is contained in:
parent
779b3e0e8e
commit
cab3748010
@ -1815,6 +1815,7 @@
|
|||||||
"cursorPosition": "Cursor Position",
|
"cursorPosition": "Cursor Position",
|
||||||
"darkenOutsideSelection": "Darken Outside Selection",
|
"darkenOutsideSelection": "Darken Outside Selection",
|
||||||
"discardAll": "Discard All",
|
"discardAll": "Discard All",
|
||||||
|
"discardCurrent": "Discard Current",
|
||||||
"downloadAsImage": "Download As Image",
|
"downloadAsImage": "Download As Image",
|
||||||
"emptyFolder": "Empty Folder",
|
"emptyFolder": "Empty Folder",
|
||||||
"emptyTempImageFolder": "Empty Temp Image Folder",
|
"emptyTempImageFolder": "Empty Temp Image Folder",
|
||||||
|
@ -5,6 +5,7 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
|||||||
import { stagingAreaImageSaved } from 'features/canvas/store/actions';
|
import { stagingAreaImageSaved } from 'features/canvas/store/actions';
|
||||||
import {
|
import {
|
||||||
commitStagingAreaImage,
|
commitStagingAreaImage,
|
||||||
|
discardStagedImage,
|
||||||
discardStagedImages,
|
discardStagedImages,
|
||||||
nextStagingAreaImage,
|
nextStagingAreaImage,
|
||||||
prevStagingAreaImage,
|
prevStagingAreaImage,
|
||||||
@ -22,6 +23,7 @@ import {
|
|||||||
PiEyeBold,
|
PiEyeBold,
|
||||||
PiEyeSlashBold,
|
PiEyeSlashBold,
|
||||||
PiFloppyDiskBold,
|
PiFloppyDiskBold,
|
||||||
|
PiTrashSimpleBold,
|
||||||
PiXBold,
|
PiXBold,
|
||||||
} from 'react-icons/pi';
|
} from 'react-icons/pi';
|
||||||
import { useGetImageDTOQuery } from 'services/api/endpoints/images';
|
import { useGetImageDTOQuery } from 'services/api/endpoints/images';
|
||||||
@ -44,6 +46,40 @@ const selector = createMemoizedSelector(selectCanvasSlice, (canvas) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ClearStagingIntermediatesIconButton = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handleDiscardStagingArea = useCallback(() => {
|
||||||
|
dispatch(discardStagedImages())
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
|
const handleDiscardStagingImage = useCallback(() => {
|
||||||
|
dispatch(discardStagedImage())
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<IconButton
|
||||||
|
tooltip={`${t('unifiedCanvas.discardCurrent')}`}
|
||||||
|
aria-label={t('unifiedCanvas.discardCurrent')}
|
||||||
|
icon={<PiXBold />}
|
||||||
|
onClick={handleDiscardStagingImage}
|
||||||
|
colorScheme="invokeBlue"
|
||||||
|
fontSize={16}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
tooltip={`${t('unifiedCanvas.discardAll')} (Esc)`}
|
||||||
|
aria-label={t('unifiedCanvas.discardAll')}
|
||||||
|
icon={<PiTrashSimpleBold />}
|
||||||
|
onClick={handleDiscardStagingArea}
|
||||||
|
colorScheme="error"
|
||||||
|
fontSize={16}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const IAICanvasStagingAreaToolbar = () => {
|
const IAICanvasStagingAreaToolbar = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { currentStagingAreaImage, shouldShowStagingImage, currentIndex, total } = useAppSelector(selector);
|
const { currentStagingAreaImage, shouldShowStagingImage, currentIndex, total } = useAppSelector(selector);
|
||||||
@ -185,14 +221,7 @@ const IAICanvasStagingAreaToolbar = () => {
|
|||||||
onClick={handleSaveToGallery}
|
onClick={handleSaveToGallery}
|
||||||
colorScheme="invokeBlue"
|
colorScheme="invokeBlue"
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<ClearStagingIntermediatesIconButton />
|
||||||
tooltip={`${t('unifiedCanvas.discardAll')} (Esc)`}
|
|
||||||
aria-label={t('unifiedCanvas.discardAll')}
|
|
||||||
icon={<PiXBold />}
|
|
||||||
onClick={handleDiscardStagingArea}
|
|
||||||
colorScheme="error"
|
|
||||||
fontSize={20}
|
|
||||||
/>
|
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
@ -292,6 +292,24 @@ export const canvasSlice = createSlice({
|
|||||||
state.shouldShowStagingImage = true;
|
state.shouldShowStagingImage = true;
|
||||||
state.batchIds = [];
|
state.batchIds = [];
|
||||||
},
|
},
|
||||||
|
discardStagedImage: (state) => {
|
||||||
|
const { images, selectedImageIndex } = state.layerState.stagingArea;
|
||||||
|
|
||||||
|
if (!images.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
images.splice(selectedImageIndex, 1);
|
||||||
|
|
||||||
|
if (selectedImageIndex >= images.length) {
|
||||||
|
state.layerState.stagingArea.selectedImageIndex = images.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!images.length) {
|
||||||
|
state.shouldShowStagingImage = false;
|
||||||
|
state.shouldShowStagingOutline = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
addFillRect: (state) => {
|
addFillRect: (state) => {
|
||||||
const { boundingBoxCoordinates, boundingBoxDimensions, brushColor } = state;
|
const { boundingBoxCoordinates, boundingBoxDimensions, brushColor } = state;
|
||||||
|
|
||||||
@ -659,6 +677,7 @@ export const {
|
|||||||
commitColorPickerColor,
|
commitColorPickerColor,
|
||||||
commitStagingAreaImage,
|
commitStagingAreaImage,
|
||||||
discardStagedImages,
|
discardStagedImages,
|
||||||
|
discardStagedImage,
|
||||||
nextStagingAreaImage,
|
nextStagingAreaImage,
|
||||||
prevStagingAreaImage,
|
prevStagingAreaImage,
|
||||||
redo,
|
redo,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user