Fixes issue where pinch to zoom would jitter around scale 1 - D&S rounds
the value to exactly 1 when it is "close enough". Good for pointer, poor
UX for precision trackpad.
Adds trackpad gesture support to canvas interaction. Supports:
- Pinch to zoom
- Two-finger panning
Feature is off by default. Also by default, the browser user-agent must
include "Mac" (even if the feature has been enabled).
```ts
// Enable mac trackpad gestures
LiteGraph.macTrackpadGestures = true
// Disable the default Mac user-agent check
LiteGraph.macGesturesRequireMac = false
```
Emits an event when attempting to delete items with nothing selected.
Event is generic and should also be used to report any other
user-initiated actions.
Emitted from LGraphCanvas.canvas
- bubbles
- non-cancellable
```
litegraph:no-items-selected
```
### Virtual helper "slots"
Adds a virtual input and output slot to native reroutes, allowing links
to be dragged from them to other reroutes or nodes.
https://github.com/user-attachments/assets/67d308c4-4732-4b04-a2b9-0a2b0c79b413
### Notes
- Reroute slots automatically show an outline as the pointer gets close
- When the slot is clickable, it will highlight in the same colour as
the reroute
- Enables opposite direction connecting: from reroute to node outputs
- Floating reroutes only show one slot - to whichever side is not
connected
Restores the full left-arrow button click area for widgets. Previously
lost ~5 canvas pixels to clicks intercepted by input sockets.
Supporting refactors:
- Maps concrete node slot impls. to private array, once per frame
- Converts slot boundingRect to use absolute canvas pos (same as other
elements)
- Stores parent node ref in concrete slot classes
### Node resize overhaul
- Precisely calculates node minimum size
- Prevents input & output overlap
- Prevents (normal*) widgets from rendering text over the edge of nodes
- Performance impact was sub-millisecond for normal usage in a 500-node
graph

_Minimum size for a few example node configurations_
### Widgets
- Converts hard-coded draw render values to class static properties
- Adds widget button draw function for left/right arrow widgets
_*_ Exception: `control_after_generate`, as it is not a true input /
widget. A check may be added later to handle this special case.
- Checks if `e.preventDefault()` has been called for all cancellable
LinkConnector callbacks
- Sets `cancelable: true` on dispatched events
- Dedupes canvas pointer calls
- Uses CanvasPointer click to open context menu (formerly occurred on
`pointerdown`)
- Frees up right-click & drag to be used by future features
- Right-clicking a reroute now selects the reroute, using the same
selection logic used for right-clicking nodes
This PR is the litegraph side change necessary for widget sockets
feature in ComfyUI_frontend. Changes include
- Add readonly `Widget.computedDisabled` property for getting the
computed disabled state. When the associated socket is connected, the
widget is disabled
- Dynamically show the associated socket when
- the mouse is over the widget
- the slot is valid during link drop
- the slot is connected
- Removes the legacy widget drop behavior
Ref: https://github.com/Comfy-Org/rfcs/pull/9
This should allow frontend drop the stroke logic in hijack of
`drawNodeShape`. Example usage:
```ts
node.strokeStyles["executionError"] = (this: LGraphNode) =>
app.lastNodeErrors?.[this.id] ? { colour: 'red', thickness: 2 } : undefined
```