mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-07 14:09:59 +00:00
Litegraph Reroute Beta (#1421)
* Add Reroute support - ConnectingLinkImpl Bonus: TS strict * Add Reroute support * Remove unused TS expect error * Add reroute beta opt-in option * Add settings option: Middle-click reroute node * Add settings: Link Markers * Move settings * Update litegraph --------- Co-authored-by: huchenlei <huchenlei@proton.me>
This commit is contained in:
@@ -104,6 +104,12 @@ watchEffect(() => {
|
||||
)
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
LiteGraph.middle_click_slot_add_default_node = settingStore.get(
|
||||
'Comfy.Node.MiddleClickRerouteNode'
|
||||
)
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
nodeDefStore.showDeprecated = settingStore.get('Comfy.Node.ShowDeprecated')
|
||||
})
|
||||
@@ -134,6 +140,24 @@ watchEffect(() => {
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
const linkMarkerShape = settingStore.get('Comfy.Graph.LinkMarkers')
|
||||
const { canvas } = canvasStore
|
||||
if (canvas) {
|
||||
canvas.linkMarkerShape = linkMarkerShape
|
||||
canvas.setDirty(false, true)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
const reroutesEnabled = settingStore.get('Comfy.RerouteBeta')
|
||||
const { canvas } = canvasStore
|
||||
if (canvas) {
|
||||
canvas.reroutesEnabled = reroutesEnabled
|
||||
canvas.setDirty(false, true)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
if (!canvasStore.canvas) return
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ const getNewNodeLocation = (): [number, number] => {
|
||||
}
|
||||
|
||||
const originalEvent = triggerEvent.value.detail.originalEvent
|
||||
// @ts-expect-error LiteGraph types are not typed
|
||||
return [originalEvent.canvasX, originalEvent.canvasY]
|
||||
}
|
||||
const nodeFilters = ref<FilterAndValue[]>([])
|
||||
@@ -153,8 +152,16 @@ const showContextMenu = (e: LiteGraphCanvasEvent) => {
|
||||
showSearchBox: () => showSearchBox(e)
|
||||
}
|
||||
const connectionOptions = firstLink.output
|
||||
? { nodeFrom: firstLink.node, slotFrom: firstLink.output }
|
||||
: { nodeTo: firstLink.node, slotTo: firstLink.input }
|
||||
? {
|
||||
nodeFrom: firstLink.node,
|
||||
slotFrom: firstLink.output,
|
||||
afterRerouteId: firstLink.afterRerouteId
|
||||
}
|
||||
: {
|
||||
nodeTo: firstLink.node,
|
||||
slotTo: firstLink.input,
|
||||
afterRerouteId: firstLink.afterRerouteId
|
||||
}
|
||||
canvasStore.canvas.showConnectionMenu({
|
||||
...connectionOptions,
|
||||
...commonOptions
|
||||
@@ -178,7 +185,6 @@ const canvasEventHandler = (e: LiteGraphCanvasEvent) => {
|
||||
} else if (e.detail.subType === 'group-double-click') {
|
||||
const group = e.detail.group
|
||||
const [x, y] = group.pos
|
||||
// @ts-expect-error LiteGraphCanvasEvent is not typed
|
||||
const relativeY = e.detail.originalEvent.canvasY - y
|
||||
// Show search box if the click is NOT on the title bar
|
||||
if (relativeY > group.titleHeight) {
|
||||
|
||||
Reference in New Issue
Block a user