mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 07:44:11 +00:00
Support for hidden & advanced widgets (#250)
This commit is contained in:
@@ -180,6 +180,7 @@ export class LGraphNode {
|
||||
has_errors?: boolean
|
||||
removable?: boolean
|
||||
block_delete?: boolean
|
||||
showAdvanced?: boolean
|
||||
|
||||
_pos: Point
|
||||
public get pos() {
|
||||
@@ -408,7 +409,8 @@ export class LGraphNode {
|
||||
size: this.size,
|
||||
flags: LiteGraph.cloneObject(this.flags),
|
||||
order: this.order,
|
||||
mode: this.mode
|
||||
mode: this.mode,
|
||||
showAdvanced: this.showAdvanced
|
||||
}
|
||||
|
||||
//special case for when there were errors
|
||||
@@ -1265,6 +1267,7 @@ export class LGraphNode {
|
||||
if (this.widgets?.length) {
|
||||
for (let i = 0, l = this.widgets.length; i < l; ++i) {
|
||||
const widget = this.widgets[i]
|
||||
if (widget.hidden || (widget.advanced && !this.showAdvanced)) continue;
|
||||
|
||||
widgets_height += widget.computeSize
|
||||
? widget.computeSize(size[0])[1] + 4
|
||||
@@ -2297,6 +2300,20 @@ export class LGraphNode {
|
||||
this.setDirtyCanvas(true, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles advanced mode of the node, showing advanced widgets
|
||||
*/
|
||||
toggleAdvanced() {
|
||||
if (!this.widgets?.some(w => w.advanced)) return
|
||||
this.graph._version++
|
||||
this.showAdvanced = !this.showAdvanced
|
||||
const prefSize = this.computeSize()
|
||||
if (this.size[0] < prefSize[0] || this.size[1] < prefSize[1]) {
|
||||
this.setSize([Math.max(this.size[0], prefSize[0]), Math.max(this.size[1], prefSize[1])])
|
||||
}
|
||||
this.setDirtyCanvas(true, true)
|
||||
}
|
||||
|
||||
get pinned() {
|
||||
return !!this.flags.pinned
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user