mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 19:49:58 +00:00
[Refactor] Move slot code out of LGraphNode (#981)
Moves collapsed node slot render code to the slot instances.
This commit is contained in:
@@ -49,6 +49,9 @@ export abstract class NodeSlot implements INodeSlot {
|
||||
])
|
||||
}
|
||||
|
||||
/** The center point of this slot when the node is collapsed. */
|
||||
abstract get collapsedPos(): ReadOnlyPoint
|
||||
|
||||
#node: LGraphNode
|
||||
get node(): LGraphNode {
|
||||
return this.#node
|
||||
@@ -204,11 +207,11 @@ export abstract class NodeSlot implements INodeSlot {
|
||||
ctx.lineWidth = originalLineWidth
|
||||
}
|
||||
|
||||
drawCollapsed(ctx: CanvasRenderingContext2D, options: { pos: Point }) {
|
||||
const [x, y] = options.pos
|
||||
drawCollapsed(ctx: CanvasRenderingContext2D) {
|
||||
const [x, y] = this.collapsedPos
|
||||
|
||||
// Save original styles
|
||||
const originalFillStyle = ctx.fillStyle
|
||||
const { fillStyle } = ctx
|
||||
|
||||
ctx.fillStyle = "#686"
|
||||
ctx.beginPath()
|
||||
@@ -234,6 +237,6 @@ export abstract class NodeSlot implements INodeSlot {
|
||||
ctx.fill()
|
||||
|
||||
// Restore original styles
|
||||
ctx.fillStyle = originalFillStyle
|
||||
ctx.fillStyle = fillStyle
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user