QskSkinTransition fixed

This commit is contained in:
Uwe Rathmann 2024-02-01 15:40:16 +01:00
parent 463187d048
commit 330df7308a
4 changed files with 58 additions and 25 deletions

View File

@ -365,14 +365,29 @@ void WindowAnimator::addHints( const QskControl* control,
if ( v1 && v2 ) if ( v1 && v2 )
{ {
if ( QskVariantAnimator::maybeInterpolate( *v1, *v2 ) ) if ( r1.section() == r2.section() )
{ aspect.setSection( r2.section() );
if ( r1.variation() == r2.variation() ) if ( r1.variation() == r2.variation() )
aspect.setVariation( r2.variation() ); aspect.setVariation( r2.variation() );
if ( r1.states() == r2.states() ) if ( r1.states() == r2.states() )
aspect.setStates( r2.states() ); aspect.setStates( r2.states() );
bool accecptIdentity = false;
if ( aspect != aspect.trunk() )
{
/*
We might need an animator even if the values do not differ
to prevent effectiveSkinHint to find its value from
another animator that might have been started with
less extra bits.
*/
accecptIdentity = true;
}
if ( QskVariantAnimator::maybeInterpolate( *v1, *v2, accecptIdentity ) )
{
storeAnimator( control, aspect, *v1, *v2, animatorHint ); storeAnimator( control, aspect, *v1, *v2, animatorHint );
storeUpdateInfo( control, aspect ); storeUpdateInfo( control, aspect );
} }

View File

@ -1316,7 +1316,7 @@ void QskSkinnable::startHintTransition( QskAspect aspect, int index,
if ( control->window() == nullptr || !isTransitionAccepted( aspect ) ) if ( control->window() == nullptr || !isTransitionAccepted( aspect ) )
return; return;
if ( !QskVariantAnimator::maybeInterpolate( from, to ) ) if ( !QskVariantAnimator::maybeInterpolate( from, to, false ) )
return; return;
auto v1 = from; auto v1 = from;

View File

@ -210,11 +210,26 @@ void QskVariantAnimator::done()
} }
bool QskVariantAnimator::maybeInterpolate( bool QskVariantAnimator::maybeInterpolate(
const QVariant& value1, const QVariant& value2 ) const QVariant& value1, const QVariant& value2, bool acceptIdentity )
{ {
if ( !value1.isValid() && !value2.isValid() ) if ( !value1.isValid() && !value2.isValid() )
return false; return false;
if ( acceptIdentity )
{
if ( value1.isValid() && value2.isValid() )
{
const auto type1 = qskMetaType( value1 );
const auto type2 = qskMetaType( value2 );
if ( type1 != type2 )
return value1.canConvert( type2 ) || value2.canConvert( type1 );
}
return true;
}
else
{
const auto type1 = qskMetaType( value1 ); const auto type1 = qskMetaType( value1 );
const auto type2 = qskMetaType( value2 ); const auto type2 = qskMetaType( value2 );
@ -237,3 +252,4 @@ bool QskVariantAnimator::maybeInterpolate(
return value1 != value2; return value1 != value2;
} }
}

View File

@ -24,7 +24,9 @@ class QSK_EXPORT QskVariantAnimator : public QskAnimator
void setEndValue( const QVariant& ); void setEndValue( const QVariant& );
QVariant endValue() const; QVariant endValue() const;
static bool maybeInterpolate( const QVariant&, const QVariant& ); static bool maybeInterpolate(
const QVariant&, const QVariant&, bool acceptIdentity );
static bool convertValues( QVariant&, QVariant& ); static bool convertValues( QVariant&, QVariant& );
protected: protected: