mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 11:40:00 +00:00
[Refactor] Remove redundant code (#1001)
Removes redundant code. After being refactored out of LGraphCanvas, the class methods were being passed their own properties as params.
This commit is contained in:
@@ -3374,35 +3374,34 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
}: DrawWidgetsOptions): void {
|
||||
if (!this.widgets) return
|
||||
|
||||
const width = this.size[0]
|
||||
const widgets = this.widgets
|
||||
const nodeWidth = this.size[0]
|
||||
const { widgets } = this
|
||||
const H = LiteGraph.NODE_WIDGET_HEIGHT
|
||||
const show_text = !lowQuality
|
||||
const showText = !lowQuality
|
||||
ctx.save()
|
||||
ctx.globalAlpha = editorAlpha
|
||||
const { margin } = BaseWidget
|
||||
|
||||
for (const w of widgets) {
|
||||
if (!this.isWidgetVisible(w)) continue
|
||||
for (const widget of widgets) {
|
||||
if (!this.isWidgetVisible(widget)) continue
|
||||
|
||||
const y = w.y
|
||||
const outline_color = w.advanced ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR : LiteGraph.WIDGET_OUTLINE_COLOR
|
||||
const { y } = widget
|
||||
const outlineColour = widget.advanced ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR : LiteGraph.WIDGET_OUTLINE_COLOR
|
||||
|
||||
w.last_y = y
|
||||
widget.last_y = y
|
||||
// Disable widget if it is disabled or if the value is passed from socket connection.
|
||||
w.computedDisabled = w.disabled || this.getSlotFromWidget(w)?.link != null
|
||||
widget.computedDisabled = widget.disabled || this.getSlotFromWidget(widget)?.link != null
|
||||
|
||||
ctx.strokeStyle = outline_color
|
||||
ctx.strokeStyle = outlineColour
|
||||
ctx.fillStyle = "#222"
|
||||
ctx.textAlign = "left"
|
||||
if (w.computedDisabled) ctx.globalAlpha *= 0.5
|
||||
const widget_width = w.width || width
|
||||
if (widget.computedDisabled) ctx.globalAlpha *= 0.5
|
||||
const width = widget.width || nodeWidth
|
||||
|
||||
const WidgetClass: typeof WIDGET_TYPE_MAP[string] = WIDGET_TYPE_MAP[w.type]
|
||||
const WidgetClass: typeof WIDGET_TYPE_MAP[string] = WIDGET_TYPE_MAP[widget.type]
|
||||
if (WidgetClass) {
|
||||
toClass(WidgetClass, w).drawWidget(ctx, { y, width: widget_width, show_text, margin })
|
||||
toClass(WidgetClass, widget).drawWidget(ctx, { width, showText })
|
||||
} else {
|
||||
w.draw?.(ctx, this, widget_width, y, H, lowQuality)
|
||||
widget.draw?.(ctx, this, width, y, H, lowQuality)
|
||||
}
|
||||
ctx.globalAlpha = editorAlpha
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user