diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 03baf6db..238b78f2 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -547,8 +547,11 @@ void QskSquiekSkin::initTabButtonHints() setTab( aspect ); } - setAnimation( Q::Panel | Color, qskDuration ); - setAnimation( Q::Panel | Metric, qskDuration ); + QskAnimationHint animationHint( qskDuration ); + animationHint.updateFlags = QskAnimationHint::UpdateNode; + + setAnimation( Q::Panel | Color, animationHint ); + setAnimation( Q::Panel | Metric, animationHint ); // text setSkinHint( Q::Text | QskAspect::Alignment, Qt::AlignCenter ); diff --git a/src/controls/QskAnimationHint.h b/src/controls/QskAnimationHint.h index 2193f2eb..cfdb90ec 100644 --- a/src/controls/QskAnimationHint.h +++ b/src/controls/QskAnimationHint.h @@ -14,9 +14,23 @@ class QSK_EXPORT QskAnimationHint { public: + enum UpdateFlag + { + UpdateAuto = 0, // depending on the animated aspect + + UpdateNode = 1 << 0, + UpdatePolish = 1 << 1, + UpdateSizeHint = 1 << 2, + + UpdateAll = UpdateNode | UpdatePolish | UpdateSizeHint + }; + + Q_DECLARE_FLAGS( UpdateFlags, UpdateFlag ) + inline constexpr QskAnimationHint() noexcept : duration( 0 ) , type( QEasingCurve::Linear ) + , updateFlags( UpdateAuto ) { } @@ -24,14 +38,17 @@ class QSK_EXPORT QskAnimationHint QEasingCurve::Type type = QEasingCurve::Linear ) noexcept : duration( duration ) , type( type ) + , updateFlags( UpdateAuto ) { } - uint duration : 24; - QEasingCurve::Type type : 8; + uint duration; + QEasingCurve::Type type; + UpdateFlags updateFlags; }; Q_DECLARE_METATYPE( QskAnimationHint ) Q_DECLARE_TYPEINFO( QskAnimationHint, Q_PRIMITIVE_TYPE ); +Q_DECLARE_OPERATORS_FOR_FLAGS( QskAnimationHint::UpdateFlags ) #endif diff --git a/src/controls/QskHintAnimator.cpp b/src/controls/QskHintAnimator.cpp index 3c7d7be9..65777c86 100644 --- a/src/controls/QskHintAnimator.cpp +++ b/src/controls/QskHintAnimator.cpp @@ -106,6 +106,11 @@ void QskHintAnimator::setAspect( QskAspect::Aspect aspect ) m_aspect = aspect; } +void QskHintAnimator::setUpdateFlags( QskAnimationHint::UpdateFlags flags ) +{ + m_updateFlags = flags; +} + void QskHintAnimator::setControl( QskControl* control ) { m_control = control; @@ -123,13 +128,29 @@ void QskHintAnimator::advance( qreal progress ) if ( m_control && ( currentValue() != oldValue ) ) { - if ( m_aspect.type() == QskAspect::Metric ) + if ( m_updateFlags == QskAnimationHint::UpdateAuto ) { - m_control->resetImplicitSize(); - m_control->polish(); - } + if ( m_aspect.type() == QskAspect::Metric ) + { + m_control->resetImplicitSize(); - m_control->update(); + if ( !m_control->childItems().isEmpty() ) + m_control->polish(); + } + + m_control->update(); + } + else + { + if ( m_updateFlags & QskAnimationHint::UpdateSizeHint ) + m_control->resetImplicitSize(); + + if ( m_updateFlags & QskAnimationHint::UpdatePolish ) + m_control->polish(); + + if ( m_updateFlags & QskAnimationHint::UpdateNode ) + m_control->update(); + } } } @@ -219,6 +240,7 @@ void QskHintAnimatorTable::start( QskControl* control, animator.setDuration( animationHint.duration ); animator.setEasingCurve( animationHint.type ); + animator.setUpdateFlags( animationHint.updateFlags ); animator.setControl( control ); animator.setWindow( control->window() ); diff --git a/src/controls/QskHintAnimator.h b/src/controls/QskHintAnimator.h index 69f4b73b..c4d44dea 100644 --- a/src/controls/QskHintAnimator.h +++ b/src/controls/QskHintAnimator.h @@ -8,11 +8,11 @@ #include "QskAspect.h" #include "QskVariantAnimator.h" +#include "QskAnimationHint.h" #include class QskControl; -class QskAnimationHint; class QSK_EXPORT QskHintAnimator : public QskVariantAnimator { @@ -28,10 +28,14 @@ class QSK_EXPORT QskHintAnimator : public QskVariantAnimator void setControl( QskControl* ); QskControl* control() const; + void setUpdateFlags( QskAnimationHint::UpdateFlags ); + QskAnimationHint::UpdateFlags updateFlags() const; + void advance( qreal value ) override; private: QskAspect::Aspect m_aspect; + QskAnimationHint::UpdateFlags m_updateFlags; QPointer< QskControl > m_control; }; @@ -61,6 +65,11 @@ inline QskAspect::Aspect QskHintAnimator::aspect() const return m_aspect; } +inline QskAnimationHint::UpdateFlags QskHintAnimator::updateFlags() const +{ + return m_updateFlags; +} + inline QskControl* QskHintAnimator::control() const { return m_control; diff --git a/src/controls/QskSkinTransition.cpp b/src/controls/QskSkinTransition.cpp index 5b217909..f945832e 100644 --- a/src/controls/QskSkinTransition.cpp +++ b/src/controls/QskSkinTransition.cpp @@ -384,6 +384,7 @@ namespace animator.setDuration( animationHint.duration ); animator.setEasingCurve( animationHint.type ); + animator.setUpdateFlags( animationHint.updateFlags ); animator.setControl( nullptr ); animator.setWindow( window );