Code cleanup, docs, TS types (#278)

* Fix test TS types

Prefer relative imports over @imports

* Add tuple names SerialisedLLinkArray

* nit

* [Refactor] LGraphCanvas.computeConnectionPoint

* [Refactor] Add LGraphCanvas.#dirty()

* Remove string LLink IDs

No downstream support for strings at present.

* nit - Rename

* nit

* nit

* nit - Remove unused code

* nit - Doc

* nit

* nit - Remove redundant code

* Remove unused: LGraphCanvas.isOverNodeBox

* Optimise - remove 2d context save/restore

* [Refactor] Move node collapsed check to class

* Add minor code change to support stricter types

* Revert accidental deletion in 0f2d04d

0f2d04d09e5e8a27a6d46d8c910dc077ed2d9071
This commit is contained in:
filtered
2024-11-05 13:08:59 +11:00
committed by GitHub
parent e1a118a70f
commit e6961f1c5a
8 changed files with 154 additions and 162 deletions

View File

@@ -1513,6 +1513,17 @@ export class LGraphNode implements Positionable, IPinnable {
return isXyInRectangle(x, y, this.boundingRect)
}
/**
* Checks if the provided point is inside this node's collapse button area.
* @param x X co-ordinate to check
* @param y Y co-ordinate to check
* @returns true if the x,y point is in the collapse button area, otherwise false
*/
isPointInCollapse(x: number, y: number): boolean {
const squareLength = LiteGraph.NODE_TITLE_HEIGHT
return isInsideRectangle(x, y, this.pos[0], this.pos[1] - squareLength, squareLength, squareLength)
}
/**
* checks if a point is inside a node slot, and returns info about which slot
* @param x
@@ -1915,9 +1926,9 @@ export class LGraphNode implements Positionable, IPinnable {
}
}
const nextId = LiteGraph.use_uuids
? LiteGraph.uuidv4()
: ++graph.last_link_id
// UUID: LinkIds
// const nextId = LiteGraph.use_uuids ? LiteGraph.uuidv4() : ++graph.last_link_id
const nextId = ++graph.last_link_id
//create link class
link_info = new LLink(
@@ -2300,7 +2311,7 @@ export class LGraphNode implements Positionable, IPinnable {
}
/**
* Collapse the node to make it smaller on the canvas
* Toggle node collapse (makes it smaller on the canvas)
**/
collapse(force?: boolean): void {
if (!this.collapsible && !force) return