internally using a boolean instead of the sizemode enum
This commit is contained in:
parent
d6da8fcbb8
commit
8775976f0b
@ -48,7 +48,7 @@ void QskArcMetrics::setSpanAngle( qreal spanAngle ) noexcept
|
|||||||
|
|
||||||
void QskArcMetrics::setSizeMode( Qt::SizeMode sizeMode ) noexcept
|
void QskArcMetrics::setSizeMode( Qt::SizeMode sizeMode ) noexcept
|
||||||
{
|
{
|
||||||
m_sizeMode = sizeMode;
|
m_relativeSize = ( sizeMode == Qt::RelativeSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskArcMetrics::isClosed() const
|
bool QskArcMetrics::isClosed() const
|
||||||
@ -79,7 +79,7 @@ bool QskArcMetrics::containsAngle( qreal angle ) const
|
|||||||
QskArcMetrics QskArcMetrics::interpolated(
|
QskArcMetrics QskArcMetrics::interpolated(
|
||||||
const QskArcMetrics& to, qreal ratio ) const noexcept
|
const QskArcMetrics& to, qreal ratio ) const noexcept
|
||||||
{
|
{
|
||||||
if ( ( *this == to ) || ( m_sizeMode != to.m_sizeMode ) )
|
if ( ( *this == to ) || ( m_relativeSize != to.m_relativeSize ) )
|
||||||
return to;
|
return to;
|
||||||
|
|
||||||
const qreal thickness = qskInterpolated( m_thickness, to.m_thickness, ratio );
|
const qreal thickness = qskInterpolated( m_thickness, to.m_thickness, ratio );
|
||||||
@ -87,7 +87,7 @@ QskArcMetrics QskArcMetrics::interpolated(
|
|||||||
const qreal s1 = qskInterpolated( m_startAngle, to.m_startAngle, ratio );
|
const qreal s1 = qskInterpolated( m_startAngle, to.m_startAngle, ratio );
|
||||||
const qreal s2 = qskInterpolated( endAngle(), to.endAngle(), ratio );
|
const qreal s2 = qskInterpolated( endAngle(), to.endAngle(), ratio );
|
||||||
|
|
||||||
return QskArcMetrics( s1, s2 - s1, thickness, m_sizeMode );
|
return QskArcMetrics( s1, s2 - s1, thickness, sizeMode() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QskArcMetrics::interpolate(
|
QVariant QskArcMetrics::interpolate(
|
||||||
@ -97,6 +97,11 @@ QVariant QskArcMetrics::interpolate(
|
|||||||
return QVariant::fromValue( from.interpolated( to, progress ) );
|
return QVariant::fromValue( from.interpolated( to, progress ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskArcMetrics QskArcMetrics::toAbsolute( const QSizeF& size ) const noexcept
|
||||||
|
{
|
||||||
|
return toAbsolute( 0.5 * size.width(), 0.5 * size.height() );
|
||||||
|
}
|
||||||
|
|
||||||
QskArcMetrics QskArcMetrics::toAbsolute( qreal radiusX, qreal radiusY ) const noexcept
|
QskArcMetrics QskArcMetrics::toAbsolute( qreal radiusX, qreal radiusY ) const noexcept
|
||||||
{
|
{
|
||||||
if ( radiusX < 0.0 )
|
if ( radiusX < 0.0 )
|
||||||
@ -110,7 +115,7 @@ QskArcMetrics QskArcMetrics::toAbsolute( qreal radiusX, qreal radiusY ) const no
|
|||||||
|
|
||||||
QskArcMetrics QskArcMetrics::toAbsolute( qreal radius ) const noexcept
|
QskArcMetrics QskArcMetrics::toAbsolute( qreal radius ) const noexcept
|
||||||
{
|
{
|
||||||
if ( m_sizeMode != Qt::RelativeSize )
|
if ( !m_relativeSize )
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
const qreal t = qskEffectiveThickness( radius, m_thickness );
|
const qreal t = qskEffectiveThickness( radius, m_thickness );
|
||||||
@ -122,7 +127,7 @@ QPainterPath QskArcMetrics::painterPath( const QRectF& ellipseRect ) const
|
|||||||
const auto sz = qMin( ellipseRect.width(), ellipseRect.height() );
|
const auto sz = qMin( ellipseRect.width(), ellipseRect.height() );
|
||||||
|
|
||||||
qreal t = m_thickness;
|
qreal t = m_thickness;
|
||||||
if ( m_sizeMode == Qt::RelativeSize )
|
if ( m_relativeSize )
|
||||||
t = qskEffectiveThickness( 0.5 * sz, t );
|
t = qskEffectiveThickness( 0.5 * sz, t );
|
||||||
|
|
||||||
if ( t <= 0.0 || qFuzzyIsNull( m_spanAngle ) )
|
if ( t <= 0.0 || qFuzzyIsNull( m_spanAngle ) )
|
||||||
@ -212,8 +217,7 @@ QskHashValue QskArcMetrics::hash( QskHashValue seed ) const noexcept
|
|||||||
hash = qHash( m_startAngle, hash );
|
hash = qHash( m_startAngle, hash );
|
||||||
hash = qHash( m_spanAngle, hash );
|
hash = qHash( m_spanAngle, hash );
|
||||||
|
|
||||||
const int mode = m_sizeMode;
|
return qHash( m_relativeSize, hash );
|
||||||
return qHashBits( &mode, sizeof( mode ), hash );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
@ -58,6 +58,7 @@ class QSK_EXPORT QskArcMetrics
|
|||||||
QskArcMetrics interpolated( const QskArcMetrics&,
|
QskArcMetrics interpolated( const QskArcMetrics&,
|
||||||
qreal value ) const noexcept;
|
qreal value ) const noexcept;
|
||||||
|
|
||||||
|
QskArcMetrics toAbsolute( const QSizeF& ) const noexcept;
|
||||||
QskArcMetrics toAbsolute( qreal radiusX, qreal radiusY ) const noexcept;
|
QskArcMetrics toAbsolute( qreal radiusX, qreal radiusY ) const noexcept;
|
||||||
QskArcMetrics toAbsolute( qreal radius ) const noexcept;
|
QskArcMetrics toAbsolute( qreal radius ) const noexcept;
|
||||||
|
|
||||||
@ -76,7 +77,8 @@ class QSK_EXPORT QskArcMetrics
|
|||||||
qreal m_spanAngle = 0.0;
|
qreal m_spanAngle = 0.0;
|
||||||
|
|
||||||
qreal m_thickness = 0.0;
|
qreal m_thickness = 0.0;
|
||||||
Qt::SizeMode m_sizeMode = Qt::AbsoluteSize;
|
|
||||||
|
bool m_relativeSize = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline constexpr QskArcMetrics::QskArcMetrics(
|
inline constexpr QskArcMetrics::QskArcMetrics(
|
||||||
@ -85,23 +87,22 @@ inline constexpr QskArcMetrics::QskArcMetrics(
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskArcMetrics::QskArcMetrics(
|
inline constexpr QskArcMetrics::QskArcMetrics( qreal startAngle, qreal spanAngle,
|
||||||
qreal startAngle, qreal spanAngle,
|
|
||||||
qreal thickness, Qt::SizeMode sizeMode ) noexcept
|
qreal thickness, Qt::SizeMode sizeMode ) noexcept
|
||||||
: m_startAngle( startAngle )
|
: m_startAngle( startAngle )
|
||||||
, m_spanAngle( spanAngle )
|
, m_spanAngle( spanAngle )
|
||||||
, m_thickness( thickness )
|
, m_thickness( thickness )
|
||||||
, m_sizeMode( sizeMode )
|
, m_relativeSize( sizeMode == Qt::RelativeSize )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool QskArcMetrics::operator==(
|
inline bool QskArcMetrics::operator==(
|
||||||
const QskArcMetrics& other ) const noexcept
|
const QskArcMetrics& other ) const noexcept
|
||||||
{
|
{
|
||||||
return ( qskFuzzyCompare( m_thickness, other.m_thickness )
|
return qskFuzzyCompare( m_thickness, other.m_thickness )
|
||||||
&& qskFuzzyCompare( m_startAngle, other.m_startAngle )
|
&& qskFuzzyCompare( m_startAngle, other.m_startAngle )
|
||||||
&& qskFuzzyCompare( m_spanAngle, other.m_spanAngle )
|
&& qskFuzzyCompare( m_spanAngle, other.m_spanAngle )
|
||||||
&& m_sizeMode == other.m_sizeMode );
|
&& ( m_relativeSize == other.m_relativeSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool QskArcMetrics::operator!=(
|
inline bool QskArcMetrics::operator!=(
|
||||||
@ -142,7 +143,7 @@ inline constexpr qreal QskArcMetrics::angleAtRatio( qreal ratio ) const noexcept
|
|||||||
|
|
||||||
inline constexpr Qt::SizeMode QskArcMetrics::sizeMode() const noexcept
|
inline constexpr Qt::SizeMode QskArcMetrics::sizeMode() const noexcept
|
||||||
{
|
{
|
||||||
return m_sizeMode;
|
return m_relativeSize ? Qt::RelativeSize : Qt::AbsoluteSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user