mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
Add lowQuality param to IWidget.draw (#843)
Currently widget needs to get access to `LGraphCanvas` instance to know whether the canvas is rendering in low quality (Zoomed out). Usually canvas object is obtained from `ComfyApp` instance. This PR passes the lowQuality value to `IWidget.draw` to decouple the dependency on `LGraphCanvas`.
This commit is contained in:
@@ -3376,7 +3376,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
if (WidgetClass) {
|
||||
toClass(WidgetClass, w).drawWidget(ctx, { y, width: widget_width, show_text, margin })
|
||||
} else {
|
||||
w.draw?.(ctx, this, widget_width, y, H)
|
||||
w.draw?.(ctx, this, widget_width, y, H, lowQuality)
|
||||
}
|
||||
ctx.globalAlpha = editorAlpha
|
||||
}
|
||||
|
||||
@@ -193,12 +193,22 @@ export interface IBaseWidget {
|
||||
* @todo Expose CanvasPointer API to custom widgets
|
||||
*/
|
||||
mouse?(event: CanvasPointerEvent, pointerOffset: Point, node: LGraphNode): boolean
|
||||
/**
|
||||
* Draw the widget.
|
||||
* @param ctx The canvas context to draw on.
|
||||
* @param node The node this widget belongs to.
|
||||
* @param widget_width The width of the widget.
|
||||
* @param y The y position of the widget.
|
||||
* @param H The height of the widget.
|
||||
* @param lowQuality Whether to draw the widget in low quality.
|
||||
*/
|
||||
draw?(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
node: LGraphNode,
|
||||
widget_width: number,
|
||||
y: number,
|
||||
H: number,
|
||||
lowQuality?: boolean,
|
||||
): void
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user