From 72f28783a9bc75de427c30f38423608d533c4a8a Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 4 Jan 2022 13:46:54 +0100 Subject: [PATCH] qskInterpolatedSize added --- src/common/QskFunctions.cpp | 14 ++++++++++++++ src/common/QskFunctions.h | 3 +++ 2 files changed, 17 insertions(+) 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(