Fixes staging area outline

This commit is contained in:
psychedelicious 2022-11-19 17:01:43 +11:00 committed by blessedcoolant
parent ae4a44de3e
commit 68aebad7ad
4 changed files with 26 additions and 19 deletions

View File

@ -15,6 +15,7 @@ const selector = createSelector(
stagingArea: { images, selectedImageIndex }, stagingArea: { images, selectedImageIndex },
}, },
shouldShowStagingImage, shouldShowStagingImage,
shouldShowStagingOutline,
} = canvas; } = canvas;
return { return {
@ -23,6 +24,7 @@ const selector = createSelector(
isOnFirstImage: selectedImageIndex === 0, isOnFirstImage: selectedImageIndex === 0,
isOnLastImage: selectedImageIndex === images.length - 1, isOnLastImage: selectedImageIndex === images.length - 1,
shouldShowStagingImage, shouldShowStagingImage,
shouldShowStagingOutline,
}; };
}, },
{ {
@ -36,11 +38,11 @@ type Props = GroupConfig;
const IAICanvasStagingArea = (props: Props) => { const IAICanvasStagingArea = (props: Props) => {
const { ...rest } = props; const { ...rest } = props;
const { currentStagingAreaImage, shouldShowStagingImage } = const {
useAppSelector(selector); currentStagingAreaImage,
shouldShowStagingImage,
const [shouldShowStagingAreaOutline, setShouldShowStagingAreaOutline] = shouldShowStagingOutline,
useState<boolean>(true); } = useAppSelector(selector);
if (!currentStagingAreaImage) return null; if (!currentStagingAreaImage) return null;
@ -53,7 +55,7 @@ const IAICanvasStagingArea = (props: Props) => {
return ( return (
<Group {...rest}> <Group {...rest}>
{shouldShowStagingImage && <IAICanvasImage url={url} x={x} y={y} />} {shouldShowStagingImage && <IAICanvasImage url={url} x={x} y={y} />}
{shouldShowStagingAreaOutline && ( {shouldShowStagingOutline && (
<Group> <Group>
<Rect <Rect
x={x} x={x}

View File

@ -28,6 +28,7 @@ import {
nextStagingAreaImage, nextStagingAreaImage,
prevStagingAreaImage, prevStagingAreaImage,
setShouldShowStagingImage, setShouldShowStagingImage,
setShouldShowStagingOutline,
} from 'features/canvas/store/canvasSlice'; } from 'features/canvas/store/canvasSlice';
const selector = createSelector( const selector = createSelector(
@ -37,6 +38,7 @@ const selector = createSelector(
layerState: { layerState: {
stagingArea: { images, selectedImageIndex }, stagingArea: { images, selectedImageIndex },
}, },
shouldShowStagingOutline,
shouldShowStagingImage, shouldShowStagingImage,
} = canvas; } = canvas;
@ -46,6 +48,7 @@ const selector = createSelector(
isOnFirstImage: selectedImageIndex === 0, isOnFirstImage: selectedImageIndex === 0,
isOnLastImage: selectedImageIndex === images.length - 1, isOnLastImage: selectedImageIndex === images.length - 1,
shouldShowStagingImage, shouldShowStagingImage,
shouldShowStagingOutline,
}; };
}, },
{ {
@ -64,16 +67,13 @@ const IAICanvasStagingAreaToolbar = () => {
shouldShowStagingImage, shouldShowStagingImage,
} = useAppSelector(selector); } = useAppSelector(selector);
const [shouldShowStagingAreaOutline, setShouldShowStagingAreaOutline] =
useState<boolean>(true);
const handleMouseOver = useCallback(() => { const handleMouseOver = useCallback(() => {
setShouldShowStagingAreaOutline(false); dispatch(setShouldShowStagingOutline(false));
}, []); }, [dispatch]);
const handleMouseOut = useCallback(() => { const handleMouseOut = useCallback(() => {
setShouldShowStagingAreaOutline(true); dispatch(setShouldShowStagingOutline(true));
}, []); }, [dispatch]);
if (!currentStagingAreaImage) return null; if (!currentStagingAreaImage) return null;
@ -84,6 +84,9 @@ const IAICanvasStagingAreaToolbar = () => {
w={'100%'} w={'100%'}
align={'center'} align={'center'}
justify={'center'} justify={'center'}
filter="drop-shadow(0 0.5rem 1rem rgba(0,0,0))"
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
> >
<ButtonGroup isAttached> <ButtonGroup isAttached>
<IAIIconButton <IAIIconButton
@ -92,8 +95,6 @@ const IAICanvasStagingAreaToolbar = () => {
aria-label="Previous" aria-label="Previous"
icon={<FaArrowLeft />} icon={<FaArrowLeft />}
onClick={() => dispatch(prevStagingAreaImage())} onClick={() => dispatch(prevStagingAreaImage())}
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
data-selected={true} data-selected={true}
isDisabled={isOnFirstImage} isDisabled={isOnFirstImage}
/> />
@ -103,8 +104,6 @@ const IAICanvasStagingAreaToolbar = () => {
aria-label="Next" aria-label="Next"
icon={<FaArrowRight />} icon={<FaArrowRight />}
onClick={() => dispatch(nextStagingAreaImage())} onClick={() => dispatch(nextStagingAreaImage())}
onMouseOver={handleMouseOver}
onMouseOut={handleMouseOut}
data-selected={true} data-selected={true}
isDisabled={isOnLastImage} isDisabled={isOnLastImage}
/> />

View File

@ -73,13 +73,14 @@ const initialCanvasState: CanvasState = {
shouldShowCheckboardTransparency: false, shouldShowCheckboardTransparency: false,
shouldShowGrid: true, shouldShowGrid: true,
shouldShowIntermediates: true, shouldShowIntermediates: true,
shouldShowStagingImage: true,
shouldShowStagingOutline: true,
shouldSnapToGrid: true, shouldSnapToGrid: true,
shouldUseInpaintReplace: false, shouldUseInpaintReplace: false,
stageCoordinates: { x: 0, y: 0 }, stageCoordinates: { x: 0, y: 0 },
stageDimensions: { width: 0, height: 0 }, stageDimensions: { width: 0, height: 0 },
stageScale: 1, stageScale: 1,
tool: 'brush', tool: 'brush',
shouldShowStagingImage: true,
}; };
export const canvasSlice = createSlice({ export const canvasSlice = createSlice({
@ -636,6 +637,9 @@ export const canvasSlice = createSlice({
setShouldShowStagingImage: (state, action: PayloadAction<boolean>) => { setShouldShowStagingImage: (state, action: PayloadAction<boolean>) => {
state.shouldShowStagingImage = action.payload; state.shouldShowStagingImage = action.payload;
}, },
setShouldShowStagingOutline: (state, action: PayloadAction<boolean>) => {
state.shouldShowStagingOutline = action.payload;
},
setMergedCanvas: (state, action: PayloadAction<CanvasImage>) => { setMergedCanvas: (state, action: PayloadAction<CanvasImage>) => {
state.pastLayerStates.push({ state.pastLayerStates.push({
...state.layerState, ...state.layerState,
@ -705,6 +709,7 @@ export const {
fitBoundingBoxToStage, fitBoundingBoxToStage,
setShouldShowStagingImage, setShouldShowStagingImage,
setMergedCanvas, setMergedCanvas,
setShouldShowStagingOutline,
} = canvasSlice.actions; } = canvasSlice.actions;
export default canvasSlice.reducer; export default canvasSlice.reducer;

View File

@ -104,11 +104,12 @@ export interface CanvasState {
shouldShowCheckboardTransparency: boolean; shouldShowCheckboardTransparency: boolean;
shouldShowGrid: boolean; shouldShowGrid: boolean;
shouldShowIntermediates: boolean; shouldShowIntermediates: boolean;
shouldShowStagingImage: boolean;
shouldShowStagingOutline: boolean;
shouldSnapToGrid: boolean; shouldSnapToGrid: boolean;
shouldUseInpaintReplace: boolean; shouldUseInpaintReplace: boolean;
stageCoordinates: Vector2d; stageCoordinates: Vector2d;
stageDimensions: Dimensions; stageDimensions: Dimensions;
stageScale: number; stageScale: number;
tool: CanvasTool; tool: CanvasTool;
shouldShowStagingImage: boolean;
} }