From 6cf1f2d627a28cb688cd12802b6104a28ce3fe42 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 3 Feb 2025 20:02:42 -0800 Subject: [PATCH] [Refactor] Move shape fallback from LGraphCanvas to LGraphNode (#451) * [Refactor] Move shape fallback from LGraphCanvas to LGraphNode * nit --- src/LGraphCanvas.ts | 2 +- src/LGraphNode.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index e93f7197c..0ea07c0f7 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -5175,7 +5175,7 @@ export class LGraphCanvas { const low_quality = this.low_quality const { collapsed } = node.flags - const shape = node._shape || node.constructor.shape || LiteGraph.NODE_DEFAULT_SHAPE + const shape = node.renderingShape const title_mode = node.title_mode const render_title = title_mode == TitleMode.TRANSPARENT_TITLE || title_mode == TitleMode.NO_TITLE diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 796de9834..932a4e6a2 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -323,6 +323,13 @@ export class LGraphNode implements Positionable, IPinnable { } } + /** + * The shape of the node used for rendering. @see {@link RenderShape} + */ + get renderingShape(): RenderShape { + return this._shape || this.constructor.shape || LiteGraph.NODE_DEFAULT_SHAPE + } + public get is_selected(): boolean { return this.selected }