Commit Graph

19 Commits

Author SHA1 Message Date
filtered
71f8a1decf Export Reroute class the same as other similar classes (#378)
* Export Reroute class the same as other similar classes

* Update test expectations
2024-12-15 10:54:50 -08:00
filtered
91077aa20b Redesign invalid node indicator (#358)
* nit

* Remove unused code

Gradient can (and should) be impl. directly by caching a CanvasGradient.

* nit

* nit - Refactor

* Remove redundant code

* Add line width & colour options to shape stroke

* Rename drawSelectionBounding to strokeShape

* nit - Doc

* Fix rounded corners not scaling with padding

* Optimise node badge draw

* Redesign invalid node visual indication

Customisable boundary indicator now used, replacing red background.

* Update snapshot

---------

Co-authored-by: huchenlei <huchenlei@proton.me>
2024-11-29 16:26:25 -05:00
filtered
ee45593558 Move Snap to Grid control to LiteGraphGlobal (#329)
* Fix snap to grid - now toggled at app level

Was impl. as per workflow.

* Update test expectations
2024-11-21 10:19:00 -05:00
pythongosssss
1bec315427 Adds highlight to advanced widgets (#317)
* Adds highlight to advanced widgets

* Update snapshot
2024-11-18 13:16:52 -05:00
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
3e28ec5981 Update tests for schema v1 (#289) 2024-11-08 11:12:09 -05:00
filtered
7e21b00cc7 Replace test framework: jest -> vitest (#281)
* Replace test framework: jest -> vitest

* nit - remove deprecated npm scripts

* Add vitest config

* Add a few basic tests

* Update actions with vitest params

* Add correct expectations

* Remove jest config
2024-11-06 17:27:32 -05:00
Chenlei Hu
b663f86c9e Serialize to node pos/size to plain array (#273) 2024-11-04 14:08:09 -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
94f1ca4279 Remove future test (#249) 2024-11-01 19:00:02 -04:00
filtered
edfa5e70f2 ES2022 Output & whitespace-only minification (#201)
* Change vite output to ES2022

* Add whitespace-only minify using default esbuild

Does not work for .es.js output - limitation of vite.
Workaround for .es.js involves adding terser & a plugin.

* Remove @ts-expect-error from tests

* Update vite.config.mts

---------

Co-authored-by: Chenlei Hu <huchenlei@proton.me>
2024-10-10 21:00:45 -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
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
Chenlei Hu
e25c21026c Fix LGraphNode.pos serialization (#107) 2024-09-02 14:31:05 -04:00
Chenlei Hu
b0bcb0e062 Remove unnecessary compatibility layer (#66) 2024-08-09 13:18:51 -04:00
Chenlei Hu
16a3d384b6 ES6 class convertion of LGraph (#63)
* LGraph ES6 class conversion

* Add compatibility to prototype extension

* Add jest test action

---------

Co-authored-by: filtered <176114999+webfiltered@users.noreply.github.com>
2024-08-09 11:20:05 -04:00