mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Tweaks to Image Progress Node (#3833)
* Update nodesSlice.ts * Update ProgressImageNode.tsx * remove unused code * Remove Fixed Ratio I was causing issues * fix: Progress Image Node Size --------- Co-authored-by: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com>
This commit is contained in:
parent
94787b7251
commit
23f0c7035c
@ -1,33 +1,46 @@
|
|||||||
import { Flex, Image } from '@chakra-ui/react';
|
import { Flex, Image } from '@chakra-ui/react';
|
||||||
import { NodeProps } from 'reactflow';
|
import { RootState } from 'app/store/store';
|
||||||
import { InvocationValue } from '../types/types';
|
|
||||||
|
|
||||||
import { useAppSelector } from 'app/store/storeHooks';
|
|
||||||
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
|
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { NodeProps, OnResize } from 'reactflow';
|
||||||
|
import { setProgressNodeSize } from '../store/nodesSlice';
|
||||||
import IAINodeHeader from './IAINode/IAINodeHeader';
|
import IAINodeHeader from './IAINode/IAINodeHeader';
|
||||||
import IAINodeResizer from './IAINode/IAINodeResizer';
|
import IAINodeResizer from './IAINode/IAINodeResizer';
|
||||||
import NodeWrapper from './NodeWrapper';
|
import NodeWrapper from './NodeWrapper';
|
||||||
|
|
||||||
const ProgressImageNode = (props: NodeProps<InvocationValue>) => {
|
const ProgressImageNode = (props: NodeProps) => {
|
||||||
const progressImage = useAppSelector((state) => state.system.progressImage);
|
const progressImage = useSelector(
|
||||||
|
(state: RootState) => state.system.progressImage
|
||||||
|
);
|
||||||
|
const progressNodeSize = useSelector(
|
||||||
|
(state: RootState) => state.nodes.progressNodeSize
|
||||||
|
);
|
||||||
|
const dispatch = useDispatch();
|
||||||
const { selected } = props;
|
const { selected } = props;
|
||||||
|
|
||||||
|
const handleResize: OnResize = (_, newSize) => {
|
||||||
|
dispatch(setProgressNodeSize(newSize));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeWrapper selected={selected}>
|
<NodeWrapper selected={selected}>
|
||||||
<IAINodeHeader
|
<IAINodeHeader
|
||||||
title="Progress Image"
|
title="Progress Image"
|
||||||
description="Displays the progress image in the Node Editor"
|
description="Displays the progress image in the Node Editor"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
className="nopan"
|
|
||||||
sx={{
|
sx={{
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
|
flexShrink: 0,
|
||||||
borderBottomRadius: 'md',
|
borderBottomRadius: 'md',
|
||||||
p: 2,
|
|
||||||
bg: 'base.200',
|
bg: 'base.200',
|
||||||
_dark: { bg: 'base.800' },
|
_dark: { bg: 'base.800' },
|
||||||
|
width: progressNodeSize.width - 2,
|
||||||
|
height: progressNodeSize.height - 2,
|
||||||
|
minW: 250,
|
||||||
|
minH: 250,
|
||||||
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{progressImage ? (
|
{progressImage ? (
|
||||||
@ -42,22 +55,17 @@ const ProgressImageNode = (props: NodeProps<InvocationValue>) => {
|
|||||||
) : (
|
) : (
|
||||||
<Flex
|
<Flex
|
||||||
sx={{
|
sx={{
|
||||||
w: 'full',
|
minW: 250,
|
||||||
h: 'full',
|
minH: 250,
|
||||||
minW: 32,
|
width: progressNodeSize.width - 2,
|
||||||
minH: 32,
|
height: progressNodeSize.height - 2,
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IAINoContentFallback />
|
<IAINoContentFallback />
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
<IAINodeResizer
|
<IAINodeResizer onResize={handleResize} />
|
||||||
maxHeight={progressImage?.height ?? 512}
|
|
||||||
maxWidth={progressImage?.width ?? 512}
|
|
||||||
/>
|
|
||||||
</NodeWrapper>
|
</NodeWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -35,6 +35,7 @@ export type NodesState = {
|
|||||||
shouldShowFieldTypeLegend: boolean;
|
shouldShowFieldTypeLegend: boolean;
|
||||||
shouldShowMinimapPanel: boolean;
|
shouldShowMinimapPanel: boolean;
|
||||||
editorInstance: ReactFlowInstance | undefined;
|
editorInstance: ReactFlowInstance | undefined;
|
||||||
|
progressNodeSize: { width: number; height: number };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initialNodesState: NodesState = {
|
export const initialNodesState: NodesState = {
|
||||||
@ -47,6 +48,7 @@ export const initialNodesState: NodesState = {
|
|||||||
shouldShowFieldTypeLegend: false,
|
shouldShowFieldTypeLegend: false,
|
||||||
shouldShowMinimapPanel: true,
|
shouldShowMinimapPanel: true,
|
||||||
editorInstance: undefined,
|
editorInstance: undefined,
|
||||||
|
progressNodeSize: { width: 512, height: 512 },
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodesSlice = createSlice({
|
const nodesSlice = createSlice({
|
||||||
@ -157,6 +159,12 @@ const nodesSlice = createSlice({
|
|||||||
loadFileEdges: (state, action: PayloadAction<Edge[]>) => {
|
loadFileEdges: (state, action: PayloadAction<Edge[]>) => {
|
||||||
state.edges = action.payload;
|
state.edges = action.payload;
|
||||||
},
|
},
|
||||||
|
setProgressNodeSize: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<{ width: number; height: number }>
|
||||||
|
) => {
|
||||||
|
state.progressNodeSize = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(receivedOpenAPISchema.fulfilled, (state, action) => {
|
builder.addCase(receivedOpenAPISchema.fulfilled, (state, action) => {
|
||||||
@ -182,6 +190,7 @@ export const {
|
|||||||
setEditorInstance,
|
setEditorInstance,
|
||||||
loadFileNodes,
|
loadFileNodes,
|
||||||
loadFileEdges,
|
loadFileEdges,
|
||||||
|
setProgressNodeSize,
|
||||||
} = nodesSlice.actions;
|
} = nodesSlice.actions;
|
||||||
|
|
||||||
export default nodesSlice.reducer;
|
export default nodesSlice.reducer;
|
||||||
|
Loading…
Reference in New Issue
Block a user