block resizing of children, when having no width/height

This commit is contained in:
Uwe Rathmann 2019-09-20 07:08:08 +02:00
parent 03c7913f18
commit c6553c3310

View File

@ -171,8 +171,6 @@ void QskControl::setMargins( const QMarginsF& margins )
{ {
using namespace QskAspect; using namespace QskAspect;
const auto subControl = effectiveSubcontrol( QskAspect::Control );
const QMarginsF m( const QMarginsF m(
qMax( qreal( margins.left() ), qreal( 0.0 ) ), qMax( qreal( margins.left() ), qreal( 0.0 ) ),
qMax( qreal( margins.top() ), qreal( 0.0 ) ), qMax( qreal( margins.top() ), qreal( 0.0 ) ),
@ -181,6 +179,8 @@ void QskControl::setMargins( const QMarginsF& margins )
if ( m != this->margins() ) if ( m != this->margins() )
{ {
const auto subControl = effectiveSubcontrol( QskAspect::Control );
setMarginsHint( subControl | Margin, m ); setMarginsHint( subControl | Margin, m );
resetImplicitSize(); resetImplicitSize();
@ -892,8 +892,11 @@ void QskControl::windowDeactivateEvent()
void QskControl::updateItemPolish() void QskControl::updateItemPolish()
{ {
if ( d_func()->autoLayoutChildren && !maybeUnresized() updateResources(); // an extra dirty bit for this ???
&& ( width() > 0.0 || height() > 0.0 ) )
if ( width() >= 0.0 || height() >= 0.0 )
{
if ( d_func()->autoLayoutChildren && !maybeUnresized() )
{ {
const auto rect = layoutRect(); const auto rect = layoutRect();
@ -913,9 +916,9 @@ void QskControl::updateItemPolish()
} }
} }
updateResources();
updateLayout(); updateLayout();
} }
}
QSGNode* QskControl::updateItemPaintNode( QSGNode* node ) QSGNode* QskControl::updateItemPaintNode( QSGNode* node )
{ {
@ -980,16 +983,29 @@ QSizeF QskControl::layoutSizeHint(
qreal h = -1.0; qreal h = -1.0;
const auto children = childItems(); const auto children = childItems();
for ( const auto child : children ) for ( const auto child : children )
{ {
if ( qskIsVisibleToLayout( child ) ) if ( !qskIsVisibleToLayout( child ) )
continue;
const auto policy = qskSizePolicy( child );
if ( constraint.width() >= 0.0 && policy.isConstrained( Qt::Vertical ) )
{
const auto hint = qskSizeConstraint( child, which, constraint );
h = QskLayoutHint::combined( which, h, hint.height() );
}
else if ( constraint.height() >= 0.0 && policy.isConstrained( Qt::Horizontal ) )
{ {
const auto hint = qskSizeConstraint( child, which, constraint ); const auto hint = qskSizeConstraint( child, which, constraint );
if ( constraint.width() < 0.0 )
w = QskLayoutHint::combined( which, w, hint.width() ); w = QskLayoutHint::combined( which, w, hint.width() );
}
else
{
const auto hint = qskSizeConstraint( child, which, QSizeF() );
if ( constraint.height() < 0.0 ) w = QskLayoutHint::combined( which, w, hint.width() );
h = QskLayoutHint::combined( which, h, hint.height() ); h = QskLayoutHint::combined( which, h, hint.height() );
} }
} }