QskAnimationHint::UpdateFlag introduced

This commit is contained in:
Uwe Rathmann 2019-06-22 16:26:10 +02:00
parent a4a49bb7ae
commit 309106965d
5 changed files with 62 additions and 10 deletions

View File

@ -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 );

View File

@ -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

View File

@ -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;
@ -122,15 +127,31 @@ void QskHintAnimator::advance( qreal progress )
#endif
if ( m_control && ( currentValue() != oldValue ) )
{
if ( m_updateFlags == QskAnimationHint::UpdateAuto )
{
if ( m_aspect.type() == QskAspect::Metric )
{
m_control->resetImplicitSize();
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();
}
}
}
namespace
@ -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() );

View File

@ -8,11 +8,11 @@
#include "QskAspect.h"
#include "QskVariantAnimator.h"
#include "QskAnimationHint.h"
#include <qpointer.h>
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;

View File

@ -384,6 +384,7 @@ namespace
animator.setDuration( animationHint.duration );
animator.setEasingCurve( animationHint.type );
animator.setUpdateFlags( animationHint.updateFlags );
animator.setControl( nullptr );
animator.setWindow( window );