handling of multicells improved
This commit is contained in:
parent
01cb089856
commit
7075879244
@ -85,7 +85,6 @@ void QskLayoutChain::expandCell( int index, const CellData& newCell )
|
|||||||
if ( !cell.isValid )
|
if ( !cell.isValid )
|
||||||
{
|
{
|
||||||
cell = newCell;
|
cell = newCell;
|
||||||
cell.stretch = qMax( cell.stretch, 0 );
|
|
||||||
m_validCells++;
|
m_validCells++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -105,57 +104,62 @@ void QskLayoutChain::expandCells(
|
|||||||
int index, int count, const CellData& multiCell )
|
int index, int count, const CellData& multiCell )
|
||||||
{
|
{
|
||||||
QskLayoutChain chain;
|
QskLayoutChain chain;
|
||||||
|
chain.setSpacing( m_spacing );
|
||||||
chain.reset( count, -1 );
|
chain.reset( count, -1 );
|
||||||
|
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
chain.expandCell( i, m_cells[ index + i ] );
|
|
||||||
|
|
||||||
auto& cell = chain.m_cells[ i ];
|
auto& cell = chain.m_cells[ i ];
|
||||||
#if 1
|
cell = m_cells[ index + i ];
|
||||||
// what to do now ??
|
|
||||||
if ( !cell.isValid )
|
if ( !cell.isValid )
|
||||||
{
|
{
|
||||||
cell.isValid = true;
|
cell.isValid = true;
|
||||||
cell.canGrow = multiCell.canGrow;
|
cell.canGrow = multiCell.canGrow;
|
||||||
cell.stretch = qMax( cell.stretch, 0 );
|
cell.stretch = multiCell.stretch;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
chain.m_validCells = count;
|
chain.finish();
|
||||||
|
|
||||||
QVarLengthArray< QskLayoutHint > hints( count );
|
QskLayoutChain::Segments minimum;
|
||||||
|
QskLayoutChain::Segments preferred;
|
||||||
|
QskLayoutChain::Segments maximum;
|
||||||
|
|
||||||
const auto& hint = multiCell.hint;
|
|
||||||
const auto chainHint = chain.boundingHint();
|
const auto chainHint = chain.boundingHint();
|
||||||
|
|
||||||
if ( hint.minimum() > chainHint.minimum() )
|
if ( multiCell.hint.minimum() > chainHint.minimum() )
|
||||||
{
|
minimum = chain.segments( multiCell.hint.minimum() );
|
||||||
const auto segments = chain.segments( hint.minimum() );
|
|
||||||
for ( int i = 0; i < count; i++ )
|
|
||||||
hints[i].setMinimum( segments[i].length );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( hint.preferred() > chainHint.preferred() )
|
if ( multiCell.hint.preferred() > chainHint.preferred() )
|
||||||
{
|
preferred = chain.segments( multiCell.hint.preferred() );
|
||||||
const auto segments = chain.segments( hint.preferred() );
|
|
||||||
for ( int i = 0; i < count; i++ )
|
|
||||||
hints[i].setPreferred( segments[i].length );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( hint.maximum() < chainHint.maximum() )
|
if ( chainHint.maximum() == QskLayoutConstraint::unlimited )
|
||||||
{
|
{
|
||||||
const auto segments = chain.segments( hint.maximum() );
|
if ( multiCell.hint.maximum() < QskLayoutConstraint::unlimited )
|
||||||
for ( int i = 0; i < count; i++ )
|
maximum = chain.segments( multiCell.hint.maximum() );
|
||||||
hints[i].setMaximum( segments[i].length );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
auto cell = multiCell;
|
auto& cell = m_cells[ index + i ];
|
||||||
cell.hint = hints[i];
|
|
||||||
|
|
||||||
expandCell( index + i, cell );
|
cell.canGrow |= multiCell.canGrow;
|
||||||
|
cell.stretch = qMax( cell.stretch, multiCell.stretch );
|
||||||
|
|
||||||
|
if ( !minimum.isEmpty() )
|
||||||
|
cell.hint.expandMinimum( minimum[i].length );
|
||||||
|
|
||||||
|
if ( !preferred.isEmpty() )
|
||||||
|
cell.hint.expandPreferred( preferred[i].length );
|
||||||
|
|
||||||
|
if ( !maximum.isEmpty() && !cell.isValid )
|
||||||
|
cell.hint.setMaximum( maximum[i].length );
|
||||||
|
|
||||||
|
if ( !cell.isValid )
|
||||||
|
{
|
||||||
|
cell.isValid = true;
|
||||||
|
m_validCells++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,13 @@ void QskLayoutHint::setSize( int which, qreal size )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskLayoutHint::expandTo( const QskLayoutHint& other )
|
||||||
|
{
|
||||||
|
m_minimum = qMax( m_minimum, other.m_minimum );
|
||||||
|
m_preferred = qMax( m_preferred, other.m_preferred );
|
||||||
|
m_maximum = qMax( m_maximum, other.m_maximum );
|
||||||
|
}
|
||||||
|
|
||||||
void QskLayoutHint::normalize()
|
void QskLayoutHint::normalize()
|
||||||
{
|
{
|
||||||
m_minimum = qMax( m_minimum, qreal( 0.0 ) );
|
m_minimum = qMax( m_minimum, qreal( 0.0 ) );
|
||||||
|
@ -38,6 +38,11 @@ class QSK_EXPORT QskLayoutHint
|
|||||||
qreal maximum() const;
|
qreal maximum() const;
|
||||||
|
|
||||||
void setSizes( qreal minimum, qreal preferred, qreal maximum );
|
void setSizes( qreal minimum, qreal preferred, qreal maximum );
|
||||||
|
void expandTo( const QskLayoutHint& );
|
||||||
|
|
||||||
|
void expandMinimum( qreal value );
|
||||||
|
void expandPreferred( qreal value );
|
||||||
|
void expandMaximum( qreal value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_minimum;
|
qreal m_minimum;
|
||||||
@ -75,6 +80,24 @@ inline void QskLayoutHint::setMaximum( qreal value )
|
|||||||
m_maximum = value;
|
m_maximum = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void QskLayoutHint::expandMinimum( qreal value )
|
||||||
|
{
|
||||||
|
if ( value > m_minimum )
|
||||||
|
m_minimum = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void QskLayoutHint::expandPreferred( qreal value )
|
||||||
|
{
|
||||||
|
if ( value > m_preferred )
|
||||||
|
m_preferred = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void QskLayoutHint::expandMaximum( qreal value )
|
||||||
|
{
|
||||||
|
if ( value > m_maximum )
|
||||||
|
m_maximum = value;
|
||||||
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::setSizes(
|
inline void QskLayoutHint::setSizes(
|
||||||
qreal minimum, qreal preferred, qreal maximum )
|
qreal minimum, qreal preferred, qreal maximum )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user