mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-22 07:19:41 +00:00
Positionable: Common interface for canvas items (#256)
* Add Positionable interface to canvas elements * Add group resizeTo children Refactor out duplicated code from Node * Remove redundant "is_selected" check * Improve measure pass - interface, caching Node bounds once per render Cached results * Use cached bounds for repeat canvas calls - Removes margin param from getNodeOnPos - Removes margin param from getGroupOnPos - Hitboxes now uniform for render / mouse features - Simplifies code * nit - Refactor * Fix top-left edge of hitbox missing * Add ID to groups
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ContextMenu } from "./ContextMenu"
|
||||
import type { LGraphNode } from "./LGraphNode"
|
||||
import type { LGraphNode, NodeId } from "./LGraphNode"
|
||||
import type { LinkDirection, RenderShape } from "./types/globalEnums"
|
||||
import type { LinkId } from "./LLink"
|
||||
|
||||
@@ -12,6 +12,35 @@ export type NullableProperties<T> = {
|
||||
|
||||
export type CanvasColour = string | CanvasGradient | CanvasPattern
|
||||
|
||||
export interface Positionable {
|
||||
id: NodeId | number
|
||||
/** Position in graph coordinates. Default: 0,0 */
|
||||
pos: Point
|
||||
/** true if this object is part of the selection, otherwise false. */
|
||||
selected?: boolean
|
||||
|
||||
readonly children?: ReadonlySet<Positionable>
|
||||
|
||||
/**
|
||||
* Adds a delta to the current position.
|
||||
* @param deltaX X value to add to current position
|
||||
* @param deltaY Y value to add to current position
|
||||
* @param skipChildren If true, any child objects like group contents will not be moved
|
||||
*/
|
||||
move(deltaX: number, deltaY: number, skipChildren?: boolean): void
|
||||
|
||||
/**
|
||||
* Cached position & size as `x, y, width, height`.
|
||||
* @readonly See {@link move}
|
||||
*/
|
||||
readonly boundingRect: ReadOnlyRect
|
||||
|
||||
/** Called whenever the item is selected */
|
||||
onSelected?(): void
|
||||
/** Called whenever the item is deselected */
|
||||
onDeselected?(): void
|
||||
}
|
||||
|
||||
export interface IInputOrOutput {
|
||||
// If an input, this will be defined
|
||||
input?: INodeInputSlot
|
||||
|
||||
Reference in New Issue
Block a user