wip: Improve the IP Adapter UI

This commit is contained in:
blessedcoolant 2023-09-16 12:14:04 +12:00 committed by Kent Keirsey
parent f7b64304ae
commit 208286e97a
5 changed files with 41 additions and 7 deletions

View File

@ -193,7 +193,9 @@
"w": "W", "w": "W",
"weight": "Weight", "weight": "Weight",
"enableIPAdapter": "Enable IP Adapter", "enableIPAdapter": "Enable IP Adapter",
"ipAdapterModel": "Adapter Model" "ipAdapterModel": "Adapter Model",
"resetIPAdapterImage": "Reset IP Adapter Image",
"ipAdapterImageFallback": "No IP Adapter Image Selected"
}, },
"embedding": { "embedding": {
"addEmbedding": "Add Embedding", "addEmbedding": "Add Embedding",

View File

@ -86,7 +86,10 @@ export const store = configureStore({
.concat(autoBatchEnhancer()); .concat(autoBatchEnhancer());
}, },
middleware: (getDefaultMiddleware) => middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ immutableCheck: false }) getDefaultMiddleware({
serializableCheck: false,
immutableCheck: false,
})
.concat(api.middleware) .concat(api.middleware)
.concat(dynamicMiddlewares) .concat(dynamicMiddlewares)
.prepend(listenerMiddleware.middleware), .prepend(listenerMiddleware.middleware),

View File

@ -13,7 +13,7 @@ const IPAdapterPanel = () => {
gap: 3, gap: 3,
paddingInline: 3, paddingInline: 3,
paddingBlock: 2, paddingBlock: 2,
paddingBottom: 6, paddingBottom: 5,
borderRadius: 'base', borderRadius: 'base',
position: 'relative', position: 'relative',
bg: 'base.250', bg: 'base.250',

View File

@ -1,14 +1,18 @@
import { Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import { skipToken } from '@reduxjs/toolkit/dist/query'; import { skipToken } from '@reduxjs/toolkit/dist/query';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAIDndImage from 'common/components/IAIDndImage'; import IAIDndImage from 'common/components/IAIDndImage';
import IAIIconButton from 'common/components/IAIIconButton';
import { IAINoContentFallback } from 'common/components/IAIImageFallback'; import { IAINoContentFallback } from 'common/components/IAIImageFallback';
import { ipAdapterImageChanged } from 'features/controlNet/store/controlNetSlice';
import { import {
TypesafeDraggableData, TypesafeDraggableData,
TypesafeDroppableData, TypesafeDroppableData,
} from 'features/dnd/types'; } from 'features/dnd/types';
import { memo, useMemo } from 'react'; import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { FaUndo } from 'react-icons/fa';
import { useGetImageDTOQuery } from 'services/api/endpoints/images'; import { useGetImageDTOQuery } from 'services/api/endpoints/images';
const ParamIPAdapterImage = () => { const ParamIPAdapterImage = () => {
@ -20,6 +24,9 @@ const ParamIPAdapterImage = () => {
(state: RootState) => state.controlNet.isIPAdapterEnabled (state: RootState) => state.controlNet.isIPAdapterEnabled
); );
const dispatch = useAppDispatch();
const { t } = useTranslation();
const { currentData: imageDTO } = useGetImageDTOQuery( const { currentData: imageDTO } = useGetImageDTOQuery(
ipAdapterInfo.adapterImage?.image_name ?? skipToken ipAdapterInfo.adapterImage?.image_name ?? skipToken
); );
@ -56,12 +63,28 @@ const ParamIPAdapterImage = () => {
droppableData={droppableData} droppableData={droppableData}
draggableData={draggableData} draggableData={draggableData}
isUploadDisabled={!isIPAdapterEnabled} isUploadDisabled={!isIPAdapterEnabled}
fitContainer dropLabel={t('toast.setIPAdapterImage')}
// dropLabel="Set as Initial Image"
noContentFallback={ noContentFallback={
<IAINoContentFallback label="No IP Adapter Image Selected" /> <IAINoContentFallback
label={t('controlnet.ipAdapterImageFallback')}
/>
} }
/> />
{ipAdapterInfo.adapterImage && (
<IAIIconButton
tooltip={t('controlnet.resetIPAdapterImage')}
aria-label={t('controlnet.resetIPAdapterImage')}
icon={<FaUndo />}
onClick={() => dispatch(ipAdapterImageChanged(null))}
isDisabled={!imageDTO}
sx={{
position: 'absolute',
top: 3,
right: 3,
}}
/>
)}
</Flex> </Flex>
); );
}; };

View File

@ -22,6 +22,10 @@ const ParamIPAdapterWeight = () => {
[dispatch] [dispatch]
); );
const handleWeightReset = useCallback(() => {
dispatch(ipAdapterWeightChanged(1));
}, [dispatch]);
return ( return (
<IAISlider <IAISlider
isDisabled={!isIpAdapterEnabled} isDisabled={!isIpAdapterEnabled}
@ -33,6 +37,8 @@ const ParamIPAdapterWeight = () => {
step={0.01} step={0.01}
withSliderMarks withSliderMarks
sliderMarks={[0, 1, 2]} sliderMarks={[0, 1, 2]}
withReset
handleReset={handleWeightReset}
/> />
); );
}; };