Commit Graph

10 Commits

Author SHA1 Message Date
filtered
ccbdff0ad1 Fix Rectangle subarray end offset logic (#1021) 2025-05-06 18:10:59 +00:00
filtered
a74df42cce Fix Rectangle.size exception on access (#1013) 2025-05-06 19:28:51 +10:00
filtered
75df19521b Widget overhaul (#1010)
### Widget text overhaul

#### Current
- Numbers and text overlap
- Combo boxes truncate the value before the label

![image](https://github.com/user-attachments/assets/c991b0b6-879f-4455-92d4-4254ef25b55c)

#### Proposed

**By default, widgets will now truncate their labels before their
values.**


https://github.com/user-attachments/assets/296ea5ab-d2ff-44f2-9139-5d97789e4f12

- Changes the way widget text is rendered, calculated, and truncated
- Truncation now applies in a standard way to the following widgets:
  - Text
  - Combo
  - Number
- Centralises widget draw routines in base class

### Config

```ts
// Truncate **both** widgets and labels evenly
LiteGraph.truncateWidgetTextEvenly = true

// Swap the default from truncating labels before values, to truncating values first (restores legacy behaviour)
// truncateWidgetTextEvenly **must** be `false`.
LiteGraph.truncateWidgetValuesFirst = true
```

### API / interfaces  

- Adds rich `Rectangle` concrete impl., with many methods and helpful
accessors (e.g. `right`, `bottom`)
- Actually _improves_ performance due to switch from Float32Array to
Float64Array
- Impact vs plain Float64Array was not detectable outside of a 2M+
instantiation-loop with random data
  - Lazy `pos` & `size` `subarray` properties
- Adds `ReadOnlySize`
- Adds higher-level text draw functions to abstract the nitty gritty in
a performant way (binary search)

- Resolves Comfy-Org/ComfyUI_frontend/issues/457
2025-05-05 10:48:06 +10:00
filtered
64d1225037 [Refactor] Convert to generic CustomEventTarget (#983)
Converts LinkConnector event target to a generic class.

Subgraph pre-requisite.
2025-04-28 22:19:26 +00:00
filtered
ce46f19de9 Fix LinkConnector methods cannot be cancelled via API (#934)
- Checks if `e.preventDefault()` has been called for all cancellable
LinkConnector callbacks
- Sets `cancelable: true` on dispatched events
- Dedupes canvas pointer calls
2025-04-18 20:50:33 +10:00
filtered
7b8f01f546 [Refactor] Split moving links (#839)
Splits moving links out to separate input and output classes.
2025-03-23 22:11:08 +00:00
filtered
850d1b9652 [API] Finalise LinkConnector design, adding reroute logic (#817)
- Splits link connect logic out of `LinkConnector` to individual
`RenderLink` classes
- Add support for connecting / reconnecting reroutes in various
configurations
- Adds support for moving existing floating links from outputs / inputs
- Fixes numerous corruption issues when reconnecting reroutes / moving
links
- Tests in separate PR #816
2025-03-21 19:41:20 +00:00
filtered
5ed264ce8e Allow reroutes to be re-connected (#749)
- Resolves #305
- Allows links to be dragged from inputs to reroutes
2025-03-11 13:47:26 +00:00
filtered
c0bfe5489f [API] Add LinkConnector - replaces connecting_links (#726)
### LinkConnector

Replaces the minimal-change effort of `connecting_links` with a more
reliable implementation.

- Subscribable, event-based API
- Uses browser-standard `e.preventDefault()` to cancel `before-*` events
- Uses standard `state` POJO - can be proxied without issue
- Structures code and separates concerns out of `LGraphCanvas`
- Link creation calls can now be made from anywhere, without the need
for a rewrite
- New canvas sub-components now live in `src/canvas/`

### Rendering

- Skips link segments by setting a `_dragging` bool flag on the LLink or
Reroute
- Moves some previously nested code to event listeners, configured in
the `LGraphCanvas` constructor

### Deprecation

`LGraphCanvas.connecting_links` is now deprecated and will later be
removed.

Until it is removed, to prevent breaking extensions it will continue to
be set and cleared by a legacy callback. The contents of this property
are ignored; code search revealed no exentsions actually modifying the
array.
2025-03-08 23:48:45 +00:00
filtered
0b84ca83d8 [TS] Use strict mode in LGraphGroup (#599)
- Adds `NullGraphError` to reduce boilerplate null check code
- Prefer optional `undefined` to explicit `null`
  - Related: https://github.com/Comfy-Org/litegraph.js/issues/595
- Adds strict types
2025-02-25 17:15:48 +00:00