Skip to content

Commit

Permalink
fix(ui): fix control image sizes
Browse files Browse the repository at this point in the history
they were all weird
  • Loading branch information
psychedelicious committed Jun 24, 2023
1 parent c9f59e0 commit 36237d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ const ControlNet = (props: ControlNetProps) => {
aspectRatio: '1/1',
}}
>
<ControlNetImagePreview controlNet={props.controlNet} />
<ControlNetImagePreview
controlNet={props.controlNet}
height={24}
/>
</Flex>
)}
</Flex>
Expand All @@ -181,7 +184,7 @@ const ControlNet = (props: ControlNetProps) => {
<Box mt={2}>
<ControlNetImagePreview
controlNet={props.controlNet}
imageSx={expandedControlImageSx}
height={96}
/>
</Box>
<ParamControlNetProcessorSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
controlNetSelector,
} from '../store/controlNetSlice';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { Box, ChakraProps, Flex } from '@chakra-ui/react';
import { Box, Flex, SystemStyleObject } from '@chakra-ui/react';
import IAIDndImage from 'common/components/IAIDndImage';
import { createSelector } from '@reduxjs/toolkit';
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
Expand All @@ -27,11 +27,11 @@ const selector = createSelector(

type Props = {
controlNet: ControlNetConfig;
imageSx?: ChakraProps['sx'];
height: SystemStyleObject['h'];
};

const ControlNetImagePreview = (props: Props) => {
const { imageSx } = props;
const { height } = props;
const {
controlNetId,
controlImage: controlImageName,
Expand Down Expand Up @@ -84,10 +84,6 @@ const ControlNetImagePreview = (props: Props) => {
setIsMouseOverImage(false);
}, []);

const shouldShowProcessedImageBackdrop =
Number(controlImage?.width) > Number(processedControlImage?.width) ||
Number(controlImage?.height) > Number(processedControlImage?.height);

const shouldShowProcessedImage =
controlImage &&
processedControlImage &&
Expand All @@ -96,54 +92,51 @@ const ControlNetImagePreview = (props: Props) => {
processorType !== 'none';

return (
<Box
<Flex
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
sx={{ position: 'relative', w: 'full', h: 'full' }}
sx={{
position: 'relative',
w: 'full',
h: height,
alignItems: 'center',
justifyContent: 'center',
}}
>
<IAIDndImage
image={controlImage}
onDrop={handleDrop}
isDropDisabled={shouldShowProcessedImage}
isDropDisabled={!shouldShowProcessedImage}
isUploadDisabled={Boolean(controlImage)}
postUploadAction={{ type: 'SET_CONTROLNET_IMAGE', controlNetId }}
imageSx={{
pointerEvents: shouldShowProcessedImage ? 'none' : 'auto',
...imageSx,
w: 'full',
h: 'full',
}}
/>
{shouldShowProcessedImage && (
<Box
sx={{
position: 'absolute',
top: 0,
insetInlineStart: 0,
<Box
sx={{
position: 'absolute',
top: 0,
insetInlineStart: 0,
w: 'full',
h: 'full',
opacity: shouldShowProcessedImage ? 1 : 0,
transitionProperty: 'common',
transitionDuration: 'normal',
}}
>
<IAIDndImage
image={processedControlImage}
onDrop={handleDrop}
payloadImage={controlImage}
isUploadDisabled={true}
imageSx={{
w: 'full',
h: 'full',
}}
>
{shouldShowProcessedImageBackdrop && (
<Box
sx={{
position: 'absolute',
top: 0,
insetInlineStart: 0,
w: 'full',
h: 'full',
bg: 'base.900',
opacity: 0.7,
}}
/>
)}
<IAIDndImage
image={processedControlImage}
onDrop={handleDrop}
payloadImage={controlImage}
isUploadDisabled={true}
imageSx={imageSx}
/>
</Box>
)}
/>
</Box>
{pendingControlImages.includes(controlNetId) && (
<Box
sx={{
Expand Down Expand Up @@ -173,7 +166,7 @@ const ControlNetImagePreview = (props: Props) => {
/>
</Flex>
)}
</Box>
</Flex>
);
};

Expand Down

0 comments on commit 36237d6

Please sign in to comment.