QskIntervalF::interpolate added
This commit is contained in:
parent
48a5e387d4
commit
50923fcf8c
@ -5,8 +5,34 @@
|
||||
|
||||
#include "QskIntervalF.h"
|
||||
#include "QskFunctions.h"
|
||||
|
||||
#include <qvariant.h>
|
||||
#include <algorithm>
|
||||
|
||||
static inline QskIntervalF qskInterpolated(
|
||||
const QskIntervalF& intv1, const QskIntervalF& intv2, qreal progress )
|
||||
{
|
||||
const qreal lowerBound = intv1.lowerBound()
|
||||
+ progress * ( intv2.lowerBound() - intv1.lowerBound() );
|
||||
|
||||
const qreal upperBound = intv1.upperBound()
|
||||
+ progress * ( intv2.upperBound() - intv1.upperBound() );
|
||||
|
||||
return QskIntervalF( lowerBound, upperBound );
|
||||
}
|
||||
|
||||
QskIntervalF QskIntervalF::interpolated(
|
||||
const QskIntervalF& to, qreal progress ) const noexcept
|
||||
{
|
||||
return qskInterpolated( *this, to, progress );
|
||||
}
|
||||
|
||||
QVariant QskIntervalF::interpolate(
|
||||
const QskIntervalF& intv1, const QskIntervalF& intv2, qreal progress ) noexcept
|
||||
{
|
||||
return QVariant::fromValue( qskInterpolated( intv1, intv2, progress ) );
|
||||
}
|
||||
|
||||
void QskIntervalF::unite( const QskIntervalF& other ) noexcept
|
||||
{
|
||||
if ( isValid() )
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <qglobal.h>
|
||||
#include <qmetatype.h>
|
||||
|
||||
class QVariant;
|
||||
|
||||
class QSK_EXPORT QskIntervalF
|
||||
{
|
||||
Q_GADGET
|
||||
@ -67,6 +69,11 @@ class QSK_EXPORT QskIntervalF
|
||||
|
||||
void invalidate() noexcept;
|
||||
|
||||
QskIntervalF interpolated( const QskIntervalF&, qreal progress ) const noexcept;
|
||||
|
||||
static QVariant interpolate( const QskIntervalF&,
|
||||
const QskIntervalF&, qreal progress ) noexcept;
|
||||
|
||||
private:
|
||||
qreal m_lowerBound = 0.0;
|
||||
qreal m_upperBound = -1.0;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "QskColorFilter.h"
|
||||
#include "QskGradient.h"
|
||||
#include "QskMargins.h"
|
||||
#include "QskIntervalF.h"
|
||||
#include "QskTextColors.h"
|
||||
|
||||
// Even if we don't use the standard Qt animation system we
|
||||
@ -25,6 +26,7 @@ QSK_QT_PRIVATE_END
|
||||
static void qskRegisterInterpolator()
|
||||
{
|
||||
qRegisterAnimationInterpolator< QskColorFilter >( QskColorFilter::interpolate );
|
||||
qRegisterAnimationInterpolator< QskIntervalF >( QskIntervalF::interpolate );
|
||||
qRegisterAnimationInterpolator< QskMargins >( QskMargins::interpolate );
|
||||
qRegisterAnimationInterpolator< QskGradient >( QskGradient::interpolate );
|
||||
qRegisterAnimationInterpolator< QskBoxShapeMetrics >( QskBoxShapeMetrics::interpolate );
|
||||
|
Loading…
x
Reference in New Issue
Block a user