[Refactor] Move Comfy.WidgetControlMode to coreSettings (#2078)

This commit is contained in:
Chenlei Hu
2024-12-27 21:06:23 -05:00
committed by GitHub
parent 74361eebe0
commit feabd3f11d
4 changed files with 38 additions and 41 deletions

View File

@@ -67,6 +67,7 @@ import { useCommandStore } from '@/stores/commandStore'
import { useWorkflowService } from '@/services/workflowService'
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
import { useColorPaletteService } from '@/services/colorPaletteService'
import { IS_CONTROL_WIDGET, updateControlWidgetLabel } from '@/scripts/widgets'
const emit = defineEmits(['ready'])
const canvasRef = ref<HTMLCanvasElement | null>(null)
@@ -195,6 +196,23 @@ watchEffect(() => {
LiteGraph.alwaysSnapToGrid = settingStore.get('pysssss.SnapToGrid')
})
watch(settingStore.get('Comfy.WidgetControlMode'), () => {
for (const n of comfyApp.graph.nodes) {
if (!n.widgets) continue
for (const w of n.widgets) {
if (w[IS_CONTROL_WIDGET]) {
updateControlWidgetLabel(w)
if (w.linkedWidgets) {
for (const l of w.linkedWidgets) {
updateControlWidgetLabel(l)
}
}
}
}
}
comfyApp.graph.setDirtyCanvas(true)
})
watchEffect(() => {
if (!canvasStore.canvas) return