Qing
2024-08-21 21:50:13 +08:00
parent 04c031e10a
commit 728f96c0e7
2 changed files with 28 additions and 2 deletions

View File

@@ -30,7 +30,11 @@ import Cropper from "./Cropper"
import { InteractiveSegPoints } from "./InteractiveSeg" import { InteractiveSegPoints } from "./InteractiveSeg"
import useHotKey from "@/hooks/useHotkey" import useHotKey from "@/hooks/useHotkey"
import Extender from "./Extender" import Extender from "./Extender"
import { MAX_BRUSH_SIZE, MIN_BRUSH_SIZE } from "@/lib/const" import {
MAX_BRUSH_SIZE,
MIN_BRUSH_SIZE,
SHORTCUT_KEY_CHANGE_BRUSH_SIZE,
} from "@/lib/const"
const TOOLBAR_HEIGHT = 200 const TOOLBAR_HEIGHT = 200
const COMPARE_SLIDER_DURATION_MS = 300 const COMPARE_SLIDER_DURATION_MS = 300
@@ -657,8 +661,28 @@ export default function Editor(props: EditorProps) {
} }
) )
useEffect(() => {
const handleKeyUp = (ev: KeyboardEvent) => {
if (ev.key === SHORTCUT_KEY_CHANGE_BRUSH_SIZE) {
setIsChangingBrushSizeByWheel(false)
}
}
const handleBlur = () => {
setIsChangingBrushSizeByWheel(false)
}
window.addEventListener("keyup", handleKeyUp)
window.addEventListener("blur", handleBlur)
return () => {
window.removeEventListener("keyup", handleKeyUp)
window.removeEventListener("blur", handleBlur)
}
}, [])
useKeyPressEvent( useKeyPressEvent(
"Alt", SHORTCUT_KEY_CHANGE_BRUSH_SIZE,
(ev) => { (ev) => {
if (!disableShortCuts) { if (!disableShortCuts) {
ev?.preventDefault() ev?.preventDefault()

View File

@@ -21,3 +21,5 @@ export const ANYTEXT = "Sanster/AnyText"
export const DEFAULT_NEGATIVE_PROMPT = export const DEFAULT_NEGATIVE_PROMPT =
"out of frame, lowres, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, disfigured, gross proportions, malformed limbs, watermark, signature" "out of frame, lowres, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, disfigured, gross proportions, malformed limbs, watermark, signature"
export const SHORTCUT_KEY_CHANGE_BRUSH_SIZE = "Alt"