mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 01:20:03 +00:00
## Summary Add a setting to select all children (nodes, reroutes, nested groups) when clicking a group on the canvas. ## Changes - **What**: New `LiteGraph.Group.SelectChildrenOnClick` boolean setting (default: `false`). When enabled, selecting a group cascades `select()` to all its `_children`, and deselecting cascades `deselect()`. Recursion handles nested groups naturally. No double-move risk — the drag handler already uses `skipChildren=true`. The setting is wired via `onChange` to `canvas.groupSelectChildren`, keeping litegraph free of platform imports. ## Review Focus - The select/deselect cascading in `LGraphCanvas.select()` / `deselect()` — verify no infinite recursion risk with deeply nested groups. - The `groupSelectChildren` property is set via the setting's `onChange` callback on `LGraphCanvas.active_canvas` — confirm this covers canvas re-creation scenarios. ## Screenshots (if applicable) N/A — behavioral change behind a setting toggle. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9149-feat-select-group-children-on-click-3116d73d365081a1a7b8c82dea95b242) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com>
174 lines
4.5 KiB
TypeScript
174 lines
4.5 KiB
TypeScript
import { watchEffect } from 'vue'
|
|
|
|
import {
|
|
CanvasPointer,
|
|
LGraphNode,
|
|
LiteGraph
|
|
} from '@/lib/litegraph/src/litegraph'
|
|
import { useSettingStore } from '@/platform/settings/settingStore'
|
|
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
|
|
|
/**
|
|
* Watch for changes in the setting store and update the LiteGraph settings accordingly.
|
|
*/
|
|
export const useLitegraphSettings = () => {
|
|
const settingStore = useSettingStore()
|
|
const canvasStore = useCanvasStore()
|
|
|
|
watchEffect(() => {
|
|
const canvasInfoEnabled = settingStore.get('Comfy.Graph.CanvasInfo')
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.show_info = canvasInfoEnabled
|
|
canvasStore.canvas.draw(false, true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const zoomSpeed = settingStore.get('Comfy.Graph.ZoomSpeed')
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.zoom_speed = zoomSpeed
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.snaps_for_comfy = settingStore.get(
|
|
'Comfy.Node.AutoSnapLinkToSlot'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.snap_highlights_node = settingStore.get(
|
|
'Comfy.Node.SnapHighlightsNode'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LGraphNode.keepAllLinksOnBypass = settingStore.get(
|
|
'Comfy.Node.BypassAllLinksOnDelete'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.middle_click_slot_add_default_node = settingStore.get(
|
|
'Comfy.Node.MiddleClickRerouteNode'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const linkRenderMode = settingStore.get('Comfy.LinkRenderMode')
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.links_render_mode = linkRenderMode
|
|
canvasStore.canvas.setDirty(/* fg */ false, /* bg */ true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const minFontSizeForLOD = settingStore.get(
|
|
'LiteGraph.Canvas.MinFontSizeForLOD'
|
|
)
|
|
if (canvasStore.canvas) {
|
|
canvasStore.canvas.min_font_size_for_lod = minFontSizeForLOD
|
|
canvasStore.canvas.setDirty(/* fg */ true, /* bg */ true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const linkMarkerShape = settingStore.get('Comfy.Graph.LinkMarkers')
|
|
const { canvas } = canvasStore
|
|
if (canvas) {
|
|
canvas.linkMarkerShape = linkMarkerShape
|
|
canvas.setDirty(false, true)
|
|
}
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const maximumFps = settingStore.get('LiteGraph.Canvas.MaximumFps')
|
|
const { canvas } = canvasStore
|
|
if (canvas) canvas.maximumFps = maximumFps
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const dragZoomEnabled = settingStore.get('Comfy.Graph.CtrlShiftZoom')
|
|
const { canvas } = canvasStore
|
|
if (canvas) canvas.dragZoomEnabled = dragZoomEnabled
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const liveSelection = settingStore.get('Comfy.Graph.LiveSelection')
|
|
const { canvas } = canvasStore
|
|
if (canvas) canvas.liveSelection = liveSelection
|
|
})
|
|
|
|
watchEffect(() => {
|
|
CanvasPointer.doubleClickTime = settingStore.get(
|
|
'Comfy.Pointer.DoubleClickTime'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
CanvasPointer.bufferTime = settingStore.get('Comfy.Pointer.ClickBufferTime')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
CanvasPointer.maxClickDrift = settingStore.get('Comfy.Pointer.ClickDrift')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.CANVAS_GRID_SIZE = settingStore.get('Comfy.SnapToGrid.GridSize')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.alwaysSnapToGrid = settingStore.get('pysssss.SnapToGrid')
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.context_menu_scaling = settingStore.get(
|
|
'LiteGraph.ContextMenu.Scaling'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.Reroute.maxSplineOffset = settingStore.get(
|
|
'LiteGraph.Reroute.SplineOffset'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const navigationMode = settingStore.get('Comfy.Canvas.NavigationMode') as
|
|
| 'standard'
|
|
| 'legacy'
|
|
| 'custom'
|
|
|
|
LiteGraph.canvasNavigationMode = navigationMode
|
|
LiteGraph.macTrackpadGestures = navigationMode === 'standard'
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const leftMouseBehavior = settingStore.get(
|
|
'Comfy.Canvas.LeftMouseClickBehavior'
|
|
) as 'panning' | 'select'
|
|
LiteGraph.leftMouseClickBehavior = leftMouseBehavior
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const mouseWheelScroll = settingStore.get(
|
|
'Comfy.Canvas.MouseWheelScroll'
|
|
) as 'panning' | 'zoom'
|
|
LiteGraph.mouseWheelScroll = mouseWheelScroll
|
|
})
|
|
|
|
watchEffect(() => {
|
|
LiteGraph.saveViewportWithGraph = settingStore.get(
|
|
'Comfy.EnableWorkflowViewRestore'
|
|
)
|
|
})
|
|
|
|
watchEffect(() => {
|
|
const selectChildren = settingStore.get(
|
|
'LiteGraph.Group.SelectChildrenOnClick'
|
|
)
|
|
if (canvasStore.canvas)
|
|
canvasStore.canvas.groupSelectChildren = selectChildren
|
|
})
|
|
}
|