mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add ui for cpu noise
not hooked up to graphs
This commit is contained in:
parent
2bc99f5b6c
commit
0138f52220
@ -0,0 +1,39 @@
|
|||||||
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
import { stateSelector } from 'app/store/store';
|
||||||
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
|
import IAISwitch from 'common/components/IAISwitch';
|
||||||
|
import { shouldUseCpuNoiseChanged } from 'features/parameters/store/generationSlice';
|
||||||
|
import { ChangeEvent } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
const selector = createSelector(
|
||||||
|
stateSelector,
|
||||||
|
(state) => {
|
||||||
|
const { shouldUseNoiseSettings, shouldUseCpuNoise } = state.generation;
|
||||||
|
return {
|
||||||
|
isDisabled: !shouldUseNoiseSettings,
|
||||||
|
shouldUseCpuNoise,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
defaultSelectorOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ParamCpuNoiseToggle = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const { isDisabled, shouldUseCpuNoise } = useAppSelector(selector);
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
dispatch(shouldUseCpuNoiseChanged(e.target.checked));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IAISwitch
|
||||||
|
isDisabled={isDisabled}
|
||||||
|
label="Use CPU Noise"
|
||||||
|
isChecked={shouldUseCpuNoise}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
@ -7,6 +7,7 @@ import IAICollapse from 'common/components/IAICollapse';
|
|||||||
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { ParamCpuNoiseToggle } from './ParamCpuNoise';
|
||||||
import ParamNoiseThreshold from './ParamNoiseThreshold';
|
import ParamNoiseThreshold from './ParamNoiseThreshold';
|
||||||
import { ParamNoiseToggle } from './ParamNoiseToggle';
|
import { ParamNoiseToggle } from './ParamNoiseToggle';
|
||||||
import ParamPerlinNoise from './ParamPerlinNoise';
|
import ParamPerlinNoise from './ParamPerlinNoise';
|
||||||
@ -40,6 +41,7 @@ const ParamNoiseCollapse = () => {
|
|||||||
>
|
>
|
||||||
<Flex sx={{ gap: 2, flexDirection: 'column' }}>
|
<Flex sx={{ gap: 2, flexDirection: 'column' }}>
|
||||||
<ParamNoiseToggle />
|
<ParamNoiseToggle />
|
||||||
|
<ParamCpuNoiseToggle />
|
||||||
<ParamPerlinNoise />
|
<ParamPerlinNoise />
|
||||||
<ParamNoiseThreshold />
|
<ParamNoiseThreshold />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -55,6 +55,7 @@ export interface GenerationState {
|
|||||||
seamlessXAxis: boolean;
|
seamlessXAxis: boolean;
|
||||||
seamlessYAxis: boolean;
|
seamlessYAxis: boolean;
|
||||||
clipSkip: number;
|
clipSkip: number;
|
||||||
|
shouldUseCpuNoise: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialGenerationState: GenerationState = {
|
export const initialGenerationState: GenerationState = {
|
||||||
@ -90,6 +91,7 @@ export const initialGenerationState: GenerationState = {
|
|||||||
seamlessXAxis: false,
|
seamlessXAxis: false,
|
||||||
seamlessYAxis: false,
|
seamlessYAxis: false,
|
||||||
clipSkip: 0,
|
clipSkip: 0,
|
||||||
|
shouldUseCpuNoise: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState: GenerationState = initialGenerationState;
|
const initialState: GenerationState = initialGenerationState;
|
||||||
@ -239,6 +241,9 @@ export const generationSlice = createSlice({
|
|||||||
setClipSkip: (state, action: PayloadAction<number>) => {
|
setClipSkip: (state, action: PayloadAction<number>) => {
|
||||||
state.clipSkip = action.payload;
|
state.clipSkip = action.payload;
|
||||||
},
|
},
|
||||||
|
shouldUseCpuNoiseChanged: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.shouldUseCpuNoise = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addCase(configChanged, (state, action) => {
|
builder.addCase(configChanged, (state, action) => {
|
||||||
@ -298,6 +303,7 @@ export const {
|
|||||||
setSeamlessXAxis,
|
setSeamlessXAxis,
|
||||||
setSeamlessYAxis,
|
setSeamlessYAxis,
|
||||||
setClipSkip,
|
setClipSkip,
|
||||||
|
shouldUseCpuNoiseChanged,
|
||||||
} = generationSlice.actions;
|
} = generationSlice.actions;
|
||||||
|
|
||||||
export default generationSlice.reducer;
|
export default generationSlice.reducer;
|
||||||
|
Loading…
Reference in New Issue
Block a user