6#include "QskSkinHintTable.h"
7#include "QskAnimationHint.h"
11const QVariant QskSkinHintTable::invalidHint;
13inline const QVariant* qskResolvedHint(
QskAspect aspect,
14 const QHash< QskAspect, QVariant >& hints,
QskAspect* resolvedAspect )
20 auto it = hints.constFind( aspect );
21 if ( it != hints.constEnd() )
24 *resolvedAspect = aspect;
36 if (
const auto topState = aspect.
topState() )
42 if ( aspect.hasState() )
58 if ( aspect.section() != QskAspect::Body )
62 a.setSection( QskAspect::Body );
72QskSkinHintTable::QskSkinHintTable()
77 : m_animatorCount( other.m_animatorCount )
78 , m_states( other.m_states )
94 m_hints =
new QHash< QskAspect, QVariant >( *other.m_hints );
98QskSkinHintTable::~QskSkinHintTable()
105 m_animatorCount = ( other.m_animatorCount );
106 m_states = other.m_states;
112 m_hints =
new QHash< QskAspect, QVariant >( *other.m_hints );
117const QHash< QskAspect, QVariant >& QskSkinHintTable::hints()
const
122 static QHash< QskAspect, QVariant > dummyHints;
126#define QSK_ASSERT_COUNTER( x ) Q_ASSERT( x < std::numeric_limits< decltype( x ) >::max() )
128bool QskSkinHintTable::setHint(
QskAspect aspect,
const QVariant& skinHint )
130 if ( m_hints ==
nullptr )
131 m_hints =
new QHash< QskAspect, QVariant >();
133 auto it = m_hints->find( aspect );
134 if ( it == m_hints->end() )
136 m_hints->insert( aspect, skinHint );
141 QSK_ASSERT_COUNTER( m_animatorCount );
144 m_states |= aspect.
states();
149 if ( it.value() != skinHint )
151 it.value() = skinHint;
158#undef QSK_ASSERT_COUNTER
160bool QskSkinHintTable::removeHint(
QskAspect aspect )
162 if ( m_hints ==
nullptr )
165 const bool erased = m_hints->remove( aspect );
174 if ( m_hints->empty() )
184QVariant QskSkinHintTable::takeHint(
QskAspect aspect )
188 auto it = m_hints->find( aspect );
189 if ( it != m_hints->end() )
191 const auto value = it.value();
192 m_hints->erase( it );
199 if ( m_hints->empty() )
212void QskSkinHintTable::clear()
221const QVariant* QskSkinHintTable::resolvedHint(
224 if ( m_hints !=
nullptr )
225 return qskResolvedHint( aspect & m_states, *m_hints, resolvedAspect );
234 if ( m_hints !=
nullptr )
235 qskResolvedHint( aspect & m_states, *m_hints, &a );
240QskAspect QskSkinHintTable::resolvedAnimator(
243 if ( m_hints && m_animatorCount > 0 )
249 auto it = m_hints->find( aspect );
250 if ( it != m_hints->cend() )
256 if (
const auto topState = aspect.
topState() )
269 return hint< QskAnimationHint >( aspect );
272bool QskSkinHintTable::setAnimation(
276 return setHint( aspect, animation );
279bool QskSkinHintTable::isResolutionMatching(
286 if ( aspect1 == aspect2 )
297 const auto state1 = aspect1.
topState();
298 const auto state2 = aspect2.
topState();
300 if ( state1 > state2 )
302 if ( hasHint( aspect1 ) )
309 if ( state2 > state1 )
311 if ( hasHint( aspect2 ) )
318 if ( aspect1 == aspect2 )
320 if ( hasHint( aspect1 ) )
327 if ( aspect1.section() == QskAspect::Body )
332 a1.setSection( QskAspect::Body );
333 a2.setSection( QskAspect::Body );
354 if ( hasHint( aspect1 ) || hasHint( aspect2 ) )
Lookup key for a QskSkinHintTable.
State topState() const noexcept
void clearStates(States=AllStates) noexcept
constexpr bool isAnimator() const noexcept
constexpr quint64 value() const noexcept
constexpr QskAspect trunk() const noexcept
constexpr Variation variation() const noexcept
void setAnimator(bool on) noexcept
constexpr States states() const noexcept
void setVariation(Variation) noexcept
void clearState(State) noexcept