Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/LGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3431,8 +3431,13 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
const outlineColour = widget.advanced ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR : LiteGraph.WIDGET_OUTLINE_COLOR

widget.last_y = y

// Check if widget has an input connection
const connectedSlot = this.getSlotFromWidget(widget)
const stripValue = connectedSlot?.link != null
// Disable widget if it is disabled or if the value is passed from socket connection.
widget.computedDisabled = widget.disabled || this.getSlotFromWidget(widget)?.link != null
widget.computedDisabled = widget.disabled || stripValue
widget.computedStripValue = stripValue

ctx.strokeStyle = outlineColour
ctx.fillStyle = "#222"
Expand All @@ -3443,7 +3448,10 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
if (typeof widget.draw === "function") {
widget.draw(ctx, this, width, y, H, lowQuality)
} else {
toConcreteWidget(widget, this, false)?.drawWidget(ctx, { width, showText })
toConcreteWidget(widget, this, false)?.drawWidget(ctx, {
width,
showText,
})
}
ctx.globalAlpha = editorAlpha
}
Expand Down
6 changes: 6 additions & 0 deletions src/types/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ export interface IBaseWidget<
*/
computedDisabled?: boolean

/**
* Whether the widget value should be hidden.
* @readonly [Computed] This property is computed by the node.
*/
computedStripValue?: boolean

hidden?: boolean
advanced?: boolean

Expand Down
8 changes: 8 additions & 0 deletions src/widgets/BaseWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget> impl
width?: number
disabled?: boolean
computedDisabled?: boolean
computedStripValue?: boolean
hidden?: boolean
advanced?: boolean
tooltip?: string
Expand Down Expand Up @@ -211,6 +212,13 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget> impl

ctx.fillStyle = this.secondary_text_color

if (this.computedStripValue) {
// When the value is hidden, only show the name of the widget
drawTextInArea({ ctx, text: displayName, area, align: "left" })
ctx.fillStyle = this.text_color
return
}

if (requiredWidth <= totalWidth) {
// Draw label & value normally
drawTextInArea({ ctx, text: displayName, area, align: "left" })
Expand Down
Loading