Skip to content

Commit

Permalink
Fix custom workflow UI reserving space for text outputs when there ar…
Browse files Browse the repository at this point in the history
…e none
  • Loading branch information
Acly committed Oct 28, 2024
1 parent 0d9e938 commit 11dcb3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ai_diffusion/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CustomNode(NamedTuple):
"External Tooling Nodes",
"comfyui-tooling-nodes",
"https://github.com/Acly/comfyui-tooling-nodes",
"19337dcc0e9ec56b3b4eca463090de55335a94fe",
"e86973fedfba49f48786ed6d9b8f0e5e1d093f25",
["ETN_LoadImageBase64", "ETN_LoadMaskBase64", "ETN_SendImageWebSocket", "ETN_Translate"],
),
CustomNode(
Expand Down
11 changes: 8 additions & 3 deletions ai_diffusion/ui/custom_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,18 @@ def value(self, value: dict[str, TextOutput]):
self._value = value
self._update()

@property
def is_visible(self):
return self._scroll_area.isVisible()

def _update(self):
if len(self._value) == 0:
self.expander.hide()
self._scroll_area.hide()
return
elif not self.expander.isVisible():
self.expander.show()
self._scroll_area.show()
self._scroll_area.setVisible(self.expander.isChecked())

widget = QWidget(self._scroll_area)
layout = QGridLayout()
Expand Down Expand Up @@ -618,15 +622,15 @@ def __init__(self):
self._layout.addLayout(actions_layout)
self._layout.addWidget(self._progress_bar)
self._layout.addWidget(self._error_text)
self._layout.addWidget(self._outputs, stretch=1)
self._layout.addWidget(self._outputs, stretch=0)
self._layout.addWidget(self._history, stretch=3)
self._layout.addWidget(self._live_preview, stretch=5)
self.setLayout(self._layout)

self._update_ui()

def _update_layout(self):
stretch = 1 if self._outputs.expander.isChecked() else 0
stretch = 1 if self._outputs.is_visible else 0
self._layout.setStretchFactor(self._outputs, stretch)

@property
Expand All @@ -642,6 +646,7 @@ def model(self, model: Model):
bind(model, "workspace", self._workspace_select, "value", Bind.one_way),
bind_combo(model.custom, "workflow_id", self._workflow_select, Bind.one_way),
bind(model.custom, "outputs", self._outputs, "value", Bind.one_way),
model.custom.outputs_changed.connect(self._update_layout),
model.workspace_changed.connect(self._cancel_name),
model.custom.graph_changed.connect(self._update_current_workflow),
model.error_changed.connect(self._error_text.setText),
Expand Down

0 comments on commit 11dcb3e

Please sign in to comment.