fix(ui): h/w disabled bug

This commit is contained in:
psychedelicious 2023-05-10 14:26:36 +10:00
parent 31a78d571b
commit b42b630583
3 changed files with 29 additions and 40 deletions

View File

@ -1,6 +1,6 @@
import { createSelector } from '@reduxjs/toolkit';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAISlider from 'common/components/IAISlider';
import IAISlider, { IAIFullSliderProps } from 'common/components/IAISlider';
import { generationSelector } from 'features/parameters/store/generationSelectors';
import { setHeight } from 'features/parameters/store/generationSlice';
import { configSelector } from 'features/system/store/configSelectors';
@ -13,8 +13,7 @@ const selector = createSelector(
(generation, hotkeys, config) => {
const { initial, min, sliderMax, inputMax, fineStep, coarseStep } =
config.sd.height;
const { height, shouldFitToWidthHeight, isImageToImageEnabled } =
generation;
const { height } = generation;
const step = hotkeys.shift ? fineStep : coarseStep;
@ -25,23 +24,18 @@ const selector = createSelector(
sliderMax,
inputMax,
step,
shouldFitToWidthHeight,
isImageToImageEnabled,
};
}
);
const ParamHeight = () => {
const {
height,
initial,
min,
sliderMax,
inputMax,
step,
shouldFitToWidthHeight,
isImageToImageEnabled,
} = useAppSelector(selector);
type ParamHeightProps = Omit<
IAIFullSliderProps,
'label' | 'value' | 'onChange'
>;
const ParamHeight = (props: ParamHeightProps) => {
const { height, initial, min, sliderMax, inputMax, step } =
useAppSelector(selector);
const dispatch = useAppDispatch();
const { t } = useTranslation();
@ -58,7 +52,6 @@ const ParamHeight = () => {
return (
<IAISlider
isDisabled={!shouldFitToWidthHeight && isImageToImageEnabled}
label={t('parameters.height')}
value={height}
min={min}
@ -70,6 +63,7 @@ const ParamHeight = () => {
withReset
withSliderMarks
sliderNumberInputProps={{ max: inputMax }}
{...props}
/>
);
};

View File

@ -1,6 +1,7 @@
import { createSelector } from '@reduxjs/toolkit';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAISlider from 'common/components/IAISlider';
import { IAIFullSliderProps } from 'common/components/IAISlider';
import { generationSelector } from 'features/parameters/store/generationSelectors';
import { setWidth } from 'features/parameters/store/generationSlice';
import { configSelector } from 'features/system/store/configSelectors';
@ -13,7 +14,7 @@ const selector = createSelector(
(generation, hotkeys, config) => {
const { initial, min, sliderMax, inputMax, fineStep, coarseStep } =
config.sd.width;
const { width, shouldFitToWidthHeight, isImageToImageEnabled } = generation;
const { width } = generation;
const step = hotkeys.shift ? fineStep : coarseStep;
@ -24,23 +25,15 @@ const selector = createSelector(
sliderMax,
inputMax,
step,
shouldFitToWidthHeight,
isImageToImageEnabled,
};
}
);
const ParamWidth = () => {
const {
width,
initial,
min,
sliderMax,
inputMax,
step,
shouldFitToWidthHeight,
isImageToImageEnabled,
} = useAppSelector(selector);
type ParamWidthProps = Omit<IAIFullSliderProps, 'label' | 'value' | 'onChange'>;
const ParamWidth = (props: ParamWidthProps) => {
const { width, initial, min, sliderMax, inputMax, step } =
useAppSelector(selector);
const dispatch = useAppDispatch();
const { t } = useTranslation();
@ -57,7 +50,6 @@ const ParamWidth = () => {
return (
<IAISlider
isDisabled={!shouldFitToWidthHeight && isImageToImageEnabled}
label={t('parameters.width')}
value={width}
min={min}
@ -69,6 +61,7 @@ const ParamWidth = () => {
withReset
withSliderMarks
sliderNumberInputProps={{ max: inputMax }}
{...props}
/>
);
};

View File

@ -13,19 +13,21 @@ import ParamSampler from 'features/parameters/components/Parameters/Core/ParamSa
import ModelSelect from 'features/system/components/ModelSelect';
import ImageToImageStrength from 'features/parameters/components/Parameters/ImageToImage/ImageToImageStrength';
import ImageToImageFit from 'features/parameters/components/Parameters/ImageToImage/ImageToImageFit';
import { generationSelector } from 'features/parameters/store/generationSelectors';
const selector = createSelector(
uiSelector,
(ui) => {
[uiSelector, generationSelector],
(ui, generation) => {
const { shouldUseSliders } = ui;
const { shouldFitToWidthHeight } = generation;
return { shouldUseSliders };
return { shouldUseSliders, shouldFitToWidthHeight };
},
defaultSelectorOptions
);
const ImageToImageTabCoreParameters = () => {
const { shouldUseSliders } = useAppSelector(selector);
const { shouldUseSliders, shouldFitToWidthHeight } = useAppSelector(selector);
return (
<Flex
@ -42,8 +44,8 @@ const ImageToImageTabCoreParameters = () => {
<ParamIterations />
<ParamSteps />
<ParamCFGScale />
<ParamWidth />
<ParamHeight />
<ParamWidth isDisabled={!shouldFitToWidthHeight} />
<ParamHeight isDisabled={!shouldFitToWidthHeight} />
<ImageToImageStrength />
<ImageToImageFit />
<Flex gap={3} w="full">
@ -62,8 +64,8 @@ const ImageToImageTabCoreParameters = () => {
<ParamSteps />
<ParamCFGScale />
</Flex>
<ParamWidth />
<ParamHeight />
<ParamWidth isDisabled={!shouldFitToWidthHeight} />
<ParamHeight isDisabled={!shouldFitToWidthHeight} />
<Flex gap={3} w="full">
<Box flexGrow={2}>
<ParamSampler />