From d452240936c53ddb01a2d09243b474da02a2b432 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 9 May 2025 16:37:59 +1000 Subject: [PATCH] [TS] Declare missing types in BaseWidget (#1038) --- src/widgets/BaseWidget.ts | 7 +++++++ src/widgets/KnobWidget.ts | 2 +- src/widgets/LegacyWidget.ts | 3 +-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/widgets/BaseWidget.ts b/src/widgets/BaseWidget.ts index 67438a4d6..feca3c484 100644 --- a/src/widgets/BaseWidget.ts +++ b/src/widgets/BaseWidget.ts @@ -42,6 +42,13 @@ export abstract class BaseWidget impl static labelValueGap = 5 declare computedHeight?: number + declare serialize?: boolean + computeLayoutSize?(node: LGraphNode): { + minHeight: number + maxHeight?: number + minWidth: number + maxWidth?: number + } #node: LGraphNode /** The node that this widget belongs to. */ diff --git a/src/widgets/KnobWidget.ts b/src/widgets/KnobWidget.ts index 688bb6cc7..c9351e427 100644 --- a/src/widgets/KnobWidget.ts +++ b/src/widgets/KnobWidget.ts @@ -12,7 +12,7 @@ export class KnobWidget extends BaseWidget implements IKnobWidget { * Compute the layout size of the widget. * @returns The layout size of the widget. */ - computeLayoutSize(): { + override computeLayoutSize(): { minHeight: number maxHeight?: number minWidth: number diff --git a/src/widgets/LegacyWidget.ts b/src/widgets/LegacyWidget.ts index 84e9a61c5..bbf75c519 100644 --- a/src/widgets/LegacyWidget.ts +++ b/src/widgets/LegacyWidget.ts @@ -23,8 +23,7 @@ export class LegacyWidget extends Bas override drawWidget(ctx: CanvasRenderingContext2D, options: DrawWidgetOptions) { const H = LiteGraph.NODE_WIDGET_HEIGHT - const thisAsICustomWidget = this - thisAsICustomWidget.draw?.(ctx, this.node, options.width, this.y, H, !!options.showText) + this.draw?.(ctx, this.node, options.width, this.y, H, !!options.showText) } override onClick() {