-
Notifications
You must be signed in to change notification settings - Fork 63
draft: Show widget name when connected, hiding only the value #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Previously, when a widget was connected to an input link, the entire widget's text (name and value) would disappear. This made it difficult to identify the widget's function at a glance. This commit modifies the drawing behavior to: - Only hide the widget's value when it has an active input connection. - Continue to display the widget's name/label. This improves user experience by providing better visual context for connected widgets. Refactor: - Introduced a \hideValue\ property in \LGraphNode.drawWidgets\ to decouple value visibility from the widget's disabled state. - Updated \BaseSteppedWidget\ and \TextWidget\ to render only the \displayName\ when the value is hidden.
@@ -3411,42 +3411,54 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { | |||
return !isHidden | |||
} | |||
|
|||
// sync number of widgets with the number of widgets in the node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the comment referring to?
// Check if locked: either disabled or has an input connection | ||
const connectedSlot = this.getSlotFromWidget(widget) | ||
widget.computedDisabled = widget.disabled || connectedSlot?.link != null | ||
;(widget as any).hideValue = connectedSlot?.link != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never use type assertions.
const { margin } = BaseWidget | ||
const x = margin * 2 | ||
const area = new Rectangle(x, this.y, options.width - x - margin, this.height * 0.7) | ||
ctx.fillStyle = this.secondary_text_color | ||
drawTextInArea({ | ||
ctx, | ||
text: this.displayName, | ||
area, | ||
align: "left", | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we are repeating this logic twice, can we extract to helper function or class method?
if (widget.computedDisabled) ctx.globalAlpha *= 0.5 | ||
const width = widget.width || nodeWidth | ||
|
||
const forceHideValue = (widget as any).hideValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never use type assertions. We need to look through the code to understand the classes, interfaces, types, and so on. After that, we should implement a solution that naturally extends the current system. If we do this successfuly, we may find that we never need to use type assertions.
To do this properly, it may require approaching the problem by doing research and asking LLM to explain the architecture and objects/classes in the codebase first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure ty for the advice.
Related to Comfy-Org/ComfyUI_frontend#4025
Previously, when a widget was connected to an input link, the entire widget's text (name and value) would disappear. This made it difficult to identify the widget's function at a glance.
This commit modifies the drawing behavior to:
This improves user experience by providing better visual context for connected widgets.
Refactor: