mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): hold shift to use control image size w/o model constraints
This commit is contained in:
parent
048bd18e10
commit
1f68a60752
@ -228,7 +228,8 @@
|
|||||||
"scribble": "scribble",
|
"scribble": "scribble",
|
||||||
"selectModel": "Select a model",
|
"selectModel": "Select a model",
|
||||||
"selectCLIPVisionModel": "Select a CLIP Vision model",
|
"selectCLIPVisionModel": "Select a CLIP Vision model",
|
||||||
"setControlImageDimensions": "Set Control Image Dimensions To W/H",
|
"setControlImageDimensions": "Copy size to W/H (optimize for model)",
|
||||||
|
"setControlImageDimensionsForce": "Copy size to W/H (ignore model)",
|
||||||
"showAdvanced": "Show Advanced",
|
"showAdvanced": "Show Advanced",
|
||||||
"small": "Small",
|
"small": "Small",
|
||||||
"toggleControlNet": "Toggle this ControlNet",
|
"toggleControlNet": "Toggle this ControlNet",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { SystemStyleObject } from '@invoke-ai/ui-library';
|
import type { SystemStyleObject } from '@invoke-ai/ui-library';
|
||||||
import { Box, Flex, Spinner } from '@invoke-ai/ui-library';
|
import { Box, Flex, Spinner, useShiftModifier } from '@invoke-ai/ui-library';
|
||||||
import { skipToken } from '@reduxjs/toolkit/query';
|
import { skipToken } from '@reduxjs/toolkit/query';
|
||||||
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
@ -50,6 +50,7 @@ const ControlAdapterImagePreview = ({ isSmall, id }: Props) => {
|
|||||||
const activeTabName = useAppSelector(activeTabNameSelector);
|
const activeTabName = useAppSelector(activeTabNameSelector);
|
||||||
const optimalDimension = useAppSelector(selectOptimalDimension);
|
const optimalDimension = useAppSelector(selectOptimalDimension);
|
||||||
const pendingControlImages = useAppSelector(selectPendingControlImages);
|
const pendingControlImages = useAppSelector(selectPendingControlImages);
|
||||||
|
const shift = useShiftModifier();
|
||||||
|
|
||||||
const [isMouseOverImage, setIsMouseOverImage] = useState(false);
|
const [isMouseOverImage, setIsMouseOverImage] = useState(false);
|
||||||
|
|
||||||
@ -96,14 +97,20 @@ const ControlAdapterImagePreview = ({ isSmall, id }: Props) => {
|
|||||||
if (activeTabName === 'unifiedCanvas') {
|
if (activeTabName === 'unifiedCanvas') {
|
||||||
dispatch(setBoundingBoxDimensions({ width: controlImage.width, height: controlImage.height }, optimalDimension));
|
dispatch(setBoundingBoxDimensions({ width: controlImage.width, height: controlImage.height }, optimalDimension));
|
||||||
} else {
|
} else {
|
||||||
const { width, height } = calculateNewSize(
|
if (shift) {
|
||||||
controlImage.width / controlImage.height,
|
const { width, height } = controlImage;
|
||||||
optimalDimension * optimalDimension
|
dispatch(widthChanged({ width, updateAspectRatio: true }));
|
||||||
);
|
dispatch(heightChanged({ height, updateAspectRatio: true }));
|
||||||
dispatch(widthChanged({ width, updateAspectRatio: true }));
|
} else {
|
||||||
dispatch(heightChanged({ height, updateAspectRatio: true }));
|
const { width, height } = calculateNewSize(
|
||||||
|
controlImage.width / controlImage.height,
|
||||||
|
optimalDimension * optimalDimension
|
||||||
|
);
|
||||||
|
dispatch(widthChanged({ width, updateAspectRatio: true }));
|
||||||
|
dispatch(heightChanged({ height, updateAspectRatio: true }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [controlImage, activeTabName, dispatch, optimalDimension]);
|
}, [controlImage, activeTabName, dispatch, optimalDimension, shift]);
|
||||||
|
|
||||||
const handleMouseEnter = useCallback(() => {
|
const handleMouseEnter = useCallback(() => {
|
||||||
setIsMouseOverImage(true);
|
setIsMouseOverImage(true);
|
||||||
@ -199,7 +206,7 @@ const ControlAdapterImagePreview = ({ isSmall, id }: Props) => {
|
|||||||
<IAIDndImageIcon
|
<IAIDndImageIcon
|
||||||
onClick={handleSetControlImageToDimensions}
|
onClick={handleSetControlImageToDimensions}
|
||||||
icon={controlImage ? <PiRulerBold size={16} /> : undefined}
|
icon={controlImage ? <PiRulerBold size={16} /> : undefined}
|
||||||
tooltip={t('controlnet.setControlImageDimensions')}
|
tooltip={shift ? t('controlnet.setControlImageDimensionsForce') : t('controlnet.setControlImageDimensions')}
|
||||||
styleOverrides={setControlImageDimensionsStyleOverrides}
|
styleOverrides={setControlImageDimensionsStyleOverrides}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user