mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-06 05:30:08 +00:00
Add IColorable interface (#549)
* Add IColorable interface * Set color option * nit * nit * nit
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
// @ts-strict-ignore
|
||||
import type {
|
||||
CanvasColour,
|
||||
ColorOption,
|
||||
ConnectingLink,
|
||||
Dictionary,
|
||||
IColorable,
|
||||
IContextMenuValue,
|
||||
IFoundSlot,
|
||||
INodeFlags,
|
||||
@@ -142,7 +144,7 @@ export interface LGraphNode {
|
||||
* @param {string} name a name for the node
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export class LGraphNode implements Positionable, IPinnable {
|
||||
export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
// Static properties used by dynamic child classes
|
||||
static title?: string
|
||||
static MAX_CONSOLE?: number
|
||||
@@ -234,6 +236,27 @@ export class LGraphNode implements Positionable, IPinnable {
|
||||
return this.boxcolor || colState || LiteGraph.NODE_DEFAULT_BOXCOLOR
|
||||
}
|
||||
|
||||
/** The color option used to set {@link color} and {@link bgcolor}. */
|
||||
#colorOption: ColorOption | null = null
|
||||
|
||||
/** @inheritdoc {@link IColorable.setColorOption} */
|
||||
setColorOption(colorOption: ColorOption | null): void {
|
||||
if (colorOption == null) {
|
||||
delete this.color
|
||||
delete this.bgcolor
|
||||
this.#colorOption = null
|
||||
} else {
|
||||
this.color = colorOption.color
|
||||
this.bgcolor = colorOption.bgcolor
|
||||
this.#colorOption = colorOption
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc {@link IColorable.getColorOption} */
|
||||
getColorOption(): ColorOption | null {
|
||||
return this.#colorOption
|
||||
}
|
||||
|
||||
exec_version: number
|
||||
action_call?: string
|
||||
execute_triggered: number
|
||||
|
||||
Reference in New Issue
Block a user