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