#14122 Allow tree selection editor to grow only when it is the last row

The tree selection editor can grow to a large height, which is useful when it is the last field editor in the property dialog. When other field editors are located below, the heightHint is now used as the maximum height instead. The form layout tracks whether an editor occupies the bottom-most row of the form and passes this to the editor. In the Analysis Plot, the time step selection is constrained to its height hint because other input fields are located below it.
This commit is contained in:
Magne Sjaastad committed 2026-06-05 16:28:22 +02:00
1 parent cbae501a13
commit 98ea83146a
7 files changed
+77 -9

No files matched your search

@@ -88,12 +88,14 @@ caf::PdmUiFormLayoutObjectEditor::~PdmUiFormLayoutObjectEditor()
//--------------------------------------------------------------------------------------------------
bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInNewGridLayout( const PdmUiOrdering& uiOrdering,
QWidget* containerWidget,
const QString& uiConfigName )
const QString& uiConfigName,
bool parentRowIsLast )
{
QSize beforeSize = containerWidget->sizeHint();
ensureWidgetContainsEmptyGridLayout( containerWidget );
int stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayout( uiOrdering, containerWidget, uiConfigName );
int stretch =
recursivelyConfigureAndUpdateUiOrderingInGridLayout( uiOrdering, containerWidget, uiConfigName, parentRowIsLast );
QSize afterSize = containerWidget->sizeHint();
if ( beforeSize != afterSize )
@@ -110,7 +112,8 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
//--------------------------------------------------------------------------------------------------
int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayout( const PdmUiOrdering& uiOrdering,
QWidget* containerWidgetWithGridLayout,
const QString& uiConfigName )
const QString& uiConfigName,
bool parentRowIsLast )
{
int sumRowStretch = 0;
CAF_ASSERT( containerWidgetWithGridLayout );
@@ -130,6 +133,10 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG
{
int currentColumn = 0;
// True when this row is the bottom-most row of the entire form. Editors that can grow vertically
// use this to fill the remaining space rather than being constrained to a fixed height hint.
bool rowIsLast = parentRowIsLast && ( currentRowIndex == totalRows - 1 );
const PdmUiOrdering::RowLayout& uiItemsInRow = tableLayout[currentRowIndex];
int columnsRequiredForCurrentRow = uiOrdering.nrOfRequiredColumnsInRow( uiItemsInRow );
@@ -171,7 +178,8 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG
parentLayout,
currentRowIndex,
currentColumn,
itemColumnSpan );
itemColumnSpan,
rowIsLast );
parentLayout->setRowStretch( currentRowIndex, groupStretchFactor );
currentColumn += itemColumnSpan;
sumRowStretch += groupStretchFactor;
@@ -313,6 +321,7 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInG
parentLayout->setRowStretch( currentRowIndex, fieldEditor->rowStretchFactor() );
sumRowStretch += fieldEditor->rowStretchFactor();
}
fieldEditor->setIsInLastFormRow( rowIsLast );
fieldEditor->updateUi( uiConfigName );
}
}
@@ -334,13 +343,15 @@ int caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout( PdmUiItem
QGridLayout* parentLayout,
int currentRowIndex,
int currentColumn,
int itemColumnSpan )
int itemColumnSpan,
bool parentRowIsLast )
{
PdmUiGroup* group = static_cast<PdmUiGroup*>( currentItem );
QMinimizePanel* groupBox = findOrCreateGroupBox( containerWidgetWithGridLayout, group, uiConfigName );
int stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayout( *group, groupBox->contentFrame(), uiConfigName );
int stretch =
recursivelyConfigureAndUpdateUiOrderingInGridLayout( *group, groupBox->contentFrame(), uiConfigName, parentRowIsLast );
/// Insert the group box at the correct position of the parent layout
parentLayout->addWidget( groupBox, currentRowIndex, currentColumn, 1, itemColumnSpan );