mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): recall/use size sets aspect ratio correctly
Added a new action that resets the aspect ratio when dispatched. Closes #5456
This commit is contained in:
parent
52b24e01e2
commit
52b51a6088
@ -34,7 +34,7 @@ import {
|
|||||||
modelSelected,
|
modelSelected,
|
||||||
} from 'features/parameters/store/actions';
|
} from 'features/parameters/store/actions';
|
||||||
import {
|
import {
|
||||||
heightChanged,
|
heightRecalled,
|
||||||
selectGenerationSlice,
|
selectGenerationSlice,
|
||||||
setCfgRescaleMultiplier,
|
setCfgRescaleMultiplier,
|
||||||
setCfgScale,
|
setCfgScale,
|
||||||
@ -45,7 +45,7 @@ import {
|
|||||||
setSeed,
|
setSeed,
|
||||||
setSteps,
|
setSteps,
|
||||||
vaeSelected,
|
vaeSelected,
|
||||||
widthChanged,
|
widthRecalled,
|
||||||
} from 'features/parameters/store/generationSlice';
|
} from 'features/parameters/store/generationSlice';
|
||||||
import type { ParameterModel } from 'features/parameters/types/parameterSchemas';
|
import type { ParameterModel } from 'features/parameters/types/parameterSchemas';
|
||||||
import {
|
import {
|
||||||
@ -373,7 +373,7 @@ export const useRecallParameters = () => {
|
|||||||
parameterNotSetToast();
|
parameterNotSetToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(widthChanged(width));
|
dispatch(widthRecalled(width));
|
||||||
parameterSetToast();
|
parameterSetToast();
|
||||||
},
|
},
|
||||||
[dispatch, parameterSetToast, parameterNotSetToast]
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
@ -388,7 +388,7 @@ export const useRecallParameters = () => {
|
|||||||
parameterNotSetToast();
|
parameterNotSetToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(heightChanged(height));
|
dispatch(heightRecalled(height));
|
||||||
parameterSetToast();
|
parameterSetToast();
|
||||||
},
|
},
|
||||||
[dispatch, parameterSetToast, parameterNotSetToast]
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
@ -407,8 +407,8 @@ export const useRecallParameters = () => {
|
|||||||
allParameterNotSetToast();
|
allParameterNotSetToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(heightChanged(height));
|
dispatch(heightRecalled(height));
|
||||||
dispatch(widthChanged(width));
|
dispatch(widthRecalled(width));
|
||||||
allParameterSetToast();
|
allParameterSetToast();
|
||||||
},
|
},
|
||||||
[dispatch, allParameterSetToast, allParameterNotSetToast]
|
[dispatch, allParameterSetToast, allParameterNotSetToast]
|
||||||
@ -893,11 +893,11 @@ export const useRecallParameters = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isParameterWidth(width)) {
|
if (isParameterWidth(width)) {
|
||||||
dispatch(widthChanged(width));
|
dispatch(widthRecalled(width));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isParameterHeight(height)) {
|
if (isParameterHeight(height)) {
|
||||||
dispatch(heightChanged(height));
|
dispatch(heightRecalled(height));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isParameterStrength(strength)) {
|
if (isParameterStrength(strength)) {
|
||||||
|
@ -230,6 +230,18 @@ export const generationSlice = createSlice({
|
|||||||
heightChanged: (state, action: PayloadAction<number>) => {
|
heightChanged: (state, action: PayloadAction<number>) => {
|
||||||
state.height = action.payload;
|
state.height = action.payload;
|
||||||
},
|
},
|
||||||
|
widthRecalled: (state, action: PayloadAction<number>) => {
|
||||||
|
state.width = action.payload;
|
||||||
|
state.aspectRatio.value = action.payload / state.height;
|
||||||
|
state.aspectRatio.id = 'Free';
|
||||||
|
state.aspectRatio.isLocked = false;
|
||||||
|
},
|
||||||
|
heightRecalled: (state, action: PayloadAction<number>) => {
|
||||||
|
state.height = action.payload;
|
||||||
|
state.aspectRatio.value = state.width / action.payload;
|
||||||
|
state.aspectRatio.id = 'Free';
|
||||||
|
state.aspectRatio.isLocked = false;
|
||||||
|
},
|
||||||
aspectRatioChanged: (state, action: PayloadAction<AspectRatioState>) => {
|
aspectRatioChanged: (state, action: PayloadAction<AspectRatioState>) => {
|
||||||
state.aspectRatio = action.payload;
|
state.aspectRatio = action.payload;
|
||||||
},
|
},
|
||||||
@ -306,6 +318,8 @@ export const {
|
|||||||
aspectRatioChanged,
|
aspectRatioChanged,
|
||||||
widthChanged,
|
widthChanged,
|
||||||
heightChanged,
|
heightChanged,
|
||||||
|
widthRecalled,
|
||||||
|
heightRecalled,
|
||||||
} = generationSlice.actions;
|
} = generationSlice.actions;
|
||||||
|
|
||||||
export const { selectOptimalDimension } = generationSlice.selectors;
|
export const { selectOptimalDimension } = generationSlice.selectors;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user