2017-08-22 20:50:55 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_SKIN_HINT_TABLE_H
|
|
|
|
#define QSK_SKIN_HINT_TABLE_H
|
|
|
|
|
|
|
|
#include "QskAspect.h"
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
#include <qvariant.h>
|
2017-08-22 20:50:55 +02:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2020-12-26 12:57:08 +01:00
|
|
|
class QskAnimationHint;
|
|
|
|
|
2020-12-20 16:04:19 +01:00
|
|
|
class QSK_EXPORT QskSkinHintTable
|
2017-08-22 20:50:55 +02:00
|
|
|
{
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2017-10-17 17:34:00 +02:00
|
|
|
QskSkinHintTable();
|
|
|
|
QskSkinHintTable( const QskSkinHintTable& other );
|
|
|
|
|
2017-08-22 20:50:55 +02:00
|
|
|
~QskSkinHintTable();
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
QskSkinHintTable& operator=( const QskSkinHintTable& );
|
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
void setAnimation( QskAspect, QskAnimationHint );
|
|
|
|
QskAnimationHint animation( QskAspect ) const;
|
2017-08-22 20:50:55 +02:00
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
void setHint( QskAspect, const QVariant& );
|
|
|
|
const QVariant& hint( QskAspect ) const;
|
2019-05-16 08:14:53 +02:00
|
|
|
|
2020-12-26 12:57:08 +01:00
|
|
|
template< typename T > void setHint( QskAspect, const T& );
|
|
|
|
template< typename T > T hint( QskAspect ) const;
|
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
bool removeHint( QskAspect );
|
|
|
|
QVariant takeHint( QskAspect );
|
2017-08-22 20:50:55 +02:00
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
bool hasHint( QskAspect ) const;
|
2017-08-22 20:50:55 +02:00
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
const std::unordered_map< QskAspect, QVariant >& hints() const;
|
2017-08-22 20:50:55 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
bool hasAnimators() const;
|
|
|
|
bool hasStates() const;
|
|
|
|
bool hasHints() const;
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
const QVariant* resolvedHint( QskAspect,
|
|
|
|
QskAspect* resolvedAspect = nullptr ) const;
|
2017-10-17 17:34:00 +02:00
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
QskAspect resolvedAspect( QskAspect ) const;
|
2017-10-17 17:34:00 +02:00
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
QskAspect resolvedAnimator(
|
|
|
|
QskAspect, QskAnimationHint& ) const;
|
2017-10-17 17:34:00 +02:00
|
|
|
|
2020-12-26 13:00:09 +01:00
|
|
|
bool isResolutionMatching( QskAspect, QskAspect ) const;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2020-12-26 12:57:08 +01:00
|
|
|
static const QVariant invalidHint;
|
2017-10-17 17:34:00 +02:00
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
typedef std::unordered_map< QskAspect, QVariant > HintMap;
|
2017-10-17 17:34:00 +02:00
|
|
|
HintMap* m_hints;
|
|
|
|
|
|
|
|
quint16 m_animatorCount;
|
|
|
|
bool m_hasStates : 1;
|
2017-08-22 20:50:55 +02:00
|
|
|
};
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
inline bool QskSkinHintTable::hasHints() const
|
|
|
|
{
|
|
|
|
return m_hints != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool QskSkinHintTable::hasStates() const
|
2017-08-22 20:50:55 +02:00
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
return m_hasStates;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool QskSkinHintTable::hasAnimators() const
|
|
|
|
{
|
|
|
|
return m_animatorCount;
|
2017-08-22 20:50:55 +02:00
|
|
|
}
|
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
inline bool QskSkinHintTable::hasHint( QskAspect aspect ) const
|
2017-08-22 20:50:55 +02:00
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
if ( m_hints != nullptr )
|
2017-08-22 20:50:55 +02:00
|
|
|
return m_hints->find( aspect ) != m_hints->cend();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-12-21 16:06:58 +01:00
|
|
|
inline const QVariant& QskSkinHintTable::hint( QskAspect aspect ) const
|
2017-10-17 17:34:00 +02:00
|
|
|
{
|
|
|
|
if ( m_hints != nullptr )
|
|
|
|
{
|
|
|
|
auto it = m_hints->find( aspect );
|
|
|
|
if ( it != m_hints->cend() )
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return invalidHint;
|
|
|
|
}
|
|
|
|
|
2020-12-26 12:57:08 +01:00
|
|
|
template< typename T >
|
|
|
|
inline void QskSkinHintTable::setHint( QskAspect aspect, const T& hint )
|
2017-08-22 20:50:55 +02:00
|
|
|
{
|
2020-12-26 12:57:08 +01:00
|
|
|
setHint( aspect, QVariant::fromValue( hint ) );
|
2017-08-22 20:50:55 +02:00
|
|
|
}
|
|
|
|
|
2020-12-26 12:57:08 +01:00
|
|
|
template< typename T >
|
|
|
|
inline T QskSkinHintTable::hint( QskAspect aspect ) const
|
2018-08-03 08:15:28 +02:00
|
|
|
{
|
2020-12-26 12:57:08 +01:00
|
|
|
return hint( aspect ).value< T >();
|
2017-10-19 08:44:16 +02:00
|
|
|
}
|
|
|
|
|
2017-08-22 20:50:55 +02:00
|
|
|
#endif
|