From 1a3058fad84149b8ec1225d97bd9c037673ae7dc Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 26 Dec 2020 13:00:09 +0100 Subject: [PATCH] code moved to QskSkinHintTable --- src/controls/QskSkinHintTable.cpp | 66 +++++++++++++++++++++++++++++++ src/controls/QskSkinHintTable.h | 2 + src/controls/QskSkinnable.cpp | 62 +---------------------------- 3 files changed, 69 insertions(+), 61 deletions(-) diff --git a/src/controls/QskSkinHintTable.cpp b/src/controls/QskSkinHintTable.cpp index d8b70608..c77333ea 100644 --- a/src/controls/QskSkinHintTable.cpp +++ b/src/controls/QskSkinHintTable.cpp @@ -227,3 +227,69 @@ void QskSkinHintTable::setAnimation( aspect.setAnimator( true ); setHint( aspect, animation ); } + +bool QskSkinHintTable::isResolutionMatching( + QskAspect aspect1, QskAspect aspect2 ) const +{ + if ( aspect1 == aspect2 ) + return true; + + if ( aspect1.trunk() != aspect2.trunk() ) + return false; + + if ( !hasStates() ) + return false; + + const auto a1 = aspect1; + const auto a2 = aspect2; + + Q_FOREVER + { + const auto s1 = aspect1.topState(); + const auto s2 = aspect2.topState(); + + if ( s1 > s2 ) + { + if ( hasHint( aspect1 ) ) + return false; + + aspect1.clearState( s1 ); + } + else if ( s2 > s1 ) + { + if ( hasHint( aspect2 ) ) + return false; + + aspect2.clearState( s2 ); + } + else + { + if ( aspect1 == aspect2 ) + { + if ( hasHint( aspect1 ) ) + return true; + + if ( s1 == 0 ) + { + if ( aspect1.placement() == QskAspect::NoPlacement ) + return true; + + // clear the placement bits and restart with the initial state + aspect1 = a1; + aspect1.setPlacement( QskAspect::NoPlacement ); + + aspect2 = a2; + aspect2.setPlacement( QskAspect::NoPlacement ); + } + } + else + { + if ( hasHint( aspect1 ) || hasHint( aspect2 ) ) + return false; + } + + aspect1.clearState( s1 ); + aspect2.clearState( s2 ); + } + } +} diff --git a/src/controls/QskSkinHintTable.h b/src/controls/QskSkinHintTable.h index 6ff57ae8..d017aebd 100644 --- a/src/controls/QskSkinHintTable.h +++ b/src/controls/QskSkinHintTable.h @@ -53,6 +53,8 @@ class QSK_EXPORT QskSkinHintTable QskAspect resolvedAnimator( QskAspect, QskAnimationHint& ) const; + bool isResolutionMatching( QskAspect, QskAspect ) const; + private: static const QVariant invalidHint; diff --git a/src/controls/QskSkinnable.cpp b/src/controls/QskSkinnable.cpp index 09b2844e..3287ffd7 100644 --- a/src/controls/QskSkinnable.cpp +++ b/src/controls/QskSkinnable.cpp @@ -44,66 +44,6 @@ static inline bool qskIsControl( const QskSkinnable* skinnable ) #endif } -static inline bool qskCompareResolvedStates( - QskAspect& aspect1, QskAspect& aspect2, const QskSkinHintTable& table ) -{ - if ( !table.hasStates() ) - return false; - - const auto a1 = aspect1; - const auto a2 = aspect2; - - Q_FOREVER - { - const auto s1 = aspect1.topState(); - const auto s2 = aspect2.topState(); - - if ( s1 > s2 ) - { - if ( table.hasHint( aspect1 ) ) - return false; - - aspect1.clearState( s1 ); - } - else if ( s2 > s1 ) - { - if ( table.hasHint( aspect2 ) ) - return false; - - aspect2.clearState( s2 ); - } - else - { - if ( aspect1 == aspect2 ) - { - if ( table.hasHint( aspect1 ) ) - return true; - - if ( s1 == 0 ) - { - if ( aspect1.placement() == QskAspect::NoPlacement ) - return true; - - // clear the placement bits and restart with the initial state - aspect1 = a1; - aspect1.setPlacement( QskAspect::NoPlacement ); - - aspect2 = a2; - aspect2.setPlacement( QskAspect::NoPlacement ); - } - } - else - { - if ( table.hasHint( aspect1 ) || table.hasHint( aspect2 ) ) - return false; - } - - aspect1.clearState( s1 ); - aspect2.clearState( s2 ); - } - } -} - static inline QVariant qskTypedNullValue( const QVariant& value ) { #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) @@ -1062,7 +1002,7 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated ) for skinnables with many state bits. */ - doTransition = !qskCompareResolvedStates( a1, a2, skinTable ); + doTransition = !skinTable.isResolutionMatching( a1, a2 ); } if ( doTransition )