Add LGraph.empty (#371)

This commit is contained in:
Chenlei Hu
2024-12-06 14:49:50 -08:00
committed by GitHub
parent 0d0dfafc5b
commit a9940da05f
2 changed files with 15 additions and 8 deletions

View File

@@ -115,6 +115,16 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
inputs: Dictionary<IGraphInput>
outputs: Dictionary<IGraphInput>
/** @returns Whether the graph has no items */
get empty(): boolean {
return this.positionableItems.length === 0
}
/** @returns All items on the canvas that can be selected */
get positionableItems(): Positionable[] {
return [...this._nodes, ...this._groups, ...this.reroutes.values()]
}
#reroutes = new Map<RerouteId, Reroute>()
/** All reroutes in this graph. */
public get reroutes(): Map<RerouteId, Reroute> {

View File

@@ -3954,15 +3954,12 @@ export class LGraphCanvas {
}
}
/**
* @returns All items on the canvas that can be selected
*/
get empty(): boolean {
return this.graph.empty
}
get positionableItems(): Positionable[] {
return [
...this.graph._nodes,
...this.graph._groups,
...this.graph.reroutes.values(),
]
return this.graph.positionableItems
}
/**