diff --git a/src/common/QskFunctions.cpp b/src/common/QskFunctions.cpp index c084a433..aa5870bc 100644 --- a/src/common/QskFunctions.cpp +++ b/src/common/QskFunctions.cpp @@ -138,6 +138,20 @@ QRectF qskInterpolatedRect( const QRectF &from, const QRectF &to, qreal progress return QRectF( x, y, w, h ); } +QSizeF qskInterpolatedSize( const QSizeF &from, const QSizeF &to, qreal progress ) +{ + if ( progress <= 0.0 ) + return from; + + if ( progress >= 1.0 ) + return to; + + const auto w = from.width() + progress * ( to.width() - from.width() ); + const auto h = from.height() + progress * ( to.height() - from.height() ); + + return QSizeF( w, h ); +} + qreal qskHorizontalAdvance( const QFont& font, const QString& text ) { return qskHorizontalAdvance( QFontMetricsF( font ), text ); diff --git a/src/common/QskFunctions.h b/src/common/QskFunctions.h index 765960a5..2d91a8b9 100644 --- a/src/common/QskFunctions.h +++ b/src/common/QskFunctions.h @@ -33,6 +33,9 @@ QSK_EXPORT qreal qskHorizontalAdvance( const QFontMetricsF&, const QString& ); QSK_EXPORT QRectF qskInterpolatedRect( const QRectF& from, const QRectF& to, qreal progress ); +QSK_EXPORT QSizeF qskInterpolatedSize( + const QSizeF& from, const QSizeF& to, qreal progress ); + inline QMarginsF qskMargins( const QRectF& rect, const QRectF& innerRect ) { return QMarginsF(