mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add hotkey to cycle compare modes
This commit is contained in:
parent
9a0b77ad38
commit
7153d846a9
@ -4,6 +4,7 @@ import {
|
|||||||
comparedImagesSwapped,
|
comparedImagesSwapped,
|
||||||
comparisonFitChanged,
|
comparisonFitChanged,
|
||||||
comparisonModeChanged,
|
comparisonModeChanged,
|
||||||
|
comparisonModeCycled,
|
||||||
imageToCompareChanged,
|
imageToCompareChanged,
|
||||||
} from 'features/gallery/store/gallerySlice';
|
} from 'features/gallery/store/gallerySlice';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
@ -36,6 +37,10 @@ export const CompareToolbar = memo(() => {
|
|||||||
dispatch(imageToCompareChanged(null));
|
dispatch(imageToCompareChanged(null));
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
useHotkeys('esc', exitCompare, [exitCompare]);
|
useHotkeys('esc', exitCompare, [exitCompare]);
|
||||||
|
const nextMode = useCallback(() => {
|
||||||
|
dispatch(comparisonModeCycled());
|
||||||
|
}, [dispatch]);
|
||||||
|
useHotkeys('m', nextMode, [nextMode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex w="full" gap={2}>
|
<Flex w="full" gap={2}>
|
||||||
|
@ -46,6 +46,19 @@ export const gallerySlice = createSlice({
|
|||||||
comparisonModeChanged: (state, action: PayloadAction<ComparisonMode>) => {
|
comparisonModeChanged: (state, action: PayloadAction<ComparisonMode>) => {
|
||||||
state.comparisonMode = action.payload;
|
state.comparisonMode = action.payload;
|
||||||
},
|
},
|
||||||
|
comparisonModeCycled: (state) => {
|
||||||
|
switch (state.comparisonMode) {
|
||||||
|
case 'slider':
|
||||||
|
state.comparisonMode = 'side-by-side';
|
||||||
|
break;
|
||||||
|
case 'side-by-side':
|
||||||
|
state.comparisonMode = 'hover';
|
||||||
|
break;
|
||||||
|
case 'hover':
|
||||||
|
state.comparisonMode = 'slider';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
shouldAutoSwitchChanged: (state, action: PayloadAction<boolean>) => {
|
shouldAutoSwitchChanged: (state, action: PayloadAction<boolean>) => {
|
||||||
state.shouldAutoSwitch = action.payload;
|
state.shouldAutoSwitch = action.payload;
|
||||||
},
|
},
|
||||||
@ -143,6 +156,7 @@ export const {
|
|||||||
comparisonModeChanged,
|
comparisonModeChanged,
|
||||||
comparedImagesSwapped,
|
comparedImagesSwapped,
|
||||||
comparisonFitChanged,
|
comparisonFitChanged,
|
||||||
|
comparisonModeCycled,
|
||||||
} = gallerySlice.actions;
|
} = gallerySlice.actions;
|
||||||
|
|
||||||
const isAnyBoardDeleted = isAnyOf(
|
const isAnyBoardDeleted = isAnyOf(
|
||||||
|
Loading…
Reference in New Issue
Block a user