keep brush size when switch images
This commit is contained in:
parent
774f470e58
commit
1a865810f5
@ -37,6 +37,7 @@ import {
|
||||
} from '../../utils'
|
||||
import {
|
||||
appState,
|
||||
brushSizeState,
|
||||
croperState,
|
||||
enableFileManagerState,
|
||||
fileState,
|
||||
@ -138,7 +139,8 @@ export default function Editor() {
|
||||
|
||||
const [clicks, setClicks] = useRecoilState(interactiveSegClicksState)
|
||||
|
||||
const [brushSize, setBrushSize] = useState(40)
|
||||
const [brushSize, setBrushSize] = useRecoilState(brushSizeState)
|
||||
|
||||
const [original, isOriginalLoaded] = useImage(file)
|
||||
const [renders, setRenders] = useState<HTMLImageElement[]>([])
|
||||
const [context, setContext] = useState<CanvasRenderingContext2D>()
|
||||
@ -1176,7 +1178,7 @@ export default function Editor() {
|
||||
|
||||
// Standard Hotkeys for Brush Size
|
||||
useHotKey('[', () => {
|
||||
setBrushSize(currentBrushSize => {
|
||||
setBrushSize((currentBrushSize: number) => {
|
||||
if (currentBrushSize > 10) {
|
||||
return currentBrushSize - 10
|
||||
}
|
||||
@ -1188,7 +1190,7 @@ export default function Editor() {
|
||||
})
|
||||
|
||||
useHotKey(']', () => {
|
||||
setBrushSize(currentBrushSize => {
|
||||
setBrushSize((currentBrushSize: number) => {
|
||||
return currentBrushSize + 10
|
||||
})
|
||||
})
|
||||
|
@ -48,6 +48,7 @@ interface AppState {
|
||||
showFileManager: boolean
|
||||
enableFileManager: boolean
|
||||
gifImage: HTMLImageElement | undefined
|
||||
brushSize: number
|
||||
}
|
||||
|
||||
export const appState = atom<AppState>({
|
||||
@ -66,6 +67,7 @@ export const appState = atom<AppState>({
|
||||
showFileManager: false,
|
||||
enableFileManager: false,
|
||||
gifImage: undefined,
|
||||
brushSize: 40,
|
||||
},
|
||||
})
|
||||
|
||||
@ -91,6 +93,18 @@ export const isInpaintingState = selector({
|
||||
},
|
||||
})
|
||||
|
||||
export const brushSizeState = selector({
|
||||
key: 'brushSizeState',
|
||||
get: ({ get }) => {
|
||||
const app = get(appState)
|
||||
return app.brushSize
|
||||
},
|
||||
set: ({ get, set }, newValue: any) => {
|
||||
const app = get(appState)
|
||||
set(appState, { ...app, brushSize: newValue })
|
||||
},
|
||||
})
|
||||
|
||||
export const imageHeightState = selector({
|
||||
key: 'imageHeightState',
|
||||
get: ({ get }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user