QskLayoutEngine2D::sizeHint fixed
This commit is contained in:
parent
84248098ca
commit
71d3896efe
|
@ -384,18 +384,7 @@ QSizeF QskGridBox::layoutSizeHint(
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hint = m_data->engine.sizeHint( which, constraint );
|
return m_data->engine.sizeHint( which, constraint );
|
||||||
|
|
||||||
if ( constraint.width() >= 0.0 )
|
|
||||||
{
|
|
||||||
hint.setWidth( -1.0 );
|
|
||||||
}
|
|
||||||
else if ( constraint.height() >= 0.0 )
|
|
||||||
{
|
|
||||||
hint.setHeight( -1.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return hint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskGridBox::geometryChangeEvent( QskGeometryChangeEvent* event )
|
void QskGridBox::geometryChangeEvent( QskGeometryChangeEvent* event )
|
||||||
|
|
|
@ -379,56 +379,99 @@ qreal QskLayoutEngine2D::heightForWidth( qreal width ) const
|
||||||
QSizeF QskLayoutEngine2D::sizeHint(
|
QSizeF QskLayoutEngine2D::sizeHint(
|
||||||
Qt::SizeHint which, const QSizeF& constraint ) const
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||||
{
|
{
|
||||||
|
if ( constraint.isValid() )
|
||||||
|
return constraint; // should never happen
|
||||||
|
|
||||||
if ( effectiveCount( Qt::Horizontal ) <= 0 )
|
if ( effectiveCount( Qt::Horizontal ) <= 0 )
|
||||||
return QSizeF( 0.0, 0.0 );
|
return QSizeF( 0.0, 0.0 );
|
||||||
|
|
||||||
|
auto requestType = constraintType();
|
||||||
|
|
||||||
|
switch ( requestType )
|
||||||
|
{
|
||||||
|
case QskSizePolicy::HeightForWidth:
|
||||||
|
{
|
||||||
|
if ( constraint.height() >= 0 )
|
||||||
|
{
|
||||||
|
qWarning( "QskLayoutEngine2D: HeightForWidth conflict." );
|
||||||
|
return QSizeF();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( constraint.width() <= 0 )
|
||||||
|
requestType = QskSizePolicy::Unconstrained;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QskSizePolicy::WidthForHeight:
|
||||||
|
{
|
||||||
|
if ( constraint.width() >= 0 )
|
||||||
|
{
|
||||||
|
qWarning( "QskLayoutEngine2D: WidthForHeight conflict." );
|
||||||
|
return QSizeF();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( constraint.height() <= 0 )
|
||||||
|
requestType = QskSizePolicy::Unconstrained;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if ( constraint.height() >= 0 || constraint.width() >= 0 )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
As none of the items have the Constrained flag the constraint
|
||||||
|
will have no effect and we ignore it to make use of the cached
|
||||||
|
results from unconstrained requests
|
||||||
|
*/
|
||||||
|
qWarning( "QskLayoutEngine2D: constraint will be ignored." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto& rowChain = m_data->rowChain;
|
auto& rowChain = m_data->rowChain;
|
||||||
auto& columnChain = m_data->columnChain;
|
auto& columnChain = m_data->columnChain;
|
||||||
|
|
||||||
if ( constraint.width() >= 0.0 || constraint.height() >= 0.0 )
|
|
||||||
{
|
|
||||||
const auto type = constraintType();
|
|
||||||
|
|
||||||
if ( constraint.width() >= 0 )
|
|
||||||
{
|
|
||||||
if ( type == QskSizePolicy::WidthForHeight )
|
|
||||||
qWarning( "QskLayoutEngine2D: WidthForHeight conflict." );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( type == QskSizePolicy::HeightForWidth )
|
|
||||||
qWarning( "QskLayoutEngine2D: HeightForWidth conflict." );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_data->blockInvalidate = true;
|
m_data->blockInvalidate = true;
|
||||||
|
|
||||||
if ( constraint.width() >= 0 )
|
switch( requestType )
|
||||||
|
{
|
||||||
|
case QskSizePolicy::HeightForWidth:
|
||||||
{
|
{
|
||||||
setupChain( Qt::Horizontal );
|
setupChain( Qt::Horizontal );
|
||||||
|
|
||||||
const auto constraints = columnChain.segments( constraint.width() );
|
const auto constraints = columnChain.segments( constraint.width() );
|
||||||
setupChain( Qt::Vertical, constraints );
|
setupChain( Qt::Vertical, constraints );
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if ( constraint.height() >= 0 )
|
case QskSizePolicy::WidthForHeight:
|
||||||
{
|
{
|
||||||
setupChain( Qt::Vertical );
|
setupChain( Qt::Vertical );
|
||||||
|
|
||||||
const auto constraints = rowChain.segments( constraint.height() );
|
const auto constraints = rowChain.segments( constraint.height() );
|
||||||
setupChain( Qt::Horizontal, constraints );
|
setupChain( Qt::Horizontal, constraints );
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
default:
|
||||||
{
|
{
|
||||||
setupChain( Qt::Horizontal );
|
setupChain( Qt::Horizontal );
|
||||||
setupChain( Qt::Vertical );
|
setupChain( Qt::Vertical );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_data->blockInvalidate = false;
|
m_data->blockInvalidate = false;
|
||||||
|
|
||||||
const qreal width = columnChain.boundingHint().size( which );
|
QSizeF hint;
|
||||||
const qreal height = rowChain.boundingHint().size( which );
|
|
||||||
|
|
||||||
return QSizeF( width, height );
|
if ( constraint.width() <= 0.0 )
|
||||||
|
hint.rwidth() = columnChain.boundingHint().size( which );
|
||||||
|
|
||||||
|
if ( constraint.height() <= 0.0 )
|
||||||
|
hint.rheight() = rowChain.boundingHint().size( which );
|
||||||
|
|
||||||
|
return hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskLayoutHint QskLayoutEngine2D::layoutHint( const QQuickItem* item,
|
QskLayoutHint QskLayoutEngine2D::layoutHint( const QQuickItem* item,
|
||||||
|
@ -493,8 +536,7 @@ void QskLayoutEngine2D::setupChain( Qt::Orientation orientation,
|
||||||
|
|
||||||
auto& chain = m_data->layoutChain( orientation );
|
auto& chain = m_data->layoutChain( orientation );
|
||||||
|
|
||||||
if ( ( chain.constraint() == constraint )
|
if ( ( chain.constraint() == constraint ) && ( chain.count() == count ) )
|
||||||
&& ( chain.count() == count ) )
|
|
||||||
{
|
{
|
||||||
return; // already up to date
|
return; // already up to date
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,18 +212,7 @@ QSizeF QskLinearBox::layoutSizeHint(
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hint = m_data->engine.sizeHint( which, constraint );
|
return m_data->engine.sizeHint( which, constraint );
|
||||||
|
|
||||||
if ( constraint.width() >= 0.0 )
|
|
||||||
{
|
|
||||||
hint.setWidth( -1.0 );
|
|
||||||
}
|
|
||||||
else if ( constraint.height() >= 0.0 )
|
|
||||||
{
|
|
||||||
hint.setHeight( -1.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return hint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskLinearBox::geometryChangeEvent( QskGeometryChangeEvent* event )
|
void QskLinearBox::geometryChangeEvent( QskGeometryChangeEvent* event )
|
||||||
|
|
Loading…
Reference in New Issue