mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): progress image rerender, checkbox
This commit is contained in:
parent
a4313c26cb
commit
a6be44789b
@ -28,9 +28,6 @@ import { configChanged } from 'features/system/store/configSlice';
|
|||||||
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
||||||
import { useLogger } from 'app/logging/useLogger';
|
import { useLogger } from 'app/logging/useLogger';
|
||||||
import ProgressImagePreview from 'features/parameters/components/ProgressImagePreview';
|
import ProgressImagePreview from 'features/parameters/components/ProgressImagePreview';
|
||||||
// import { DndContext, DragEndEvent } from '@dnd-kit/core';
|
|
||||||
import { floatingProgressImageMoved } from 'features/ui/store/uiSlice';
|
|
||||||
// import { restrictToWindowEdges } from '@dnd-kit/modifiers';
|
|
||||||
|
|
||||||
const DEFAULT_CONFIG = {};
|
const DEFAULT_CONFIG = {};
|
||||||
|
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
import { Flex, Icon, Image } from '@chakra-ui/react';
|
||||||
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
|
import { systemSelector } from 'features/system/store/systemSelectors';
|
||||||
|
import { isEqual } from 'lodash-es';
|
||||||
|
import { memo } from 'react';
|
||||||
|
import { FaImage } from 'react-icons/fa';
|
||||||
|
|
||||||
|
const selector = createSelector(
|
||||||
|
[systemSelector],
|
||||||
|
(system) => {
|
||||||
|
const { progressImage } = system;
|
||||||
|
|
||||||
|
return {
|
||||||
|
progressImage,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{
|
||||||
|
memoizeOptions: {
|
||||||
|
resultEqualityCheck: isEqual,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const ProgressImage = () => {
|
||||||
|
const { progressImage } = useAppSelector(selector);
|
||||||
|
return progressImage ? (
|
||||||
|
<Flex
|
||||||
|
sx={{
|
||||||
|
position: 'relative',
|
||||||
|
w: 'full',
|
||||||
|
h: 'full',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
draggable={false}
|
||||||
|
src={progressImage.dataURL}
|
||||||
|
width={progressImage.width}
|
||||||
|
height={progressImage.height}
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
objectFit: 'contain',
|
||||||
|
maxWidth: '100%',
|
||||||
|
maxHeight: '100%',
|
||||||
|
height: 'auto',
|
||||||
|
borderRadius: 'base',
|
||||||
|
p: 2,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
) : (
|
||||||
|
<Flex
|
||||||
|
sx={{
|
||||||
|
w: 'full',
|
||||||
|
h: 'full',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon color="base.400" boxSize={32} as={FaImage} />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default memo(ProgressImage);
|
@ -1,9 +1,9 @@
|
|||||||
import { Flex, Icon, Image, Text } from '@chakra-ui/react';
|
import { Flex, Text } from '@chakra-ui/react';
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { systemSelector } from 'features/system/store/systemSelectors';
|
import { systemSelector } from 'features/system/store/systemSelectors';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { FaImage, FaStopwatch } from 'react-icons/fa';
|
import { FaStopwatch } from 'react-icons/fa';
|
||||||
import { uiSelector } from 'features/ui/store/uiSelectors';
|
import { uiSelector } from 'features/ui/store/uiSelectors';
|
||||||
import IAIIconButton from 'common/components/IAIIconButton';
|
import IAIIconButton from 'common/components/IAIIconButton';
|
||||||
import { CloseIcon } from '@chakra-ui/icons';
|
import { CloseIcon } from '@chakra-ui/icons';
|
||||||
@ -16,11 +16,12 @@ import {
|
|||||||
import { Rnd } from 'react-rnd';
|
import { Rnd } from 'react-rnd';
|
||||||
import { Rect } from 'features/ui/store/uiTypes';
|
import { Rect } from 'features/ui/store/uiTypes';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
import ProgressImage from './ProgressImage';
|
||||||
|
|
||||||
const selector = createSelector(
|
const selector = createSelector(
|
||||||
[systemSelector, uiSelector],
|
[systemSelector, uiSelector],
|
||||||
(system, ui) => {
|
(system, ui) => {
|
||||||
const { progressImage, isProcessing } = system;
|
const { isProcessing } = system;
|
||||||
const {
|
const {
|
||||||
floatingProgressImageRect,
|
floatingProgressImageRect,
|
||||||
shouldShowProgressImages,
|
shouldShowProgressImages,
|
||||||
@ -33,7 +34,6 @@ const selector = createSelector(
|
|||||||
: shouldShowProgressImages;
|
: shouldShowProgressImages;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
progressImage,
|
|
||||||
floatingProgressImageRect,
|
floatingProgressImageRect,
|
||||||
showProgressWindow,
|
showProgressWindow,
|
||||||
};
|
};
|
||||||
@ -48,13 +48,28 @@ const selector = createSelector(
|
|||||||
const ProgressImagePreview = () => {
|
const ProgressImagePreview = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const { showProgressWindow, progressImage, floatingProgressImageRect } =
|
const { showProgressWindow, floatingProgressImageRect } =
|
||||||
useAppSelector(selector);
|
useAppSelector(selector);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{' '}
|
||||||
|
<IAIIconButton
|
||||||
|
onClick={() =>
|
||||||
|
dispatch(setShouldShowProgressImages(!showProgressWindow))
|
||||||
|
}
|
||||||
|
tooltip={t('ui.showProgressImages')}
|
||||||
|
isChecked={showProgressWindow}
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 4,
|
||||||
|
insetInlineStart: 4,
|
||||||
|
}}
|
||||||
|
aria-label={t('ui.showProgressImages')}
|
||||||
|
icon={<FaStopwatch />}
|
||||||
|
/>
|
||||||
{showProgressWindow && (
|
{showProgressWindow && (
|
||||||
<Rnd
|
<Rnd
|
||||||
bounds="window"
|
bounds="window"
|
||||||
@ -141,64 +156,10 @@ const ProgressImagePreview = () => {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
{progressImage ? (
|
<ProgressImage />
|
||||||
<Flex
|
|
||||||
sx={{
|
|
||||||
position: 'relative',
|
|
||||||
w: 'full',
|
|
||||||
h: 'full',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Image
|
|
||||||
draggable={false}
|
|
||||||
src={progressImage.dataURL}
|
|
||||||
width={progressImage.width}
|
|
||||||
height={progressImage.height}
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
objectFit: 'contain',
|
|
||||||
maxWidth: '100%',
|
|
||||||
maxHeight: '100%',
|
|
||||||
height: 'auto',
|
|
||||||
borderRadius: 'base',
|
|
||||||
p: 2,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
) : (
|
|
||||||
<Flex
|
|
||||||
sx={{
|
|
||||||
w: 'full',
|
|
||||||
h: 'full',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon color="base.400" boxSize={32} as={FaImage}></Icon>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Rnd>
|
</Rnd>
|
||||||
)}
|
)}
|
||||||
<IAIIconButton
|
|
||||||
onClick={() =>
|
|
||||||
dispatch(setShouldShowProgressImages(!showProgressWindow))
|
|
||||||
}
|
|
||||||
tooltip={t('ui.showProgressImages')}
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
bottom: 4,
|
|
||||||
insetInlineStart: 4,
|
|
||||||
background: showProgressWindow ? 'accent.600' : 'base.700',
|
|
||||||
_hover: {
|
|
||||||
background: showProgressWindow ? 'accent.500' : 'base.600',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
aria-label={t('ui.showProgressImages')}
|
|
||||||
icon={<FaStopwatch />}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user