Skip to content

Commit

Permalink
Reserve more space for custom params in case where none of the groups…
Browse files Browse the repository at this point in the history
… are expanded #1420
  • Loading branch information
Acly committed Nov 29, 2024
1 parent a1571c2 commit 89697ad
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ai_diffusion/ui/custom_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ class WorkflowParamsWidget(QWidget):
def __init__(self, params: list[CustomParam], parent: QWidget | None = None):
super().__init__(parent)
self._widgets: dict[str, CustomParamWidget] = {}
self._max_group_height = 0

layout = QGridLayout(self)
layout.setContentsMargins(0, 0, 2, 0)
Expand Down Expand Up @@ -454,8 +455,12 @@ def _notify(self):
self.value_changed.emit()

def _create_group(self, expander: GroupHeader | None, widgets: list[CustomParamWidget]):
display_height = sum(w.sizeHint().height() for w in widgets if not isinstance(w, QLabel))
display_height += 2 * len(widgets) # spacing
if expander is not None:
expander.set_group_widgets(widgets, len(self._widgets) < 7)
display_height += expander.sizeHint().height()
self._max_group_height = max(self._max_group_height, display_height)

@property
def value(self):
Expand All @@ -468,6 +473,10 @@ def value(self, values: dict[str, Any]):
if base_type_match(widget.value, value):
widget.value = value

@property
def min_size(self):
return self._max_group_height


class WorkflowOutputsWidget(QWidget):
def __init__(self, parent: QWidget):
Expand Down Expand Up @@ -821,6 +830,7 @@ def _update_current_workflow(self):

self._params_scroll.setWidget(self._params_widget)
widget_size = self._params_scroll.viewportSizeHint().height() + 4
widget_size = max(widget_size, self._params_widget.min_size)
params_size = min(self.height() // 2, widget_size)
self._params_scroll.setFixedHeight(params_size)
else:
Expand Down

0 comments on commit 89697ad

Please sign in to comment.