Commit Graph

655 Commits

Author SHA1 Message Date
Chenlei Hu
34f8d3408b Add LGraphCavnas.fitViewToSelectionAnimated (#292) 2024-11-08 14:22:18 -05:00
Chenlei Hu
c7d5c863ec Move createBounds to measure.ts (#290)
* nit

* Move createBounds to measure

* Export createBounds
2024-11-08 13:49:30 -05:00
Zoltán Dócs
6ad864bc20 Animate view to multiple nodes (#282)
* animateToNodes
- modify existing animation method to support passing multiple nodes, in which case the view is fit to the bounding box around them

* animateToBounds

* amend

* format

* amend
2024-11-08 13:40:15 -05:00
filtered
87c6d59546 Keep links connected when deleting nodes (#288)
* Allow node delete to keep more links connected

* Allow node delete to match every link

* Add config for connectInputToOutput
2024-11-08 11:13:14 -05:00
filtered
fc0b8087db Graph serialisation update - Links & Reroutes (#279)
* nit

* Add LGraph state POCO

Moves last_link_id, last_node_id and creates same for group and reroute

fix import

* Add new serialisation to LGraph

Add LGraph schema 1
Remove reroute from old serialised graph
Remove brittle inherited types
Ensure stale links are not kept when clearing graph

* Add serialisable exports

* Ensure valid LGraph.state during deserialise
2024-11-07 18:33:54 -05:00
filtered
1c40aad87c Fix pin not respected by multi-select move (#284) 2024-11-07 15:58:49 -05:00
filtered
e1aac5cf61 Improve hitbox for group resize (#277)
Now the same as the visual area

Co-authored-by: Chenlei Hu <huchenlei@proton.me>
2024-11-06 19:35:56 -05:00
filtered
2ba048de52 Remove hard-coded modifications to nodes (#247)
* Remove arbitrary 5 graph unit margin around nodes

* Remove arbitrary +1 pixel added to node width

---------

Co-authored-by: Chenlei Hu <huchenlei@proton.me>
2024-11-05 18:35:59 -05:00
filtered
e6961f1c5a 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
2024-11-04 21:08:59 -05:00
Chenlei Hu
5edfc185c5 Unify pin/unpin interface between LGraphNode and LGraphGroup (#274) 2024-11-04 15:09:17 -05:00
Chenlei Hu
b663f86c9e Serialize to node pos/size to plain array (#273) 2024-11-04 14:08:09 -05:00
filtered
ba52402851 Replace canvas "action" magic strings (#271) 2024-11-03 18:30:19 -05:00
filtered
ce8d39f650 Group update - titlebar, resize, config (#270)
* Backport group header from frontend

* nit - TS types & redundant code

* Refactor - simplify group resize

* Fix group resize can be inverted

* Move group resize check to group class

* Add config for group padding & default colour

* nit - Remove redundant code
2024-11-03 18:27:41 -05:00
filtered
3be1937c41 Update delete selected (#269)
* Standardise naming - deleteSelected

Renamed from deleteSelectedItems

* nit - Refactor to match future state
2024-11-03 18:10:46 -05:00
Chenlei Hu
6180f5ef55 Backspace delete selected (Nodes + Groups) (#265)
* Backspace delete selected (Nodes + Groups)

* nit

* nit
2024-11-03 17:22:08 -05:00
Chenlei Hu
62bc1ecd9f Ctrl+a select all items (Group + Node) (#264)
* Ctrl+a select all items (Group + Node)

* refactor

* nit
2024-11-03 17:16:11 -05:00
filtered
1b110a62cf Add multi select & group nesting (#262)
* Add multi-select all canvas items (groups, nodes)

* Add Feat: Group & Node Multi-Select / Nesting

- Groups can now contain groups
- Nested groups re-order on top of parent groups
- Groups can be added / removed from selection
- Uses new Positionable interface - easily extensible to new types

* Enhance add / remove from selection UX

More in line with normal desktop UX.  Structured for keys to be customisable (if impl. later).

* Fix regression in link highlight

Legacy selection code still in use

* Allow nested groups to align perfectly on edges

* Remove group-move position rounding

Did not work under all circumstances, and resulted in misalignment more often than it helped.
2024-11-03 16:21:21 -05:00
filtered
e661decddc Positionable: Common interface for canvas items (#256)
* Add Positionable interface to canvas elements

* Add group resizeTo children

Refactor out duplicated code from Node

* Remove redundant "is_selected" check

* Improve measure pass - interface, caching

Node bounds once per render
Cached results

* Use cached bounds for repeat canvas calls

- Removes margin param from getNodeOnPos
- Removes margin param from getGroupOnPos
- Hitboxes now uniform for render / mouse features
- Simplifies code

* nit - Refactor

* Fix top-left edge of hitbox missing

* Add ID to groups
2024-11-03 11:12:21 -05:00
Chenlei Hu
6200aa8602 Reland animateToNode (#259)
* Reland animateToNode

* nit
2024-11-03 10:45:42 -05:00
Chenlei Hu
7c0240857c Revert branch to cb6e80a645 (#257) 2024-11-03 09:12:47 -05:00
dmx
9b0f572ca1 (feature) animateToNode method 2024-11-03 17:18:34 +04:00
dmx
11fe365983 (add) onPositionChanged and onZoomChanged events 2024-11-03 17:03:30 +04:00
dmx
78426148ac fix TS error 'Timeout' is not assignable to type 'number' 2024-11-03 10:00:38 +04:00
dmx
c8bac1aa40 add onNodeUpdated event in LGraph 2024-11-03 09:44:48 +04:00
dmx
79c53e0095 (prettier formatting) 2024-11-03 09:20:57 +04:00
filtered
1dfe824239 Shared measure functions (#254)
* Add findPointOnCurve function

* Add measure functions: contains centre/rect

* Improve measure interfaces (ReadOnlyPoint/Rect)

* nit - Doc

* Add TS strict types

* Add TS strict types

* Add TS strict types

* Add TS type
2024-11-02 10:35:36 -04:00
filtered
c0217dbb7e Remove _ctor pattern from Node & Group (#248)
Convert to initializers
2024-11-01 23:12:03 -04:00
filtered
020c912a8d Convert Links to ES6 Map & LLink Serialisation (#246)
* Fix intermittent links bug - graph.links Map()

Replaces graph.links with Map()
Adds a Proxy to provide for...in and indexer access
Temporarily uses merged Map+Record type, to ease downstream migration

* nit - Remove redundant code

* nit - Remove redundant null checks

* Add Serializable interface, used in LLink

Allows LLink to be serialised as an object rather than an array, bringing it inline with the rest of LiteGraph.
2024-10-31 21:53:00 -04:00
pythongosssss
eaaa0a4c39 Support for hidden & advanced widgets (#250) 2024-10-31 21:41:31 -04:00
filtered
d9d0837423 Code clean up (#244)
* Replace global var with enums

* Remove unused interface

* Add TS types

* Remove unused code

* nit - Clean up

* Add TS types

* nit - Refactor / clean up

* nit - Add TS types, clean up

* nit - Doc

* nit

* nit

* nit

* nit - Doc

* nit

* nit

* nit - let/const

* nit - Remove redundant code
2024-10-31 14:17:13 -04:00
filtered
002c955bf3 Minor bug fixes & refactors (#245)
* Fix TS errors - use correct property

* Fix graph version bumped without change

* Fix onDrawForeground callback has wrong area

* Move node pos getter/setter to class decl
2024-10-31 14:16:24 -04:00
filtered
b74662fbad Fix group order unexpectedly reversing (#242) 2024-10-30 19:48:48 -04:00
filtered
116b21e8f5 Add / fix canvas TS strict types, doc (#237)
* Fix circular depdency in global

* Add TS type guard private function

* Add TS type

* Add TS types & doc

* Add TS type initialisers

* Add NullableProperties type

* Add TS types

* Split node arrange code out to separate file
2024-10-30 14:32:55 -04:00
filtered
95af20c1c4 Snaps for Comfy 🫰 (#239)
* Add Snaps for Comfy

* Add snap visual effects

* Update node measure to work everywhere

* Fix findConnectByTypeSlot does not work for "*"

* Fix regression in fast widget conversion
2024-10-30 12:02:41 -04:00
filtered
94223b2846 Fix minor debug log spam when dragging link (#238) 2024-10-29 22:08:47 -04:00
filtered
0b174adfeb Move canvas state to plain object (#233)
* Move canvas state to plain object

POCO that can be proxied without side-effects.
LGraphCanvasState interface added to package exports

* Add item dragging to canvas state
2024-10-29 21:39:46 -04:00
filtered
21b9cb6089 Multi-link drag keeps links bundled properly (#224) 2024-10-28 19:00:08 -04:00
filtered
5070866299 Add / improve Node interfaces: Find slots & before connect callback (#226)
* Add connectByType wrappers

Can find slots without actually connecting.  Will be used for link snapping.

* Refactor - generic find free slot

* Fix link/links TS types - should not be undefined

* Fix / add TS types, docs

* Refactor - fix overloads TS types

* Refactor - optional chaining

* Extend node before-connect callback

The callback can now determine if connection is to a specific input, or just trying to connect any valid slot on the node.

* Add TS types - finish IOptionalInputsData
2024-10-28 18:59:43 -04:00
filtered
83cb795301 Fix group deselected on title click (#230) 2024-10-27 21:10:08 -04:00
filtered
748d35b610 Add hover highlight and link dragging features (#222)
* Add new hover highlight and link dragging features

- Hovering effects added for node inputs and outputs
- Adds "mouseout" handler to properly clear node state when mousing off a node
- Fixes bug that causes outputs to always be dimmed out when connecting from inputs
- Slight performance improvement

* Add node highlight text colour option

* Add slot highlight colour fallback
2024-10-27 16:57:41 -04:00
filtered
d3e0582c52 Add multi-group select & drag (#225) 2024-10-26 18:12:38 -04:00
filtered
3f5499f955 Canvas refactors - standardising (#221)
* Add distribute nodes

* Fix node alt-clone does not work like copy/paste

* Impl. emitEvent across LGraphCanvas

- Create TS types and union for all events
- Replaces all relevant dispatchEvent calls with emitEvent()

* Remove unused code

- showShowGraphOptionsPanel throws an exception when run.  Safe to assume this function not in use.
- Remove old commented code

* Refactor - minor changes to clear TS errors

* Add TS types

* nit - ts-expect-error, comments

* Remove legacy hook

* Refactor - prefer typeof / instanceof / isArray

* Refactor - TS type narrowing

* nit
2024-10-26 13:13:42 -04:00
filtered
70edfe2a33 Fix node shape not set by menu / setter (#214) 2024-10-25 21:07:26 -04:00
filtered
955daac9e6 Fix circular dependency (#219)
* Fix circular dependency - LGraphCanvas static init

* Remove dependency workaround
2024-10-25 20:17:31 -04:00
filtered
eb98a36d47 Typescript LiteGraphGlobal (#210)
* nit - Format

* Refactor - prefer typeof over constructor check

* Fix initialisers

* Add TS types

* nit - auto const/let

* nit - manual const/let

* nit

* Add TS types

* nit - Remove redundant JSDoc

* nit

* Use enums in LiteGraph global

* Fix TS type - node shape

* Add TS types

* Remove unused vars

* nit - Refactor / format

* nit - Refactor

* Refactor - optional chaining
2024-10-24 20:00:29 -04:00
filtered
c0afb1306e Convert CurveEditor to TypeScript (#211) 2024-10-24 19:59:36 -04:00
filtered
dd8cda7862 Typescript DragAndScale (#212)
* nit - Format

* Add TS types

* nit - auto const/let

* nit

* nit - Refactor / format

* Refactor - optional chaining
2024-10-24 18:41:21 -04:00
filtered
4d87476905 Typescript ContextMenu (#206)
* Format only

* Refactor TS narrowing & coercion

* nit - Refactor

* nit - Refactor

* Refactor optional chaining

* Add TS narrowing

* nit - Add base interface

* Add TS types

* Refactor - TS type narrowing

* Convert to arrow funcs for this ref
2024-10-12 11:00:50 -04:00
filtered
c34299f1d7 Typescript LGraphGroup (#208)
* nit - Format

* nit - auto const/let

* nit - Refactor / format

* Add TS types

* Replace dynamic getter/setter with class decls

* Make group move nodes param optional
2024-10-12 10:57:45 -04:00
filtered
96866e8624 Typescript LGraphNode (#207)
* nit - Fix whitespace

* nit - Remove outdated comments

* nit - Remove redundant jsdoc tag

* Format only

* Add TS types

* nit - Auto let/const

* Convert special-case vars

* nit - Redeclared params / vars

* nit - const/let

* Refactor - minor logic change

* Add TS types - overloads w/workaround

* Refactor - prefer typeof over constructor check

* Add TS types

* Remove unused params

* nit - Refactor

* Refactor LGraphNode.findSlotByType

* nit - Refactor / format

* Refactor - optional chaining

* Fix TS type - node shape
2024-10-12 10:53:25 -04:00