Support associated socket for widgets (#891)

This PR is the litegraph side change necessary for widget sockets
feature in ComfyUI_frontend. Changes include

- Add readonly `Widget.computedDisabled` property for getting the
computed disabled state. When the associated socket is connected, the
widget is disabled
- Dynamically show the associated socket when
      - the mouse is over the widget
      - the slot is valid during link drop
      - the slot is connected
- Removes the legacy widget drop behavior

Ref: https://github.com/Comfy-Org/rfcs/pull/9
This commit is contained in:
Chenlei Hu
2025-04-05 16:29:37 -04:00
committed by GitHub
parent c07176eb08
commit 1ef4921c0a
12 changed files with 77 additions and 53 deletions

View File

@@ -45,7 +45,7 @@ export class ButtonWidget extends BaseWidget implements IButtonWidget {
ctx.fillRect(margin, y, width - margin * 2, height)
// Draw button outline if not disabled
if (show_text && !this.disabled) {
if (show_text && !this.computedDisabled) {
ctx.strokeStyle = this.outline_color
ctx.strokeRect(margin, y, width - margin * 2, height)
}