Commit Graph

23 Commits

Author SHA1 Message Date
filtered
c0e8b33716 Snap everything to grid (#315)
* Implement snap to grid

- Moves positioning logic to LGraph
- Simplifies code
- Adds Pointer API to alt-clone node
- Removes always_round_positions, replaced by always snap to grid (default size is 1 when always snapping)

Fix refator error

* Fix group items snapped without group

* Allow snapping of all items

- Add snapToGrid to Positionable
- Impl. on all types
- Deprecated: alignToGrid is now a wrapper

* Fix test import alias, update expectations

* Prevent desync of before / after change events

Adds ability to perform late binding of finally() during drag start.

* nit - Refactor

* Fix unwanted snap on node/group add

* nit - Doc

* Add shift key state tracking for snap to grid

Private impl., no state API as yet.

* Add snap guides rendering

Nodes, reroutes

* Optimisation - reroute rendering

 Fixes exponential redraw

* Add snap guidelines for groups
2024-11-18 10:12:20 -05:00
filtered
b29a32c1ae Add CanvasPointer API (#308)
* Add position rounding feature

Replaces previous impls. which only worked on some items, and were triggered when unexpected e.g. clicking a node that hadn't been moved.

Update test expectations

* Narrow TS types - readonly

* nit - Clean up, Doc

* nit - Clean up legacy accessors

Marks as deprecated

* Fix TS type - IContextMenuOptions.scale

* [Refactor] dist2 for use in pointer API

* Add CanvasPointer - API for pointer events

Add TS strict types
Add final click drag distance math
Add option to retain events

* nit - Rename

* nit

* Remove Subgraph - unused & not maintained

* Remove live_mode

Unused, not maintained.

* Update README

Remove live_mode reference

* Update delete selected - include reroutes & groups

* Bypass link menu if alt/shift pressed

* Remove old dragged_node interface

Incomplete impl. - unused.
Superceded by selectedItems

* Fix top/left edge of rectangles not in hitbox

* [Refactor] Match function names to interface names

* Add interface to find widgets by Point

LGraphNode.getWidgetOnPos

* Add widget search param - includeDisabled

* nit - Doc

* Rewrite canvas mouse handling

- Rewrites most pointer handling to use CanvasPointer callbacks
- All callbacks are declared ahead of time during the initial pointerdown event, logically grouped together
- Drastically simplifies the alteration or creation of new click / drag interactions
- Click events are all clicks, rather than some processed on mouse down, others on mouse up

- Functions return instead of setting and repeatedly checking multiple state vars
- Removes all lines that needed THIRTEEN tab indents

* Split middle click out from processMouseDown

* Use pointer API for link menus

* Narrow canvas event interfaces

* Fix canvas event types

Replaces original workarounds with final types

* Refactor - deprecated isInsideRectangle

* Add canvas hovering over state

- Centralises cursor set behaviour
- Provides simple downstream override

* nit

* [Refactor] Use measure functions

* Add double-click API to CanvasPointer

a

* nit - Doc

* Allow larger gap between double click events

* Rewrite double-click into CanvasPointer actions

* Improve double-click UX

Prefer down events over up events

* Add production defaults

* Add middle-click handling

* Remove debug code

* Remove redundant code

* Fix add reroute alt-click adds two undo steps

* Fix click on connected input disconnects

Old behaviour was to disconnect, then recreate a new link on drop.

* Add module export: CanvasPointer
2024-11-16 17:35:30 -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
Chenlei Hu
7c0240857c Revert branch to cb6e80a645 (#257) 2024-11-03 09:12:47 -05:00
dmx
79c53e0095 (prettier formatting) 2024-11-03 09:20:57 +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
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
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
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
d69a2ae9b0 Typescript LGraphCanvas (#202)
* Format only

* Revert accidental change

* Fix redundant falsy check - uninit. var

* nit - Refactor const/let

* nit - Refactor const/let (manual)

* nit - Redeclared params

* Add TS types & minor refactor only

* Refactor - Clean up / reformat

- Add strings.ts helper functions
- Remove unused vars & local function params
- Simplifies code
- Rename vars for clarity
- Add TODOs and other comments
- Add ts-expect-error

* Redirect draw.ts enums to global file (temp.)

Should be revisited after TS merge complete
Corrects import of types from draw.ts into interfaces

* Add measure.ts - move util funcs from Global

* Add all imports required for TS conversion

* Refactor - TS narrowing

* nit - TS types & minor refactor

* Add missing types from recent PRs

Removes duplicate declarations
Fixes some type mismatches

* nit - Refactor recent PRs

* Revert incorrect decls backported

* Remove unused params

* Add TS types only

* Fix minor TS type coercion issues

Also removes redundant code

* nit - Refactor

* Remove @ts-nocheck

* Fix refactor regression - drag link to output

Issue was the result of fixing var declared outside of closure

* Restore original logic

---------

Co-authored-by: huchenlei <huchenlei@proton.me>
2024-10-11 12:21:10 -04:00
filtered
5d510cd674 Revert "Format all code with prettier (#197)" (#198)
This reverts commit 28382b7e45.
2024-10-08 13:14:36 -04:00
Chenlei Hu
28382b7e45 Format all code with prettier (#197)
* Add formatter support

* Format all code

* Fix moved @ts-expect-error
2024-10-07 14:06:44 -04:00
Chenlei Hu
142c22ea41 Typescript conversion 0.7.84 (#194)
* Convert litegraph.js to TS

* Overhaul static litegraph.d.ts with updated types

* Fix rename oversights and revert fix unused param

- Some functions were broken by merging updated TS function signatures which included param renames
- Removal of unused params does not belong in the TS conversion PR, and has been reverted

* Remove legacy static .d.ts file

* Add callback decl from #180

Support allowing links to widgets (#180)
c23e610c11

* Convert NodeId to string | number

Results in significantly less downstream changes, despite being a change from the old static file.

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
2024-10-07 11:15:29 -04:00
Chenlei Hu
8ffb29d1a5 Add hidden link enum (#190) 2024-10-02 14:45:21 -04:00
filtered
18600f48f9 Clean litegraph module entry file (#171)
* Move LiteGraph global class props, fix duplicates

* Split polyfills out to separate file

* Move prototype modifications to class decl
2024-09-30 16:31:18 -04:00
huchenlei
96f62f8f93 Revert accidental changes 2024-09-27 10:43:53 +09:00
huchenlei
0652de8e66 Change cursor shape to grab on dragging 2024-09-27 10:43:53 +09:00
filtered
4a109deb8a Split LGraphCanvas out to TS file
Fixes circular dependency
2024-09-27 09:56:19 +09:00
filtered
1c835b04dc Split LGraphNode out to TS file 2024-09-27 09:56:19 +09:00
filtered
6ee95f1201 TypeScript conversion groundwork (#163)
* ContextMenu ES6 class conversion

* Fix compat with extensions

* CurveEditor ES6 class conversion

* Split most of the LiteGraph global out to a class

* Move remainder of LiteGraph global to class file

* Remove IIFE wrapper

* Fix jest tests throwing due to type narrowing
2024-09-27 08:20:30 +09:00