diff --git a/src/LGraph.ts b/src/LGraph.ts index 900a8547e..d74bf2e06 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -137,7 +137,6 @@ export class LGraph implements LinkNetwork, Serialisable { onExecuteStep?(): void onNodeAdded?(node: LGraphNode): void onNodeRemoved?(node: LGraphNode): void - onNodeUpdated?(node: LGraphNode): void onTrigger?(action: string, param: unknown): void onInputRenamed?(old_name: string, name: string): void onInputTypeChanged?(name: string, type: string): void @@ -146,8 +145,8 @@ export class LGraph implements LinkNetwork, Serialisable { onOutputRenamed?(old_name: string, name: string): void onOutputTypeChanged?(name: string, type: string): void onOutputRemoved?(name: string): void - onBeforeChange?(graph: LGraph, node?: LGraphNode): void - onAfterChange?(graph: LGraph, node?: LGraphNode): void + onBeforeChange?(graph: LGraph, info?: LGraphNode): void + onAfterChange?(graph: LGraph, info?: LGraphNode): void onConnectionChange?(node: LGraphNode): void on_change?(graph: LGraph): void onSerialize?(data: ISerialisedGraph | SerialisableGraph): void @@ -1206,19 +1205,15 @@ export class LGraph implements LinkNetwork, Serialisable { } } //used for undo, called before any change is made to the graph - beforeChange(node?: LGraphNode): void { - this.onBeforeChange?.(this, node) + beforeChange(info?: LGraphNode): void { + this.onBeforeChange?.(this, info) this.canvasAction(c => c.onBeforeChange?.(this)) } //used to resend actions, called after any change is made to the graph - afterChange(node?: LGraphNode): void { - this.onAfterChange?.(this, node) + afterChange(info?: LGraphNode): void { + this.onAfterChange?.(this, info) this.canvasAction(c => c.onAfterChange?.(this)) } - nodeUpdate(node?: LGraphNode): void { - this.onNodeUpdated?.(node) - this.canvasAction(c => c.onNodeUpdated?.(node)) - } connectionChange(node: LGraphNode): void { this.updateExecutionOrder() this.onConnectionChange?.(node) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index da536a51a..527112656 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -370,8 +370,6 @@ export class LGraphCanvas { onBeforeChange?(graph: LGraph): void /** called after modifying the graph */ onAfterChange?(graph: LGraph): void - onPositionChanged?: (offset: Point) => void - onZoomChanged?: (scale: number) => void onClear?: () => void /** called after moving a node */ onNodeMoved?: (node_dragged: LGraphNode) => void @@ -386,8 +384,6 @@ export class LGraphCanvas { onShowNodePanel?: (n: LGraphNode) => void onNodeSelected?: (node: LGraphNode) => void onNodeDeselected?: (node: LGraphNode) => void - onNodeUpdated?: (node: LGraphNode) => void - onNodeWidgetChanged?: (node: LGraphNode, name: string, value: unknown, widget: IWidget) => void onRender?: (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D) => void /** Implement this function to allow conversion of widget types to input types, e.g. number -> INT or FLOAT for widget link validation checks */ getWidgetLinkType?: (widget: IWidget, node: LGraphNode) => string | null | undefined @@ -2361,10 +2357,6 @@ export class LGraphCanvas { this.ds.offset[0] += delta[0] / this.ds.scale this.ds.offset[1] += delta[1] / this.ds.scale this.#dirty() - - if (this.onPositionChanged) { - this.onPositionChanged(this.ds.offset) - } } else if ((this.allow_interaction || (node && node.flags.allow_interaction)) && !this.read_only) { if (this.connecting_links) this.dirty_canvas = true @@ -2808,14 +2800,6 @@ export class LGraphCanvas { this.ds.changeScale(scale, [e.clientX, e.clientY]) - if (this.onZoomChanged) { - this.onZoomChanged(scale) - } - - if (this.onPositionChanged) { - this.onPositionChanged(this.ds.offset) - } - this.graph.change() e.preventDefault() @@ -3510,10 +3494,6 @@ export class LGraphCanvas { node.size[1] * 0.5 + (this.canvas.height * 0.5) / (this.ds.scale * dpi) this.setDirty(true, true) - - if (this.onPositionChanged) { - this.onPositionChanged(this.ds.offset) - } } /** * adds some useful properties to a mouse event, like the position in graph coordinates @@ -5947,9 +5927,7 @@ export class LGraphCanvas { if (event.type === LiteGraph.pointerevents_method + "down") { if (w.callback) { setTimeout(function () { - that.onNodeWidgetChanged?.(node, w.name, w.value, w) - node.onWidgetChanged?.(w.name, w.value, old_value, w) - w.callback(w, that, node, pos, event) + w.callback(w, that, node, pos, event) }, 20) } w.clicked = true @@ -6089,7 +6067,6 @@ export class LGraphCanvas { //value changed if (old_value != w.value) { - that.onNodeWidgetChanged?.(node, w.name, w.value, w) node.onWidgetChanged?.(w.name, w.value, old_value, w) node.graph._version++ } @@ -6100,9 +6077,6 @@ export class LGraphCanvas { function inner_value_change(widget: IWidget, value: TWidgetValue) { const v = widget.type === "number" ? Number(value) : value widget.value = v - - that.onNodeWidgetChanged?.(node, widget.name, widget.value, widget) - if (widget.options?.property && node.properties[widget.options.property] !== undefined) { node.setProperty(widget.options.property, v) } @@ -8189,10 +8163,6 @@ export class LGraphCanvas { this.setDirty(true, true) - if (this.onPositionChanged) { - this.onPositionChanged(this.ds.offset) - } - if (progress < 1) { animationId = requestAnimationFrame(animate) } else {