QskLayoutHint renamed to QskLayoutMetrics
This commit is contained in:
parent
d0b07cc465
commit
c3dc970a94
@ -20,7 +20,7 @@
|
|||||||
#include <QskGradient.h>
|
#include <QskGradient.h>
|
||||||
#include <QskGraphicLabel.h>
|
#include <QskGraphicLabel.h>
|
||||||
#include <QskIntervalF.h>
|
#include <QskIntervalF.h>
|
||||||
#include <QskLayoutHint.h>
|
#include <QskLayoutMetrics.h>
|
||||||
#include <QskMargins.h>
|
#include <QskMargins.h>
|
||||||
#include <QskMessageWindow.h>
|
#include <QskMessageWindow.h>
|
||||||
#include <QskPopup.h>
|
#include <QskPopup.h>
|
||||||
@ -201,7 +201,7 @@ void QskQml::registerTypes()
|
|||||||
QSK_REGISTER_GADGET( QskGradient, "Gradient" );
|
QSK_REGISTER_GADGET( QskGradient, "Gradient" );
|
||||||
QSK_REGISTER_GADGET( QskGradientStop, "GradientStop" );
|
QSK_REGISTER_GADGET( QskGradientStop, "GradientStop" );
|
||||||
QSK_REGISTER_GADGET( QskIntervalF, "IntervalF" );
|
QSK_REGISTER_GADGET( QskIntervalF, "IntervalF" );
|
||||||
QSK_REGISTER_GADGET( QskLayoutHint, "LayoutHint" );
|
QSK_REGISTER_GADGET( QskLayoutMetrics, "LayoutMetrics" );
|
||||||
QSK_REGISTER_GADGET( QskSizePolicy, "SizePolicy" );
|
QSK_REGISTER_GADGET( QskSizePolicy, "SizePolicy" );
|
||||||
QSK_REGISTER_GADGET( QskTextOptions, "TextOptions" );
|
QSK_REGISTER_GADGET( QskTextOptions, "TextOptions" );
|
||||||
QSK_REGISTER_GADGET( QskMargins, "Margins" );
|
QSK_REGISTER_GADGET( QskMargins, "Margins" );
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "QskControlPrivate.h"
|
#include "QskControlPrivate.h"
|
||||||
#include "QskSetup.h"
|
#include "QskSetup.h"
|
||||||
#include "QskLayoutHint.h"
|
#include "QskLayoutMetrics.h"
|
||||||
|
|
||||||
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
|
static inline void qskSendEventTo( QObject* object, QEvent::Type type )
|
||||||
{
|
{
|
||||||
@ -173,10 +173,10 @@ QSizeF QskControlPrivate::implicitSizeHint(
|
|||||||
qreal h = constraint.height();
|
qreal h = constraint.height();
|
||||||
|
|
||||||
if ( w < 0.0 )
|
if ( w < 0.0 )
|
||||||
w = QskLayoutHint::combined( which, contentsHint.width(), layoutHint.width() );
|
w = QskLayoutMetrics::combined( which, contentsHint.width(), layoutHint.width() );
|
||||||
|
|
||||||
if ( h < 0.0 )
|
if ( h < 0.0 )
|
||||||
h = QskLayoutHint::combined( which, contentsHint.height(), layoutHint.height() );
|
h = QskLayoutMetrics::combined( which, contentsHint.height(), layoutHint.height() );
|
||||||
|
|
||||||
return QSizeF( w, h );
|
return QSizeF( w, h );
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskGridLayoutEngine.h"
|
#include "QskGridLayoutEngine.h"
|
||||||
#include "QskLayoutHint.h"
|
#include "QskLayoutMetrics.h"
|
||||||
#include "QskLayoutChain.h"
|
#include "QskLayoutChain.h"
|
||||||
#include "QskSizePolicy.h"
|
#include "QskSizePolicy.h"
|
||||||
#include "QskQuick.h"
|
#include "QskQuick.h"
|
||||||
@ -30,7 +30,7 @@ namespace
|
|||||||
public:
|
public:
|
||||||
inline bool isDefault() const
|
inline bool isDefault() const
|
||||||
{
|
{
|
||||||
return m_stretch < 0 && m_hint.isDefault();
|
return m_stretch < 0 && m_metrics.isDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setStretch( int stretch )
|
bool setStretch( int stretch )
|
||||||
@ -43,11 +43,11 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setHint( Qt::SizeHint which, qreal size )
|
bool setMetric( Qt::SizeHint which, qreal metric )
|
||||||
{
|
{
|
||||||
if ( size != m_hint.size( which ) )
|
if ( metric != m_metrics.metric( which ) )
|
||||||
{
|
{
|
||||||
m_hint.setSize( which, size );
|
m_metrics.setMetric( which, metric );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -56,7 +56,7 @@ namespace
|
|||||||
QskLayoutChain::CellData cell() const
|
QskLayoutChain::CellData cell() const
|
||||||
{
|
{
|
||||||
QskLayoutChain::CellData cell;
|
QskLayoutChain::CellData cell;
|
||||||
cell.hint = m_hint.normalized();
|
cell.metrics = m_metrics.normalized();
|
||||||
cell.stretch = m_stretch;
|
cell.stretch = m_stretch;
|
||||||
cell.canGrow = m_stretch != 0;
|
cell.canGrow = m_stretch != 0;
|
||||||
cell.isValid = true;
|
cell.isValid = true;
|
||||||
@ -65,13 +65,13 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline int stretch() const { return m_stretch; }
|
inline int stretch() const { return m_stretch; }
|
||||||
inline QskLayoutHint hint() const { return m_hint; }
|
inline QskLayoutMetrics metrics() const { return m_metrics; }
|
||||||
|
|
||||||
int position = -1;
|
int position = -1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_stretch = -1;
|
int m_stretch = -1;
|
||||||
QskLayoutHint m_hint;
|
QskLayoutMetrics m_metrics;
|
||||||
};
|
};
|
||||||
|
|
||||||
int maxPosition() const
|
int maxPosition() const
|
||||||
@ -95,12 +95,12 @@ namespace
|
|||||||
return setValueAt( index, setStretch );
|
return setValueAt( index, setStretch );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setHintAt( int index, Qt::SizeHint which, qreal size )
|
bool setMetricAt( int index, Qt::SizeHint which, qreal size )
|
||||||
{
|
{
|
||||||
auto setHint = [which, size]( Setting& s )
|
auto setMetric = [which, size]( Setting& s )
|
||||||
{ return s.setHint( which, size ); };
|
{ return s.setMetric( which, size ); };
|
||||||
|
|
||||||
return setValueAt( index, setHint );
|
return setValueAt( index, setMetric );
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting settingAt( int index ) const
|
Setting settingAt( int index ) const
|
||||||
@ -276,9 +276,9 @@ QskLayoutChain::CellData Element::cell( Qt::Orientation orientation ) const
|
|||||||
const qreal value = ( orientation == Qt::Horizontal )
|
const qreal value = ( orientation == Qt::Horizontal )
|
||||||
? m_spacing.width() : m_spacing.height();
|
? m_spacing.width() : m_spacing.height();
|
||||||
|
|
||||||
cell.hint.setMinimum( value );
|
cell.metrics.setMinimum( value );
|
||||||
cell.hint.setPreferred( value );
|
cell.metrics.setPreferred( value );
|
||||||
cell.hint.setMaximum( value );
|
cell.metrics.setMaximum( value );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -423,7 +423,7 @@ int QskGridLayoutEngine::stretchFactor(
|
|||||||
bool QskGridLayoutEngine::setRowSizeHint(
|
bool QskGridLayoutEngine::setRowSizeHint(
|
||||||
int row, Qt::SizeHint which, qreal height )
|
int row, Qt::SizeHint which, qreal height )
|
||||||
{
|
{
|
||||||
if ( !m_data->rowSettings.setHintAt( row, which, height ) )
|
if ( !m_data->rowSettings.setMetricAt( row, which, height ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( row >= m_data->rowCount )
|
if ( row >= m_data->rowCount )
|
||||||
@ -436,13 +436,13 @@ bool QskGridLayoutEngine::setRowSizeHint(
|
|||||||
qreal QskGridLayoutEngine::rowSizeHint( int row, Qt::SizeHint which ) const
|
qreal QskGridLayoutEngine::rowSizeHint( int row, Qt::SizeHint which ) const
|
||||||
{
|
{
|
||||||
const auto& settings = m_data->rowSettings;
|
const auto& settings = m_data->rowSettings;
|
||||||
return settings.settingAt( row ).hint().size( which );
|
return settings.settingAt( row ).metrics().metric( which );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskGridLayoutEngine::setColumnSizeHint(
|
bool QskGridLayoutEngine::setColumnSizeHint(
|
||||||
int column, Qt::SizeHint which, qreal width )
|
int column, Qt::SizeHint which, qreal width )
|
||||||
{
|
{
|
||||||
if ( !m_data->columnSettings.setHintAt( column, which, width ) )
|
if ( !m_data->columnSettings.setMetricAt( column, which, width ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( column >= m_data->columnCount )
|
if ( column >= m_data->columnCount )
|
||||||
@ -455,7 +455,7 @@ bool QskGridLayoutEngine::setColumnSizeHint(
|
|||||||
qreal QskGridLayoutEngine::columnSizeHint( int column, Qt::SizeHint which ) const
|
qreal QskGridLayoutEngine::columnSizeHint( int column, Qt::SizeHint which ) const
|
||||||
{
|
{
|
||||||
const auto& settings = m_data->columnSettings;
|
const auto& settings = m_data->columnSettings;
|
||||||
return settings.settingAt( column ).hint().size( which );
|
return settings.settingAt( column ).metrics().metric( which );
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskGridLayoutEngine::insertItem( QQuickItem* item, const QRect& grid )
|
int QskGridLayoutEngine::insertItem( QQuickItem* item, const QRect& grid )
|
||||||
@ -645,7 +645,7 @@ void QskGridLayoutEngine::setupChain( Qt::Orientation orientation,
|
|||||||
|
|
||||||
auto cell = element.cell( orientation );
|
auto cell = element.cell( orientation );
|
||||||
if ( element.item() )
|
if ( element.item() )
|
||||||
cell.hint = layoutHint( element.item(), orientation, constraint );
|
cell.metrics = layoutMetrics( element.item(), orientation, constraint );
|
||||||
|
|
||||||
chain.expandCell( grid.top(), cell );
|
chain.expandCell( grid.top(), cell );
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ void QskGridLayoutEngine::setupChain( Qt::Orientation orientation,
|
|||||||
constraint = qskSegmentLength( constraints, grid.left(), grid.right() );
|
constraint = qskSegmentLength( constraints, grid.left(), grid.right() );
|
||||||
|
|
||||||
auto cell = element->cell( orientation );
|
auto cell = element->cell( orientation );
|
||||||
cell.hint = layoutHint( element->item(), orientation, constraint );
|
cell.metrics = layoutMetrics( element->item(), orientation, constraint );
|
||||||
|
|
||||||
chain.expandCells( grid.top(), grid.height(), cell );
|
chain.expandCells( grid.top(), grid.height(), cell );
|
||||||
}
|
}
|
||||||
|
@ -52,21 +52,21 @@ void QskLayoutChain::shrinkCell( int index, const CellData& newCell )
|
|||||||
if ( newCell.stretch >= 0 )
|
if ( newCell.stretch >= 0 )
|
||||||
cell.stretch = qMax( cell.stretch, newCell.stretch );
|
cell.stretch = qMax( cell.stretch, newCell.stretch );
|
||||||
|
|
||||||
if ( !newCell.hint.isDefault() )
|
if ( !newCell.metrics.isDefault() )
|
||||||
{
|
{
|
||||||
auto& hint = cell.hint;
|
auto& metrics = cell.metrics;
|
||||||
auto& newHint = newCell.hint;
|
auto& newMetrics = newCell.metrics;
|
||||||
|
|
||||||
hint.setMinimum( qMax( hint.minimum(), newHint.minimum() ) );
|
metrics.setMinimum( qMax( metrics.minimum(), newMetrics.minimum() ) );
|
||||||
hint.setPreferred( qMax( hint.preferred(), newHint.preferred() ) );
|
metrics.setPreferred( qMax( metrics.preferred(), newMetrics.preferred() ) );
|
||||||
|
|
||||||
if ( newHint.maximum() < hint.maximum() )
|
if ( newMetrics.maximum() < metrics.maximum() )
|
||||||
{
|
{
|
||||||
hint.setMaximum( newHint.maximum() );
|
metrics.setMaximum( newMetrics.maximum() );
|
||||||
cell.isShrunk = true;
|
cell.isShrunk = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.hint.normalize();
|
cell.metrics.normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,10 +88,10 @@ void QskLayoutChain::expandCell( int index, const CellData& newCell )
|
|||||||
cell.canGrow |= newCell.canGrow;
|
cell.canGrow |= newCell.canGrow;
|
||||||
cell.stretch = qMax( cell.stretch, newCell.stretch );
|
cell.stretch = qMax( cell.stretch, newCell.stretch );
|
||||||
|
|
||||||
cell.hint.setSizes(
|
cell.metrics.setMetrics(
|
||||||
qMax( cell.hint.minimum(), newCell.hint.minimum() ),
|
qMax( cell.metrics.minimum(), newCell.metrics.minimum() ),
|
||||||
qMax( cell.hint.preferred(), newCell.hint.preferred() ),
|
qMax( cell.metrics.preferred(), newCell.metrics.preferred() ),
|
||||||
qMax( cell.hint.maximum(), newCell.hint.maximum() )
|
qMax( cell.metrics.maximum(), newCell.metrics.maximum() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,18 +121,18 @@ void QskLayoutChain::expandCells(
|
|||||||
QskLayoutChain::Segments preferred;
|
QskLayoutChain::Segments preferred;
|
||||||
QskLayoutChain::Segments maximum;
|
QskLayoutChain::Segments maximum;
|
||||||
|
|
||||||
const auto chainHint = chain.boundingHint();
|
const auto chainMetrics = chain.boundingMetrics();
|
||||||
|
|
||||||
if ( multiCell.hint.minimum() > chainHint.minimum() )
|
if ( multiCell.metrics.minimum() > chainMetrics.minimum() )
|
||||||
minimum = chain.segments( multiCell.hint.minimum() );
|
minimum = chain.segments( multiCell.metrics.minimum() );
|
||||||
|
|
||||||
if ( multiCell.hint.preferred() > chainHint.preferred() )
|
if ( multiCell.metrics.preferred() > chainMetrics.preferred() )
|
||||||
preferred = chain.segments( multiCell.hint.preferred() );
|
preferred = chain.segments( multiCell.metrics.preferred() );
|
||||||
|
|
||||||
if ( chainHint.maximum() == QskLayoutHint::unlimited )
|
if ( chainMetrics.maximum() == QskLayoutMetrics::unlimited )
|
||||||
{
|
{
|
||||||
if ( multiCell.hint.maximum() < QskLayoutHint::unlimited )
|
if ( multiCell.metrics.maximum() < QskLayoutMetrics::unlimited )
|
||||||
maximum = chain.segments( multiCell.hint.maximum() );
|
maximum = chain.segments( multiCell.metrics.maximum() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < count; i++ )
|
for ( int i = 0; i < count; i++ )
|
||||||
@ -143,13 +143,13 @@ void QskLayoutChain::expandCells(
|
|||||||
cell.stretch = qMax( cell.stretch, multiCell.stretch );
|
cell.stretch = qMax( cell.stretch, multiCell.stretch );
|
||||||
|
|
||||||
if ( !minimum.isEmpty() )
|
if ( !minimum.isEmpty() )
|
||||||
cell.hint.expandMinimum( minimum[i].length );
|
cell.metrics.expandMinimum( minimum[i].length );
|
||||||
|
|
||||||
if ( !preferred.isEmpty() )
|
if ( !preferred.isEmpty() )
|
||||||
cell.hint.expandPreferred( preferred[i].length );
|
cell.metrics.expandPreferred( preferred[i].length );
|
||||||
|
|
||||||
if ( !maximum.isEmpty() && !cell.isValid )
|
if ( !maximum.isEmpty() && !cell.isValid )
|
||||||
cell.hint.setMaximum( maximum[i].length );
|
cell.metrics.setMaximum( maximum[i].length );
|
||||||
|
|
||||||
if ( !cell.isValid )
|
if ( !cell.isValid )
|
||||||
{
|
{
|
||||||
@ -170,28 +170,28 @@ void QskLayoutChain::finish()
|
|||||||
|
|
||||||
if ( !m_cells.empty() )
|
if ( !m_cells.empty() )
|
||||||
{
|
{
|
||||||
const auto maxMaximum = QskLayoutHint::unlimited;
|
const auto maxMaximum = QskLayoutMetrics::unlimited;
|
||||||
|
|
||||||
for ( auto& cell : m_cells )
|
for ( auto& cell : m_cells )
|
||||||
{
|
{
|
||||||
if ( !cell.isValid )
|
if ( !cell.isValid )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
minimum += cell.hint.minimum();
|
minimum += cell.metrics.minimum();
|
||||||
preferred += cell.hint.preferred();
|
preferred += cell.metrics.preferred();
|
||||||
|
|
||||||
if ( maximum < maxMaximum )
|
if ( maximum < maxMaximum )
|
||||||
{
|
{
|
||||||
if ( cell.stretch == 0 && !cell.canGrow )
|
if ( cell.stretch == 0 && !cell.canGrow )
|
||||||
{
|
{
|
||||||
maximum += cell.hint.preferred();
|
maximum += cell.metrics.preferred();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( cell.hint.maximum() == maxMaximum )
|
if ( cell.metrics.maximum() == maxMaximum )
|
||||||
maximum = maxMaximum;
|
maximum = maxMaximum;
|
||||||
else
|
else
|
||||||
maximum += cell.hint.maximum();
|
maximum += cell.metrics.maximum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,9 +208,9 @@ void QskLayoutChain::finish()
|
|||||||
maximum += spacing;
|
maximum += spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_boundingHint.setMinimum( minimum );
|
m_boundingMetrics.setMinimum( minimum );
|
||||||
m_boundingHint.setPreferred( preferred );
|
m_boundingMetrics.setPreferred( preferred );
|
||||||
m_boundingHint.setMaximum( maximum );
|
m_boundingMetrics.setMaximum( maximum );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskLayoutChain::setSpacing( qreal spacing )
|
bool QskLayoutChain::setSpacing( qreal spacing )
|
||||||
@ -231,21 +231,21 @@ QskLayoutChain::Segments QskLayoutChain::segments( qreal size ) const
|
|||||||
|
|
||||||
Segments segments;
|
Segments segments;
|
||||||
|
|
||||||
if ( size <= m_boundingHint.minimum() )
|
if ( size <= m_boundingMetrics.minimum() )
|
||||||
{
|
{
|
||||||
segments = distributed( Qt::MinimumSize, 0.0, 0.0 );
|
segments = distributed( Qt::MinimumSize, 0.0, 0.0 );
|
||||||
}
|
}
|
||||||
else if ( size < m_boundingHint.preferred() )
|
else if ( size < m_boundingMetrics.preferred() )
|
||||||
{
|
{
|
||||||
segments = minimumExpanded( size );
|
segments = minimumExpanded( size );
|
||||||
}
|
}
|
||||||
else if ( size <= m_boundingHint.maximum() )
|
else if ( size <= m_boundingMetrics.maximum() )
|
||||||
{
|
{
|
||||||
segments = preferredStretched( size );
|
segments = preferredStretched( size );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const qreal padding = size - m_boundingHint.maximum();
|
const qreal padding = size - m_boundingMetrics.maximum();
|
||||||
|
|
||||||
qreal offset = 0.0;
|
qreal offset = 0.0;
|
||||||
qreal extra = 0.0;;
|
qreal extra = 0.0;;
|
||||||
@ -297,10 +297,10 @@ QskLayoutChain::Segments QskLayoutChain::distributed(
|
|||||||
|
|
||||||
segment.start = offset;
|
segment.start = offset;
|
||||||
|
|
||||||
qreal size = cell.hint.size( which );
|
qreal size = cell.metrics.metric( which );
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if ( which == Qt::MaximumSize && size == QskLayoutHint::unlimited )
|
if ( which == Qt::MaximumSize && size == QskLayoutMetrics::unlimited )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
We have some special handling in QskLayoutChain::finish,
|
We have some special handling in QskLayoutChain::finish,
|
||||||
@ -308,7 +308,7 @@ QskLayoutChain::Segments QskLayoutChain::distributed(
|
|||||||
size of a cell to the bounding maximum size.
|
size of a cell to the bounding maximum size.
|
||||||
No good way to have this here, TODO ...
|
No good way to have this here, TODO ...
|
||||||
*/
|
*/
|
||||||
size = cell.hint.size( Qt::PreferredSize );
|
size = cell.metrics.metric( Qt::PreferredSize );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -356,8 +356,8 @@ QskLayoutChain::Segments QskLayoutChain::minimumExpanded( qreal size ) const
|
|||||||
qreal sumFactors = 0.0;
|
qreal sumFactors = 0.0;
|
||||||
QVarLengthArray< qreal > factors( m_cells.size() );
|
QVarLengthArray< qreal > factors( m_cells.size() );
|
||||||
|
|
||||||
const qreal desired = m_boundingHint.preferred() - m_boundingHint.minimum();
|
const qreal desired = m_boundingMetrics.preferred() - m_boundingMetrics.minimum();
|
||||||
const qreal available = size - m_boundingHint.minimum();
|
const qreal available = size - m_boundingMetrics.minimum();
|
||||||
|
|
||||||
for ( int i = 0; i < m_cells.size(); i++ )
|
for ( int i = 0; i < m_cells.size(); i++ )
|
||||||
{
|
{
|
||||||
@ -398,8 +398,8 @@ QskLayoutChain::Segments QskLayoutChain::minimumExpanded( qreal size ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
const qreal factor = ( size - m_boundingHint.minimum() ) /
|
const qreal factor = ( size - m_boundingMetrics.minimum() ) /
|
||||||
( m_boundingHint.preferred() - m_boundingHint.minimum() );
|
( m_boundingMetrics.preferred() - m_boundingMetrics.minimum() );
|
||||||
|
|
||||||
for ( int i = 0; i < m_cells.count(); i++ )
|
for ( int i = 0; i < m_cells.count(); i++ )
|
||||||
{
|
{
|
||||||
@ -417,8 +417,8 @@ QskLayoutChain::Segments QskLayoutChain::minimumExpanded( qreal size ) const
|
|||||||
fillSpacing = m_spacing;
|
fillSpacing = m_spacing;
|
||||||
|
|
||||||
segment.start = offset;
|
segment.start = offset;
|
||||||
segment.length = cell.hint.minimum()
|
segment.length = cell.metrics.minimum()
|
||||||
+ factor * ( cell.hint.preferred() - cell.hint.minimum() );
|
+ factor * ( cell.metrics.preferred() - cell.metrics.minimum() );
|
||||||
|
|
||||||
offset += segment.length;
|
offset += segment.length;
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ QskLayoutChain::Segments QskLayoutChain::preferredStretched( qreal size ) const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cell.hint.preferred() >= cell.hint.maximum() )
|
if ( cell.metrics.preferred() >= cell.metrics.maximum() )
|
||||||
{
|
{
|
||||||
factors[i] = 0.0;
|
factors[i] = 0.0;
|
||||||
}
|
}
|
||||||
@ -477,7 +477,7 @@ QskLayoutChain::Segments QskLayoutChain::preferredStretched( qreal size ) const
|
|||||||
|
|
||||||
const auto size = sumSizes * factors[i] / sumFactors;
|
const auto size = sumSizes * factors[i] / sumFactors;
|
||||||
|
|
||||||
const auto& hint = m_cells[i].hint;
|
const auto& hint = m_cells[i].metrics;
|
||||||
const auto boundedSize =
|
const auto boundedSize =
|
||||||
qBound( hint.preferred(), size, hint.maximum() );
|
qBound( hint.preferred(), size, hint.maximum() );
|
||||||
|
|
||||||
@ -519,7 +519,7 @@ QskLayoutChain::Segments QskLayoutChain::preferredStretched( qreal size ) const
|
|||||||
if ( factor > 0.0 )
|
if ( factor > 0.0 )
|
||||||
segment.length = sumSizes * factor / sumFactors;
|
segment.length = sumSizes * factor / sumFactors;
|
||||||
else
|
else
|
||||||
segment.length = cell.hint.preferred();
|
segment.length = cell.metrics.preferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += segment.length;
|
offset += segment.length;
|
||||||
@ -553,7 +553,7 @@ QDebug operator<<( QDebug debug, const QskLayoutChain::CellData& cell )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug << "( " << cell.hint << ", "
|
debug << "( " << cell.metrics << ", "
|
||||||
<< cell.stretch << ", " << cell.canGrow << " )";
|
<< cell.stretch << ", " << cell.canGrow << " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#ifndef QSK_LAYOUT_CHAIN_H
|
#ifndef QSK_LAYOUT_CHAIN_H
|
||||||
#define QSK_LAYOUT_CHAIN_H
|
#define QSK_LAYOUT_CHAIN_H
|
||||||
|
|
||||||
#include <QskLayoutHint.h>
|
#include <QskLayoutMetrics.h>
|
||||||
#include <qrect.h>
|
#include <qrect.h>
|
||||||
#include <qvector.h>
|
#include <qvector.h>
|
||||||
|
|
||||||
@ -29,17 +29,17 @@ class QskLayoutChain
|
|||||||
class CellData
|
class CellData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline qreal size( int which ) const
|
inline qreal metric( int which ) const
|
||||||
{
|
{
|
||||||
return hint.size( which );
|
return metrics.metric( which );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setSize( int which, qreal size )
|
inline void setMetric( int which, qreal size )
|
||||||
{
|
{
|
||||||
hint.setSize( which, size );
|
metrics.setMetric( which, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskLayoutHint hint;
|
QskLayoutMetrics metrics;
|
||||||
|
|
||||||
int stretch = 0;
|
int stretch = 0;
|
||||||
bool canGrow = false;
|
bool canGrow = false;
|
||||||
@ -73,7 +73,7 @@ class QskLayoutChain
|
|||||||
int fillMode() const { return m_fillMode; }
|
int fillMode() const { return m_fillMode; }
|
||||||
|
|
||||||
Segments segments( qreal size ) const;
|
Segments segments( qreal size ) const;
|
||||||
QskLayoutHint boundingHint() const { return m_boundingHint; }
|
QskLayoutMetrics boundingMetrics() const { return m_boundingMetrics; }
|
||||||
|
|
||||||
inline qreal constraint() const { return m_constraint; }
|
inline qreal constraint() const { return m_constraint; }
|
||||||
inline int count() const { return m_cells.size(); }
|
inline int count() const { return m_cells.size(); }
|
||||||
@ -83,7 +83,7 @@ class QskLayoutChain
|
|||||||
Segments minimumExpanded( qreal size ) const;
|
Segments minimumExpanded( qreal size ) const;
|
||||||
Segments preferredStretched( qreal size ) const;
|
Segments preferredStretched( qreal size ) const;
|
||||||
|
|
||||||
QskLayoutHint m_boundingHint;
|
QskLayoutMetrics m_boundingMetrics;
|
||||||
qreal m_constraint = -2.0;
|
qreal m_constraint = -2.0;
|
||||||
|
|
||||||
qreal m_spacing = 0;
|
qreal m_spacing = 0;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "QskLayoutEngine2D.h"
|
#include "QskLayoutEngine2D.h"
|
||||||
#include "QskLayoutChain.h"
|
#include "QskLayoutChain.h"
|
||||||
#include "QskLayoutHint.h"
|
#include "QskLayoutMetrics.h"
|
||||||
#include "QskControl.h"
|
#include "QskControl.h"
|
||||||
#include "QskQuick.h"
|
#include "QskQuick.h"
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ static inline qreal qskEffectiveConstraint( const QQuickItem* item,
|
|||||||
value = qskEffectiveSizeHint( item, which ).height();
|
value = qskEffectiveSizeHint( item, which ).height();
|
||||||
|
|
||||||
if ( value < 0.0 )
|
if ( value < 0.0 )
|
||||||
value = ( which == Qt::MaximumSize ) ? QskLayoutHint::unlimited : 0.0;
|
value = ( which == Qt::MaximumSize ) ? QskLayoutMetrics::unlimited : 0.0;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -469,19 +469,19 @@ QSizeF QskLayoutEngine2D::sizeHint(
|
|||||||
QSizeF hint;
|
QSizeF hint;
|
||||||
|
|
||||||
if ( constraint.width() <= 0.0 )
|
if ( constraint.width() <= 0.0 )
|
||||||
hint.rwidth() = columnChain.boundingHint().size( which );
|
hint.rwidth() = columnChain.boundingMetrics().metric( which );
|
||||||
|
|
||||||
if ( constraint.height() <= 0.0 )
|
if ( constraint.height() <= 0.0 )
|
||||||
hint.rheight() = rowChain.boundingHint().size( which );
|
hint.rheight() = rowChain.boundingMetrics().metric( which );
|
||||||
|
|
||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskLayoutHint QskLayoutEngine2D::layoutHint( const QQuickItem* item,
|
QskLayoutMetrics QskLayoutEngine2D::layoutMetrics( const QQuickItem* item,
|
||||||
Qt::Orientation orientation, qreal constraint ) const
|
Qt::Orientation orientation, qreal constraint ) const
|
||||||
{
|
{
|
||||||
if ( item == nullptr )
|
if ( item == nullptr )
|
||||||
return QskLayoutHint();
|
return QskLayoutMetrics();
|
||||||
|
|
||||||
const auto policy = qskSizePolicy( item ).policy( orientation );
|
const auto policy = qskSizePolicy( item ).policy( orientation );
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ QskLayoutHint QskLayoutEngine2D::layoutHint( const QQuickItem* item,
|
|||||||
preferred = minimum;
|
preferred = minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QskLayoutHint( minimum, preferred, maximum );
|
return QskLayoutMetrics( minimum, preferred, maximum );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskLayoutEngine2D::setupChain( Qt::Orientation orientation ) const
|
void QskLayoutEngine2D::setupChain( Qt::Orientation orientation ) const
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class QskLayoutHint;
|
class QskLayoutMetrics;
|
||||||
|
|
||||||
class QskLayoutEngine2D
|
class QskLayoutEngine2D
|
||||||
{
|
{
|
||||||
@ -57,7 +57,7 @@ class QskLayoutEngine2D
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
void layoutItem( QQuickItem*, const QRect& grid ) const;
|
void layoutItem( QQuickItem*, const QRect& grid ) const;
|
||||||
QskLayoutHint layoutHint( const QQuickItem*,
|
QskLayoutMetrics layoutMetrics( const QQuickItem*,
|
||||||
Qt::Orientation, qreal constraint ) const;
|
Qt::Orientation, qreal constraint ) const;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -3,25 +3,25 @@
|
|||||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskLayoutHint.h"
|
#include "QskLayoutMetrics.h"
|
||||||
#include "QskControl.h"
|
#include "QskControl.h"
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
void QskLayoutHint::setSize( int which, qreal size ) noexcept
|
void QskLayoutMetrics::setMetric( int which, qreal metric ) noexcept
|
||||||
{
|
{
|
||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
case Qt::MinimumSize:
|
case Qt::MinimumSize:
|
||||||
m_minimum = size;
|
m_minimum = metric;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::PreferredSize:
|
case Qt::PreferredSize:
|
||||||
m_preferred = size;
|
m_preferred = metric;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::MaximumSize:
|
case Qt::MaximumSize:
|
||||||
m_maximum = size;
|
m_maximum = metric;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -29,21 +29,21 @@ void QskLayoutHint::setSize( int which, qreal size ) noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskLayoutHint::expandTo( const QskLayoutHint& other ) noexcept
|
void QskLayoutMetrics::expandTo( const QskLayoutMetrics& other ) noexcept
|
||||||
{
|
{
|
||||||
m_minimum = std::max( m_minimum, other.m_minimum );
|
m_minimum = std::max( m_minimum, other.m_minimum );
|
||||||
m_preferred = std::max( m_preferred, other.m_preferred );
|
m_preferred = std::max( m_preferred, other.m_preferred );
|
||||||
m_maximum = std::max( m_maximum, other.m_maximum );
|
m_maximum = std::max( m_maximum, other.m_maximum );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskLayoutHint::normalize() noexcept
|
void QskLayoutMetrics::normalize() noexcept
|
||||||
{
|
{
|
||||||
m_minimum = std::max( m_minimum, qreal( 0.0 ) );
|
m_minimum = std::max( m_minimum, qreal( 0.0 ) );
|
||||||
m_maximum = std::max( m_minimum, m_maximum );
|
m_maximum = std::max( m_minimum, m_maximum );
|
||||||
m_preferred = qBound( m_minimum, m_preferred, m_maximum );
|
m_preferred = qBound( m_minimum, m_preferred, m_maximum );
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QskLayoutHint::combined( int which, qreal value1, qreal value2 ) noexcept
|
qreal QskLayoutMetrics::combined( int which, qreal value1, qreal value2 ) noexcept
|
||||||
{
|
{
|
||||||
if ( which == Qt::MaximumSize )
|
if ( which == Qt::MaximumSize )
|
||||||
{
|
{
|
||||||
@ -65,25 +65,25 @@ qreal QskLayoutHint::combined( int which, qreal value1, qreal value2 ) noexcept
|
|||||||
|
|
||||||
static inline QString qskHintValueString( qreal value )
|
static inline QString qskHintValueString( qreal value )
|
||||||
{
|
{
|
||||||
if ( value >= QskLayoutHint::unlimited )
|
if ( value >= QskLayoutMetrics::unlimited )
|
||||||
return QStringLiteral( "unlimited" );
|
return QStringLiteral( "unlimited" );
|
||||||
else
|
else
|
||||||
return QString::number( value );
|
return QString::number( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, const QskLayoutHint& hint )
|
QDebug operator<<( QDebug debug, const QskLayoutMetrics& metrics )
|
||||||
{
|
{
|
||||||
QDebugStateSaver saver( debug );
|
QDebugStateSaver saver( debug );
|
||||||
debug.nospace();
|
debug.nospace();
|
||||||
|
|
||||||
debug << "LayoutHint" << "( "
|
debug << "LayoutMetrics" << "( "
|
||||||
<< qskHintValueString( hint.minimum() ) << ", "
|
<< qskHintValueString( metrics.minimum() ) << ", "
|
||||||
<< qskHintValueString( hint.preferred() ) << ", "
|
<< qskHintValueString( metrics.preferred() ) << ", "
|
||||||
<< qskHintValueString( hint.maximum() ) << " )";
|
<< qskHintValueString( metrics.maximum() ) << " )";
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "moc_QskLayoutHint.cpp"
|
#include "moc_QskLayoutMetrics.cpp"
|
@ -3,15 +3,15 @@
|
|||||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef QSK_LAYOUT_HINT_H
|
#ifndef QSK_LAYOUT_METRICS_H
|
||||||
#define QSK_LAYOUT_HINT_H
|
#define QSK_LAYOUT_METRICS_H
|
||||||
|
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
#include <qmetatype.h>
|
#include <qmetatype.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
class QSK_EXPORT QskLayoutHint
|
class QSK_EXPORT QskLayoutMetrics
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
|
||||||
@ -20,19 +20,19 @@ class QSK_EXPORT QskLayoutHint
|
|||||||
Q_PROPERTY( qreal maximum READ maximum WRITE setMaximum )
|
Q_PROPERTY( qreal maximum READ maximum WRITE setMaximum )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr QskLayoutHint() noexcept = default;
|
constexpr QskLayoutMetrics() noexcept = default;
|
||||||
constexpr QskLayoutHint( qreal minimum, qreal preferred, qreal maximum ) noexcept;
|
constexpr QskLayoutMetrics( qreal minimum, qreal preferred, qreal maximum ) noexcept;
|
||||||
|
|
||||||
void normalize() noexcept;
|
void normalize() noexcept;
|
||||||
|
|
||||||
QskLayoutHint normalized() const noexcept;
|
QskLayoutMetrics normalized() const noexcept;
|
||||||
constexpr bool isDefault() const noexcept;
|
constexpr bool isDefault() const noexcept;
|
||||||
|
|
||||||
qreal size( int which ) const noexcept;
|
qreal metric( int which ) const noexcept;
|
||||||
void setSize( int which, qreal size ) noexcept;
|
void setMetric( int which, qreal metric ) noexcept;
|
||||||
|
|
||||||
constexpr bool operator==( const QskLayoutHint& ) const noexcept;
|
constexpr bool operator==( const QskLayoutMetrics& ) const noexcept;
|
||||||
constexpr bool operator!=( const QskLayoutHint& ) const noexcept;
|
constexpr bool operator!=( const QskLayoutMetrics& ) const noexcept;
|
||||||
|
|
||||||
void setMinimum( qreal value ) noexcept;
|
void setMinimum( qreal value ) noexcept;
|
||||||
constexpr qreal minimum() const noexcept;
|
constexpr qreal minimum() const noexcept;
|
||||||
@ -43,8 +43,8 @@ class QSK_EXPORT QskLayoutHint
|
|||||||
void setMaximum( qreal value ) noexcept;
|
void setMaximum( qreal value ) noexcept;
|
||||||
constexpr qreal maximum() const noexcept;
|
constexpr qreal maximum() const noexcept;
|
||||||
|
|
||||||
void setSizes( qreal minimum, qreal preferred, qreal maximum ) noexcept;
|
void setMetrics( qreal minimum, qreal preferred, qreal maximum ) noexcept;
|
||||||
void expandTo( const QskLayoutHint& ) noexcept;
|
void expandTo( const QskLayoutMetrics& ) noexcept;
|
||||||
|
|
||||||
void expandMinimum( qreal value ) noexcept;
|
void expandMinimum( qreal value ) noexcept;
|
||||||
void expandPreferred( qreal value ) noexcept;
|
void expandPreferred( qreal value ) noexcept;
|
||||||
@ -56,18 +56,18 @@ class QSK_EXPORT QskLayoutHint
|
|||||||
private:
|
private:
|
||||||
qreal m_minimum = 0.0;
|
qreal m_minimum = 0.0;
|
||||||
qreal m_preferred = 0.0;
|
qreal m_preferred = 0.0;
|
||||||
qreal m_maximum = QskLayoutHint::unlimited;
|
qreal m_maximum = QskLayoutMetrics::unlimited;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO( QskLayoutHint, Q_MOVABLE_TYPE );
|
Q_DECLARE_TYPEINFO( QskLayoutMetrics, Q_MOVABLE_TYPE );
|
||||||
Q_DECLARE_METATYPE( QskLayoutHint )
|
Q_DECLARE_METATYPE( QskLayoutMetrics )
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
|
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
|
||||||
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
|
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
|
||||||
QT_WARNING_DISABLE_INTEL(1572)
|
QT_WARNING_DISABLE_INTEL(1572)
|
||||||
|
|
||||||
inline constexpr QskLayoutHint::QskLayoutHint(
|
inline constexpr QskLayoutMetrics::QskLayoutMetrics(
|
||||||
qreal minimum, qreal preferred, qreal maximum ) noexcept
|
qreal minimum, qreal preferred, qreal maximum ) noexcept
|
||||||
: m_minimum( minimum )
|
: m_minimum( minimum )
|
||||||
, m_preferred( preferred )
|
, m_preferred( preferred )
|
||||||
@ -75,55 +75,55 @@ inline constexpr QskLayoutHint::QskLayoutHint(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr qreal QskLayoutHint::minimum() const noexcept
|
inline constexpr qreal QskLayoutMetrics::minimum() const noexcept
|
||||||
{
|
{
|
||||||
return m_minimum;
|
return m_minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::setMinimum( qreal value ) noexcept
|
inline void QskLayoutMetrics::setMinimum( qreal value ) noexcept
|
||||||
{
|
{
|
||||||
m_minimum = value;
|
m_minimum = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr qreal QskLayoutHint::preferred() const noexcept
|
inline constexpr qreal QskLayoutMetrics::preferred() const noexcept
|
||||||
{
|
{
|
||||||
return m_preferred;
|
return m_preferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::setPreferred( qreal value ) noexcept
|
inline void QskLayoutMetrics::setPreferred( qreal value ) noexcept
|
||||||
{
|
{
|
||||||
m_preferred = value;
|
m_preferred = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr qreal QskLayoutHint::maximum() const noexcept
|
inline constexpr qreal QskLayoutMetrics::maximum() const noexcept
|
||||||
{
|
{
|
||||||
return m_maximum;
|
return m_maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::setMaximum( qreal value ) noexcept
|
inline void QskLayoutMetrics::setMaximum( qreal value ) noexcept
|
||||||
{
|
{
|
||||||
m_maximum = value;
|
m_maximum = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::expandMinimum( qreal value ) noexcept
|
inline void QskLayoutMetrics::expandMinimum( qreal value ) noexcept
|
||||||
{
|
{
|
||||||
if ( value > m_minimum )
|
if ( value > m_minimum )
|
||||||
m_minimum = value;
|
m_minimum = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::expandPreferred( qreal value ) noexcept
|
inline void QskLayoutMetrics::expandPreferred( qreal value ) noexcept
|
||||||
{
|
{
|
||||||
if ( value > m_preferred )
|
if ( value > m_preferred )
|
||||||
m_preferred = value;
|
m_preferred = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::expandMaximum( qreal value ) noexcept
|
inline void QskLayoutMetrics::expandMaximum( qreal value ) noexcept
|
||||||
{
|
{
|
||||||
if ( value > m_maximum )
|
if ( value > m_maximum )
|
||||||
m_maximum = value;
|
m_maximum = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskLayoutHint::setSizes(
|
inline void QskLayoutMetrics::setMetrics(
|
||||||
qreal minimum, qreal preferred, qreal maximum ) noexcept
|
qreal minimum, qreal preferred, qreal maximum ) noexcept
|
||||||
{
|
{
|
||||||
m_minimum = minimum;
|
m_minimum = minimum;
|
||||||
@ -131,7 +131,7 @@ inline void QskLayoutHint::setSizes(
|
|||||||
m_maximum = maximum;
|
m_maximum = maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline qreal QskLayoutHint::size( int which ) const noexcept
|
inline qreal QskLayoutMetrics::metric( int which ) const noexcept
|
||||||
{
|
{
|
||||||
switch( which )
|
switch( which )
|
||||||
{
|
{
|
||||||
@ -148,25 +148,27 @@ inline qreal QskLayoutHint::size( int which ) const noexcept
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr bool QskLayoutHint::isDefault() const noexcept
|
inline constexpr bool QskLayoutMetrics::isDefault() const noexcept
|
||||||
{
|
{
|
||||||
return ( m_minimum == 0.0 ) && ( m_preferred == 0.0 )
|
return ( m_minimum == 0.0 ) && ( m_preferred == 0.0 )
|
||||||
&& ( m_maximum == QskLayoutHint::unlimited );
|
&& ( m_maximum == QskLayoutMetrics::unlimited );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr bool QskLayoutHint::operator==( const QskLayoutHint& other ) const noexcept
|
inline constexpr bool QskLayoutMetrics::operator==(
|
||||||
|
const QskLayoutMetrics& other ) const noexcept
|
||||||
{
|
{
|
||||||
return ( m_preferred == other.m_preferred )
|
return ( m_preferred == other.m_preferred )
|
||||||
&& ( m_minimum == other.m_minimum )
|
&& ( m_minimum == other.m_minimum )
|
||||||
&& ( m_maximum == other.m_maximum );
|
&& ( m_maximum == other.m_maximum );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr bool QskLayoutHint::operator!=( const QskLayoutHint& other ) const noexcept
|
inline constexpr bool QskLayoutMetrics::operator!=(
|
||||||
|
const QskLayoutMetrics& other ) const noexcept
|
||||||
{
|
{
|
||||||
return !( *this == other );
|
return !( *this == other );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QskLayoutHint QskLayoutHint::normalized() const noexcept
|
inline QskLayoutMetrics QskLayoutMetrics::normalized() const noexcept
|
||||||
{
|
{
|
||||||
auto hint = *this;
|
auto hint = *this;
|
||||||
hint.normalize();
|
hint.normalize();
|
||||||
@ -178,7 +180,7 @@ QT_WARNING_POP
|
|||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
class QDebug;
|
class QDebug;
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, const QskLayoutHint& );
|
QSK_EXPORT QDebug operator<<( QDebug, const QskLayoutMetrics& );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskLinearLayoutEngine.h"
|
#include "QskLinearLayoutEngine.h"
|
||||||
#include "QskLayoutHint.h"
|
#include "QskLayoutMetrics.h"
|
||||||
#include "QskLayoutChain.h"
|
#include "QskLayoutChain.h"
|
||||||
#include "QskSizePolicy.h"
|
#include "QskSizePolicy.h"
|
||||||
#include "QskQuick.h"
|
#include "QskQuick.h"
|
||||||
@ -138,11 +138,11 @@ QskLayoutChain::CellData Element::cell(
|
|||||||
{
|
{
|
||||||
if ( isLayoutOrientation )
|
if ( isLayoutOrientation )
|
||||||
{
|
{
|
||||||
cell.hint.setMinimum( m_spacing );
|
cell.metrics.setMinimum( m_spacing );
|
||||||
cell.hint.setPreferred( m_spacing );
|
cell.metrics.setPreferred( m_spacing );
|
||||||
|
|
||||||
if ( m_stretch <= 0 )
|
if ( m_stretch <= 0 )
|
||||||
cell.hint.setMaximum( m_spacing );
|
cell.metrics.setMaximum( m_spacing );
|
||||||
|
|
||||||
cell.stretch = qMax( m_stretch, 0 );
|
cell.stretch = qMax( m_stretch, 0 );
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ void QskLinearLayoutEngine::setupChain( Qt::Orientation orientation,
|
|||||||
auto cell = element.cell( orientation, isLayoutOrientation );
|
auto cell = element.cell( orientation, isLayoutOrientation );
|
||||||
|
|
||||||
if ( element.item() )
|
if ( element.item() )
|
||||||
cell.hint = layoutHint( element.item(), orientation, constraint );
|
cell.metrics = layoutMetrics( element.item(), orientation, constraint );
|
||||||
|
|
||||||
chain.expandCell( index2, cell );
|
chain.expandCell( index2, cell );
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ HEADERS += \
|
|||||||
layouts/QskIndexedLayoutBox.h \
|
layouts/QskIndexedLayoutBox.h \
|
||||||
layouts/QskLayoutChain.h \
|
layouts/QskLayoutChain.h \
|
||||||
layouts/QskLayoutEngine2D.cpp \
|
layouts/QskLayoutEngine2D.cpp \
|
||||||
layouts/QskLayoutHint.h \
|
layouts/QskLayoutMetrics.h \
|
||||||
layouts/QskLinearBox.h \
|
layouts/QskLinearBox.h \
|
||||||
layouts/QskLinearLayoutEngine.h \
|
layouts/QskLinearLayoutEngine.h \
|
||||||
layouts/QskStackBoxAnimator.h \
|
layouts/QskStackBoxAnimator.h \
|
||||||
@ -298,7 +298,7 @@ SOURCES += \
|
|||||||
layouts/QskIndexedLayoutBox.cpp \
|
layouts/QskIndexedLayoutBox.cpp \
|
||||||
layouts/QskLayoutChain.cpp \
|
layouts/QskLayoutChain.cpp \
|
||||||
layouts/QskLayoutEngine2D.cpp \
|
layouts/QskLayoutEngine2D.cpp \
|
||||||
layouts/QskLayoutHint.cpp \
|
layouts/QskLayoutMetrics.cpp \
|
||||||
layouts/QskLinearBox.cpp \
|
layouts/QskLinearBox.cpp \
|
||||||
layouts/QskLinearLayoutEngine.cpp \
|
layouts/QskLinearLayoutEngine.cpp \
|
||||||
layouts/QskStackBoxAnimator.cpp \
|
layouts/QskStackBoxAnimator.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user