Reduce input socket hitbox for widgets (#966)

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
This commit is contained in:
filtered
2025-04-26 00:12:09 +10:00
committed by GitHub
parent 0fd47a767d
commit 63407abf3c
7 changed files with 93 additions and 54 deletions

View File

@@ -2,12 +2,17 @@ import type { IColorable } from "@/interfaces"
/**
* Converts a plain object to a class instance if it is not already an instance of the class.
*
* Requires specific constructor signature; first parameter must be the object to convert.
* @param cls The class to convert to
* @param obj The object to convert
* @param args The object to convert, followed by any other constructor arguments
* @returns The class instance
*/
export function toClass<P, C>(cls: new (plain: P) => C, obj: P | C): C {
return obj instanceof cls ? obj : new cls(obj as P)
export function toClass<P, C extends P, Args extends unknown[]>(
cls: new (instance: P, ...args: Args) => C,
...args: [P, ...Args]
): C {
return args[0] instanceof cls ? args[0] : new cls(...args)
}
/**