mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: Add Set Control Image Width / Height to User Settings
This commit is contained in:
parent
cff391aa1d
commit
2469859c01
@ -5,12 +5,15 @@ import { stateSelector } from 'app/store/store';
|
||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||
import IAIDndImage from 'common/components/IAIDndImage';
|
||||
import { setBoundingBoxDimensions } from 'features/canvas/store/canvasSlice';
|
||||
import {
|
||||
TypesafeDraggableData,
|
||||
TypesafeDroppableData,
|
||||
} from 'features/dnd/types';
|
||||
import { setHeight, setWidth } from 'features/parameters/store/generationSlice';
|
||||
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
||||
import { memo, useCallback, useMemo, useState } from 'react';
|
||||
import { FaSave, FaUndo } from 'react-icons/fa';
|
||||
import { FaRulerVertical, FaSave, FaUndo } from 'react-icons/fa';
|
||||
import {
|
||||
useAddImageToBoardMutation,
|
||||
useChangeImageIsIntermediateMutation,
|
||||
@ -54,6 +57,7 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const { pendingControlImages, autoAddBoardId } = useAppSelector(selector);
|
||||
const activeTabName = useAppSelector(activeTabNameSelector);
|
||||
|
||||
const [isMouseOverImage, setIsMouseOverImage] = useState(false);
|
||||
|
||||
@ -85,6 +89,24 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
|
||||
addToBoard({ imageDTO: processedControlImage, board_id: autoAddBoardId });
|
||||
}, [processedControlImage, autoAddBoardId, changeIsIntermediate, addToBoard]);
|
||||
|
||||
const handleSetControlImageToDimensions = useCallback(() => {
|
||||
if (!processedControlImage) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeTabName === 'unifiedCanvas') {
|
||||
dispatch(
|
||||
setBoundingBoxDimensions({
|
||||
width: processedControlImage.width,
|
||||
height: processedControlImage.height,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
dispatch(setWidth(processedControlImage.width));
|
||||
dispatch(setHeight(processedControlImage.height));
|
||||
}
|
||||
}, [processedControlImage, activeTabName, dispatch]);
|
||||
|
||||
const handleMouseEnter = useCallback(() => {
|
||||
setIsMouseOverImage(true);
|
||||
}, []);
|
||||
@ -157,6 +179,12 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
|
||||
tooltip="Save Control Image"
|
||||
styleOverrides={{ marginTop: 6 }}
|
||||
/>
|
||||
<IAIDndImageIcon
|
||||
onClick={handleSetControlImageToDimensions}
|
||||
icon={controlImage ? <FaRulerVertical size={16} /> : undefined}
|
||||
tooltip="Set Control Image Dimensions To W/H"
|
||||
styleOverrides={{ marginTop: 12 }}
|
||||
/>
|
||||
</>
|
||||
</IAIDndImage>
|
||||
|
||||
@ -192,6 +220,12 @@ const ControlNetImagePreview = ({ isSmall, controlNet }: Props) => {
|
||||
tooltip="Save Control Image"
|
||||
styleOverrides={{ marginTop: 6 }}
|
||||
/>
|
||||
<IAIDndImageIcon
|
||||
onClick={handleSetControlImageToDimensions}
|
||||
icon={controlImage ? <FaRulerVertical size={16} /> : undefined}
|
||||
tooltip="Set Control Image Dimensions To W/H"
|
||||
styleOverrides={{ marginTop: 12 }}
|
||||
/>
|
||||
</>
|
||||
</IAIDndImage>
|
||||
</Box>
|
||||
|
Loading…
Reference in New Issue
Block a user