add rerun last mask button

This commit is contained in:
Qing
2023-02-19 15:05:41 +08:00
parent 1a865810f5
commit 183334f8f7
4 changed files with 88 additions and 35 deletions

View File

@@ -63,6 +63,7 @@ import emitter, {
EVENT_PROMPT,
EVENT_CUSTOM_MASK,
EVENT_PAINT_BY_EXAMPLE,
RERUN_LAST_MASK,
} from '../../event'
import FileSelect from '../FileSelect/FileSelect'
import InteractiveSeg from '../InteractiveSeg/InteractiveSeg'
@@ -515,6 +516,28 @@ export default function Editor() {
}
}, [runInpainting])
useEffect(() => {
emitter.on(RERUN_LAST_MASK, () => {
if (lastLineGroup.length !== 0) {
// 使用上一次手绘的 mask 生成
runInpainting(true, undefined, prevInteractiveSegMask)
} else if (prevInteractiveSegMask) {
// 使用上一次 IS 的 mask 生成
runInpainting(false, undefined, prevInteractiveSegMask)
} else {
setToastState({
open: true,
desc: 'No mask to reuse',
state: 'error',
duration: 1500,
})
}
})
return () => {
emitter.off(RERUN_LAST_MASK)
}
}, [runInpainting])
const hadRunInpainting = () => {
return renders.length !== 0
}