QskSkinHintTable::setHint indicating changes as return value
This commit is contained in:
parent
c8be7224cf
commit
3901c02368
|
@ -6,6 +6,8 @@
|
||||||
#include "QskSkinHintTable.h"
|
#include "QskSkinHintTable.h"
|
||||||
#include "QskAnimationHint.h"
|
#include "QskAnimationHint.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
const QVariant QskSkinHintTable::invalidHint;
|
const QVariant QskSkinHintTable::invalidHint;
|
||||||
|
|
||||||
inline const QVariant* qskResolvedHint( QskAspect aspect,
|
inline const QVariant* qskResolvedHint( QskAspect aspect,
|
||||||
|
@ -45,16 +47,13 @@ inline const QVariant* qskResolvedHint( QskAspect aspect,
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSkinHintTable::QskSkinHintTable()
|
QskSkinHintTable::QskSkinHintTable()
|
||||||
: m_hints( nullptr )
|
|
||||||
, m_animatorCount( 0 )
|
|
||||||
, m_hasStates( false )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSkinHintTable::QskSkinHintTable( const QskSkinHintTable& other )
|
QskSkinHintTable::QskSkinHintTable( const QskSkinHintTable& other )
|
||||||
: m_hints( nullptr )
|
: m_hints( nullptr )
|
||||||
, m_animatorCount( other.m_animatorCount )
|
, m_animatorCount( other.m_animatorCount )
|
||||||
, m_hasStates( other.m_hasStates )
|
, m_statefulCount( other.m_statefulCount )
|
||||||
{
|
{
|
||||||
if ( other.m_hints )
|
if ( other.m_hints )
|
||||||
m_hints = new HintMap( *( other.m_hints ) );
|
m_hints = new HintMap( *( other.m_hints ) );
|
||||||
|
@ -68,7 +67,7 @@ QskSkinHintTable::~QskSkinHintTable()
|
||||||
QskSkinHintTable& QskSkinHintTable::operator=( const QskSkinHintTable& other )
|
QskSkinHintTable& QskSkinHintTable::operator=( const QskSkinHintTable& other )
|
||||||
{
|
{
|
||||||
m_animatorCount = other.m_animatorCount;
|
m_animatorCount = other.m_animatorCount;
|
||||||
m_hasStates = other.m_hasStates;
|
m_statefulCount = other.m_statefulCount;
|
||||||
|
|
||||||
if ( other.m_hints )
|
if ( other.m_hints )
|
||||||
{
|
{
|
||||||
|
@ -95,7 +94,9 @@ const std::unordered_map< QskAspect, QVariant >& QskSkinHintTable::hints() const
|
||||||
return dummyHints;
|
return dummyHints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinHintTable::setHint( QskAspect aspect, const QVariant& skinHint )
|
#define QSK_ASSERT_COUNTER( x ) Q_ASSERT( x < std::numeric_limits< decltype( x ) >::max() )
|
||||||
|
|
||||||
|
bool QskSkinHintTable::setHint( QskAspect aspect, const QVariant& skinHint )
|
||||||
{
|
{
|
||||||
if ( m_hints == nullptr )
|
if ( m_hints == nullptr )
|
||||||
m_hints = new HintMap();
|
m_hints = new HintMap();
|
||||||
|
@ -104,18 +105,33 @@ void QskSkinHintTable::setHint( QskAspect aspect, const QVariant& skinHint )
|
||||||
if ( it == m_hints->end() )
|
if ( it == m_hints->end() )
|
||||||
{
|
{
|
||||||
m_hints->emplace( aspect, skinHint );
|
m_hints->emplace( aspect, skinHint );
|
||||||
|
|
||||||
if ( aspect.isAnimator() )
|
if ( aspect.isAnimator() )
|
||||||
m_animatorCount++;
|
|
||||||
}
|
|
||||||
else if ( it->second != skinHint )
|
|
||||||
{
|
{
|
||||||
it->second = skinHint;
|
m_animatorCount++;
|
||||||
|
QSK_ASSERT_COUNTER( m_animatorCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aspect.hasState() )
|
if ( aspect.hasState() )
|
||||||
m_hasStates = true;
|
{
|
||||||
|
m_statefulCount++;
|
||||||
|
QSK_ASSERT_COUNTER( m_statefulCount );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( it->second != skinHint )
|
||||||
|
{
|
||||||
|
it->second = skinHint;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef QSK_ASSERT_COUNTER
|
||||||
|
|
||||||
bool QskSkinHintTable::removeHint( QskAspect aspect )
|
bool QskSkinHintTable::removeHint( QskAspect aspect )
|
||||||
{
|
{
|
||||||
if ( m_hints == nullptr )
|
if ( m_hints == nullptr )
|
||||||
|
@ -128,6 +144,9 @@ bool QskSkinHintTable::removeHint( QskAspect aspect )
|
||||||
if ( aspect.isAnimator() )
|
if ( aspect.isAnimator() )
|
||||||
m_animatorCount--;
|
m_animatorCount--;
|
||||||
|
|
||||||
|
if ( aspect.hasState() )
|
||||||
|
m_statefulCount--;
|
||||||
|
|
||||||
if ( m_hints->empty() )
|
if ( m_hints->empty() )
|
||||||
{
|
{
|
||||||
delete m_hints;
|
delete m_hints;
|
||||||
|
@ -151,6 +170,9 @@ QVariant QskSkinHintTable::takeHint( QskAspect aspect )
|
||||||
if ( aspect.isAnimator() )
|
if ( aspect.isAnimator() )
|
||||||
m_animatorCount--;
|
m_animatorCount--;
|
||||||
|
|
||||||
|
if ( aspect.hasState() )
|
||||||
|
m_statefulCount--;
|
||||||
|
|
||||||
if ( m_hints->empty() )
|
if ( m_hints->empty() )
|
||||||
{
|
{
|
||||||
delete m_hints;
|
delete m_hints;
|
||||||
|
@ -170,6 +192,7 @@ void QskSkinHintTable::clear()
|
||||||
m_hints = nullptr;
|
m_hints = nullptr;
|
||||||
|
|
||||||
m_animatorCount = 0;
|
m_animatorCount = 0;
|
||||||
|
m_statefulCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVariant* QskSkinHintTable::resolvedHint(
|
const QVariant* QskSkinHintTable::resolvedHint(
|
||||||
|
@ -221,11 +244,11 @@ QskAnimationHint QskSkinHintTable::animation( QskAspect aspect ) const
|
||||||
return hint< QskAnimationHint >( aspect );
|
return hint< QskAnimationHint >( aspect );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinHintTable::setAnimation(
|
bool QskSkinHintTable::setAnimation(
|
||||||
QskAspect aspect, QskAnimationHint animation )
|
QskAspect aspect, QskAnimationHint animation )
|
||||||
{
|
{
|
||||||
aspect.setAnimator( true );
|
aspect.setAnimator( true );
|
||||||
setHint( aspect, animation );
|
return setHint( aspect, animation );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinHintTable::isResolutionMatching(
|
bool QskSkinHintTable::isResolutionMatching(
|
||||||
|
|
|
@ -23,13 +23,13 @@ class QSK_EXPORT QskSkinHintTable
|
||||||
|
|
||||||
QskSkinHintTable& operator=( const QskSkinHintTable& );
|
QskSkinHintTable& operator=( const QskSkinHintTable& );
|
||||||
|
|
||||||
void setAnimation( QskAspect, QskAnimationHint );
|
bool setAnimation( QskAspect, QskAnimationHint );
|
||||||
QskAnimationHint animation( QskAspect ) const;
|
QskAnimationHint animation( QskAspect ) const;
|
||||||
|
|
||||||
void setHint( QskAspect, const QVariant& );
|
bool setHint( QskAspect, const QVariant& );
|
||||||
const QVariant& hint( QskAspect ) const;
|
const QVariant& hint( QskAspect ) const;
|
||||||
|
|
||||||
template< typename T > void setHint( QskAspect, const T& );
|
template< typename T > bool setHint( QskAspect, const T& );
|
||||||
template< typename T > T hint( QskAspect ) const;
|
template< typename T > T hint( QskAspect ) const;
|
||||||
|
|
||||||
bool removeHint( QskAspect );
|
bool removeHint( QskAspect );
|
||||||
|
@ -59,10 +59,10 @@ class QSK_EXPORT QskSkinHintTable
|
||||||
static const QVariant invalidHint;
|
static const QVariant invalidHint;
|
||||||
|
|
||||||
typedef std::unordered_map< QskAspect, QVariant > HintMap;
|
typedef std::unordered_map< QskAspect, QVariant > HintMap;
|
||||||
HintMap* m_hints;
|
HintMap* m_hints = nullptr;
|
||||||
|
|
||||||
quint16 m_animatorCount;
|
unsigned short m_animatorCount = 0;
|
||||||
bool m_hasStates : 1;
|
unsigned short m_statefulCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool QskSkinHintTable::hasHints() const
|
inline bool QskSkinHintTable::hasHints() const
|
||||||
|
@ -72,12 +72,12 @@ inline bool QskSkinHintTable::hasHints() const
|
||||||
|
|
||||||
inline bool QskSkinHintTable::hasStates() const
|
inline bool QskSkinHintTable::hasStates() const
|
||||||
{
|
{
|
||||||
return m_hasStates;
|
return m_statefulCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool QskSkinHintTable::hasAnimators() const
|
inline bool QskSkinHintTable::hasAnimators() const
|
||||||
{
|
{
|
||||||
return m_animatorCount;
|
return m_animatorCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool QskSkinHintTable::hasHint( QskAspect aspect ) const
|
inline bool QskSkinHintTable::hasHint( QskAspect aspect ) const
|
||||||
|
@ -101,9 +101,9 @@ inline const QVariant& QskSkinHintTable::hint( QskAspect aspect ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
inline void QskSkinHintTable::setHint( QskAspect aspect, const T& hint )
|
inline bool QskSkinHintTable::setHint( QskAspect aspect, const T& hint )
|
||||||
{
|
{
|
||||||
setHint( aspect, QVariant::fromValue( hint ) );
|
return setHint( aspect, QVariant::fromValue( hint ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
|
|
@ -55,10 +55,10 @@ static inline QVariant qskTypedNullValue( const QVariant& value )
|
||||||
return QVariant( vType, nullptr );
|
return QVariant( vType, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qskSetFlag( QskSkinnable* skinnable,
|
static inline bool qskSetFlag( QskSkinnable* skinnable,
|
||||||
const QskAspect aspect, int flag )
|
const QskAspect aspect, int flag )
|
||||||
{
|
{
|
||||||
skinnable->setSkinHint( aspect | QskAspect::Flag, QVariant( flag ) );
|
return skinnable->setSkinHint( aspect | QskAspect::Flag, QVariant( flag ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int qskFlag( const QskSkinnable* skinnable,
|
static inline int qskFlag( const QskSkinnable* skinnable,
|
||||||
|
@ -67,17 +67,17 @@ static inline int qskFlag( const QskSkinnable* skinnable,
|
||||||
return skinnable->effectiveSkinHint( aspect | QskAspect::Flag, status ).toInt();
|
return skinnable->effectiveSkinHint( aspect | QskAspect::Flag, status ).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qskSetMetric( QskSkinnable* skinnable,
|
static inline bool qskSetMetric( QskSkinnable* skinnable,
|
||||||
const QskAspect aspect, const QVariant& metric )
|
const QskAspect aspect, const QVariant& metric )
|
||||||
{
|
{
|
||||||
skinnable->setSkinHint( aspect | QskAspect::Metric, metric );
|
return skinnable->setSkinHint( aspect | QskAspect::Metric, metric );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static inline void qskSetMetric( QskSkinnable* skinnable,
|
static inline bool qskSetMetric( QskSkinnable* skinnable,
|
||||||
QskAspect aspect, const T& metric )
|
QskAspect aspect, const T& metric )
|
||||||
{
|
{
|
||||||
qskSetMetric( skinnable, aspect, QVariant::fromValue( metric ) );
|
return qskSetMetric( skinnable, aspect, QVariant::fromValue( metric ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
@ -88,17 +88,17 @@ static inline T qskMetric( const QskSkinnable* skinnable,
|
||||||
aspect | QskAspect::Metric, status ).value< T >();
|
aspect | QskAspect::Metric, status ).value< T >();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qskSetColor( QskSkinnable* skinnable,
|
static inline bool qskSetColor( QskSkinnable* skinnable,
|
||||||
const QskAspect aspect, const QVariant& color )
|
const QskAspect aspect, const QVariant& color )
|
||||||
{
|
{
|
||||||
skinnable->setSkinHint( aspect | QskAspect::Color, color );
|
return skinnable->setSkinHint( aspect | QskAspect::Color, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static inline void qskSetColor( QskSkinnable* skinnable,
|
static inline bool qskSetColor( QskSkinnable* skinnable,
|
||||||
const QskAspect aspect, const T& color )
|
const QskAspect aspect, const T& color )
|
||||||
{
|
{
|
||||||
qskSetColor( skinnable, aspect, QVariant::fromValue( color ) );
|
return qskSetColor( skinnable, aspect, QVariant::fromValue( color ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
@ -193,9 +193,9 @@ const QskSkinHintTable& QskSkinnable::hintTable() const
|
||||||
return m_data->hintTable;
|
return m_data->hintTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setFlagHint( const QskAspect aspect, int flag )
|
bool QskSkinnable::setFlagHint( const QskAspect aspect, int flag )
|
||||||
{
|
{
|
||||||
qskSetFlag( this, aspect, flag );
|
return qskSetFlag( this, aspect, flag );
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskSkinnable::flagHint( const QskAspect aspect ) const
|
int QskSkinnable::flagHint( const QskAspect aspect ) const
|
||||||
|
@ -203,9 +203,9 @@ int QskSkinnable::flagHint( const QskAspect aspect ) const
|
||||||
return effectiveSkinHint( aspect ).toInt();
|
return effectiveSkinHint( aspect ).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setAlignmentHint( const QskAspect aspect, Qt::Alignment alignment )
|
bool QskSkinnable::setAlignmentHint( const QskAspect aspect, Qt::Alignment alignment )
|
||||||
{
|
{
|
||||||
qskSetFlag( this, aspect | QskAspect::Alignment, alignment );
|
return qskSetFlag( this, aspect | QskAspect::Alignment, alignment );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetAlignmentHint( const QskAspect aspect )
|
bool QskSkinnable::resetAlignmentHint( const QskAspect aspect )
|
||||||
|
@ -213,19 +213,19 @@ bool QskSkinnable::resetAlignmentHint( const QskAspect aspect )
|
||||||
return resetFlagHint( aspect | QskAspect::Alignment );
|
return resetFlagHint( aspect | QskAspect::Alignment );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setColor( const QskAspect aspect, const QColor& color )
|
bool QskSkinnable::setColor( const QskAspect aspect, const QColor& color )
|
||||||
{
|
{
|
||||||
qskSetColor( this, aspect, color );
|
return qskSetColor( this, aspect, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setColor( const QskAspect aspect, Qt::GlobalColor color )
|
bool QskSkinnable::setColor( const QskAspect aspect, Qt::GlobalColor color )
|
||||||
{
|
{
|
||||||
qskSetColor( this, aspect, QColor( color ) );
|
return qskSetColor( this, aspect, QColor( color ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setColor( const QskAspect aspect, QRgb rgb )
|
bool QskSkinnable::setColor( const QskAspect aspect, QRgb rgb )
|
||||||
{
|
{
|
||||||
qskSetColor( this, aspect, QColor::fromRgba( rgb ) );
|
return qskSetColor( this, aspect, QColor::fromRgba( rgb ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QskSkinnable::color( const QskAspect aspect, QskSkinHintStatus* status ) const
|
QColor QskSkinnable::color( const QskAspect aspect, QskSkinHintStatus* status ) const
|
||||||
|
@ -233,9 +233,9 @@ QColor QskSkinnable::color( const QskAspect aspect, QskSkinHintStatus* status )
|
||||||
return qskColor< QColor >( this, aspect, status );
|
return qskColor< QColor >( this, aspect, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setMetric( const QskAspect aspect, qreal metric )
|
bool QskSkinnable::setMetric( const QskAspect aspect, qreal metric )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect, metric );
|
return qskSetMetric( this, aspect, metric );
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QskSkinnable::metric( const QskAspect aspect, QskSkinHintStatus* status ) const
|
qreal QskSkinnable::metric( const QskAspect aspect, QskSkinHintStatus* status ) const
|
||||||
|
@ -243,15 +243,15 @@ qreal QskSkinnable::metric( const QskAspect aspect, QskSkinHintStatus* status )
|
||||||
return qskMetric< qreal >( this, aspect, status );
|
return qskMetric< qreal >( this, aspect, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setStrutSizeHint(
|
bool QskSkinnable::setStrutSizeHint(
|
||||||
const QskAspect aspect, qreal width, qreal height )
|
const QskAspect aspect, qreal width, qreal height )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect, QSizeF( width, height ) );
|
return qskSetMetric( this, aspect, QSizeF( width, height ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setStrutSizeHint( const QskAspect aspect, const QSizeF& strut )
|
bool QskSkinnable::setStrutSizeHint( const QskAspect aspect, const QSizeF& strut )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect, strut );
|
return qskSetMetric( this, aspect, strut );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetStrutSizeHint( const QskAspect aspect )
|
bool QskSkinnable::resetStrutSizeHint( const QskAspect aspect )
|
||||||
|
@ -265,14 +265,14 @@ QSizeF QskSkinnable::strutSizeHint(
|
||||||
return qskMetric< QSizeF >( this, aspect | QskAspect::StrutSize, status );
|
return qskMetric< QSizeF >( this, aspect | QskAspect::StrutSize, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setMarginHint( const QskAspect aspect, qreal margins )
|
bool QskSkinnable::setMarginHint( const QskAspect aspect, qreal margins )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Margin, QskMargins( margins ) );
|
return qskSetMetric( this, aspect | QskAspect::Margin, QskMargins( margins ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setMarginHint( const QskAspect aspect, const QMarginsF& margins )
|
bool QskSkinnable::setMarginHint( const QskAspect aspect, const QMarginsF& margins )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Margin, QskMargins( margins ) );
|
return qskSetMetric( this, aspect | QskAspect::Margin, QskMargins( margins ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetMarginHint( const QskAspect aspect )
|
bool QskSkinnable::resetMarginHint( const QskAspect aspect )
|
||||||
|
@ -286,14 +286,14 @@ QMarginsF QskSkinnable::marginHint(
|
||||||
return qskMetric< QskMargins >( this, aspect | QskAspect::Margin, status );
|
return qskMetric< QskMargins >( this, aspect | QskAspect::Margin, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setPaddingHint( const QskAspect aspect, qreal padding )
|
bool QskSkinnable::setPaddingHint( const QskAspect aspect, qreal padding )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Padding, QskMargins( padding ) );
|
return qskSetMetric( this, aspect | QskAspect::Padding, QskMargins( padding ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setPaddingHint( const QskAspect aspect, const QMarginsF& padding )
|
bool QskSkinnable::setPaddingHint( const QskAspect aspect, const QMarginsF& padding )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Padding, QskMargins( padding ) );
|
return qskSetMetric( this, aspect | QskAspect::Padding, QskMargins( padding ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetPaddingHint( const QskAspect aspect )
|
bool QskSkinnable::resetPaddingHint( const QskAspect aspect )
|
||||||
|
@ -307,10 +307,10 @@ QMarginsF QskSkinnable::paddingHint(
|
||||||
return qskMetric< QskMargins >( this, aspect | QskAspect::Padding, status );
|
return qskMetric< QskMargins >( this, aspect | QskAspect::Padding, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setGradientHint(
|
bool QskSkinnable::setGradientHint(
|
||||||
const QskAspect aspect, const QskGradient& gradient )
|
const QskAspect aspect, const QskGradient& gradient )
|
||||||
{
|
{
|
||||||
qskSetColor( this, aspect, gradient );
|
return qskSetColor( this, aspect, gradient );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient QskSkinnable::gradientHint(
|
QskGradient QskSkinnable::gradientHint(
|
||||||
|
@ -319,10 +319,10 @@ QskGradient QskSkinnable::gradientHint(
|
||||||
return qskColor< QskGradient >( this, aspect, status );
|
return qskColor< QskGradient >( this, aspect, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setBoxShapeHint(
|
bool QskSkinnable::setBoxShapeHint(
|
||||||
const QskAspect aspect, const QskBoxShapeMetrics& shape )
|
const QskAspect aspect, const QskBoxShapeMetrics& shape )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Shape, shape );
|
return qskSetMetric( this, aspect | QskAspect::Shape, shape );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetBoxShapeHint( const QskAspect aspect )
|
bool QskSkinnable::resetBoxShapeHint( const QskAspect aspect )
|
||||||
|
@ -337,10 +337,10 @@ QskBoxShapeMetrics QskSkinnable::boxShapeHint(
|
||||||
this, aspect | QskAspect::Shape, status );
|
this, aspect | QskAspect::Shape, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setBoxBorderMetricsHint(
|
bool QskSkinnable::setBoxBorderMetricsHint(
|
||||||
const QskAspect aspect, const QskBoxBorderMetrics& border )
|
const QskAspect aspect, const QskBoxBorderMetrics& border )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Border, border );
|
return qskSetMetric( this, aspect | QskAspect::Border, border );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetBoxBorderMetricsHint( const QskAspect aspect )
|
bool QskSkinnable::resetBoxBorderMetricsHint( const QskAspect aspect )
|
||||||
|
@ -355,10 +355,10 @@ QskBoxBorderMetrics QskSkinnable::boxBorderMetricsHint(
|
||||||
this, aspect | QskAspect::Border, status );
|
this, aspect | QskAspect::Border, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setBoxBorderColorsHint(
|
bool QskSkinnable::setBoxBorderColorsHint(
|
||||||
const QskAspect aspect, const QskBoxBorderColors& colors )
|
const QskAspect aspect, const QskBoxBorderColors& colors )
|
||||||
{
|
{
|
||||||
qskSetColor( this, aspect | QskAspect::Border, colors );
|
return qskSetColor( this, aspect | QskAspect::Border, colors );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetBoxBorderColorsHint( const QskAspect aspect )
|
bool QskSkinnable::resetBoxBorderColorsHint( const QskAspect aspect )
|
||||||
|
@ -373,9 +373,9 @@ QskBoxBorderColors QskSkinnable::boxBorderColorsHint(
|
||||||
this, aspect | QskAspect::Border, status );
|
this, aspect | QskAspect::Border, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setSpacingHint( const QskAspect aspect, qreal spacing )
|
bool QskSkinnable::setSpacingHint( const QskAspect aspect, qreal spacing )
|
||||||
{
|
{
|
||||||
qskSetMetric( this, aspect | QskAspect::Spacing, spacing );
|
return qskSetMetric( this, aspect | QskAspect::Spacing, spacing );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetSpacingHint( const QskAspect aspect )
|
bool QskSkinnable::resetSpacingHint( const QskAspect aspect )
|
||||||
|
@ -389,9 +389,9 @@ qreal QskSkinnable::spacingHint(
|
||||||
return qskMetric< qreal >( this, aspect | QskAspect::Spacing, status );
|
return qskMetric< qreal >( this, aspect | QskAspect::Spacing, status );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setFontRole( const QskAspect aspect, int role )
|
bool QskSkinnable::setFontRole( const QskAspect aspect, int role )
|
||||||
{
|
{
|
||||||
qskSetFlag( this, aspect | QskAspect::FontRole, role );
|
return qskSetFlag( this, aspect | QskAspect::FontRole, role );
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskSkinnable::fontRole(
|
int QskSkinnable::fontRole(
|
||||||
|
@ -405,9 +405,9 @@ QFont QskSkinnable::effectiveFont( const QskAspect aspect ) const
|
||||||
return effectiveSkin()->font( fontRole( aspect ) );
|
return effectiveSkin()->font( fontRole( aspect ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setGraphicRole( const QskAspect aspect, int role )
|
bool QskSkinnable::setGraphicRole( const QskAspect aspect, int role )
|
||||||
{
|
{
|
||||||
qskSetFlag( this, aspect | QskAspect::GraphicRole, role );
|
return qskSetFlag( this, aspect | QskAspect::GraphicRole, role );
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskSkinnable::graphicRole(
|
int QskSkinnable::graphicRole(
|
||||||
|
@ -460,11 +460,11 @@ QskColorFilter QskSkinnable::effectiveGraphicFilter( QskAspect aspect ) const
|
||||||
return effectiveSkin()->graphicFilter( hint.toInt() );
|
return effectiveSkin()->graphicFilter( hint.toInt() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setAnimationHint(
|
bool QskSkinnable::setAnimationHint(
|
||||||
QskAspect aspect, QskAnimationHint animation )
|
QskAspect aspect, QskAnimationHint animation )
|
||||||
{
|
{
|
||||||
aspect.setSubControl( effectiveSubcontrol( aspect.subControl() ) );
|
aspect.setSubControl( effectiveSubcontrol( aspect.subControl() ) );
|
||||||
m_data->hintTable.setAnimation( aspect, animation );
|
return m_data->hintTable.setAnimation( aspect, animation );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskAnimationHint QskSkinnable::animationHint(
|
QskAnimationHint QskSkinnable::animationHint(
|
||||||
|
@ -519,10 +519,21 @@ QskAnimationHint QskSkinnable::effectiveAnimation(
|
||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSkinnable::setSkinHint( QskAspect aspect, const QVariant& skinHint )
|
bool QskSkinnable::setSkinHint( QskAspect aspect, const QVariant& skinHint )
|
||||||
{
|
{
|
||||||
|
if ( aspect.hasState() )
|
||||||
|
{
|
||||||
|
qWarning() << "QskSkinnable::setSkinHint: setting hints with states is discouraged - "
|
||||||
|
"use QskSkinTableEditor if you are sure, that you need this.";
|
||||||
|
qWarning() << "QskAspect:" << aspect.stateless() << skinStateAsPrintable( aspect.state() );
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
aspect.clearStates();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
aspect.setSubControl( effectiveSubcontrol( aspect.subControl() ) );
|
aspect.setSubControl( effectiveSubcontrol( aspect.subControl() ) );
|
||||||
m_data->hintTable.setHint( aspect, skinHint );
|
return m_data->hintTable.setHint( aspect, skinHint );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskSkinnable::resetSkinHint( QskAspect aspect )
|
bool QskSkinnable::resetSkinHint( QskAspect aspect )
|
||||||
|
|
|
@ -75,74 +75,14 @@ class QSK_EXPORT QskSkinnable
|
||||||
void setSkinlet( const QskSkinlet* skinlet );
|
void setSkinlet( const QskSkinlet* skinlet );
|
||||||
const QskSkinlet* skinlet() const;
|
const QskSkinlet* skinlet() const;
|
||||||
|
|
||||||
void setColor( QskAspect, Qt::GlobalColor );
|
|
||||||
void setColor( QskAspect, QRgb );
|
|
||||||
void setColor( QskAspect, const QColor& );
|
|
||||||
bool resetColor( QskAspect );
|
|
||||||
QColor color( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setMetric( QskAspect, qreal metric );
|
|
||||||
bool resetMetric( QskAspect );
|
|
||||||
qreal metric( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setFlagHint( QskAspect, int flag );
|
|
||||||
bool resetFlagHint( QskAspect );
|
|
||||||
int flagHint( QskAspect ) const;
|
|
||||||
template< typename T > T flagHint( QskAspect, T = T() ) const;
|
|
||||||
|
|
||||||
void setStrutSizeHint( QskAspect, const QSizeF& );
|
|
||||||
void setStrutSizeHint( QskAspect, qreal width, qreal height );
|
|
||||||
bool resetStrutSizeHint( QskAspect );
|
|
||||||
QSizeF strutSizeHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setMarginHint( QskAspect, qreal );
|
|
||||||
void setMarginHint( QskAspect, const QMarginsF& );
|
|
||||||
bool resetMarginHint( QskAspect );
|
|
||||||
QMarginsF marginHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setPaddingHint( QskAspect, qreal );
|
|
||||||
void setPaddingHint( QskAspect, const QMarginsF& );
|
|
||||||
bool resetPaddingHint( QskAspect );
|
|
||||||
QMarginsF paddingHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setGradientHint( QskAspect, const QskGradient& );
|
|
||||||
QskGradient gradientHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setBoxShapeHint( QskAspect, const QskBoxShapeMetrics& );
|
|
||||||
bool resetBoxShapeHint( QskAspect );
|
|
||||||
QskBoxShapeMetrics boxShapeHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setBoxBorderMetricsHint( QskAspect, const QskBoxBorderMetrics& );
|
|
||||||
bool resetBoxBorderMetricsHint( QskAspect );
|
|
||||||
QskBoxBorderMetrics boxBorderMetricsHint(
|
|
||||||
QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setBoxBorderColorsHint( QskAspect, const QskBoxBorderColors& );
|
|
||||||
bool resetBoxBorderColorsHint( QskAspect );
|
|
||||||
QskBoxBorderColors boxBorderColorsHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setSpacingHint( QskAspect, qreal );
|
|
||||||
bool resetSpacingHint( QskAspect );
|
|
||||||
qreal spacingHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
void setAlignmentHint( QskAspect, Qt::Alignment );
|
|
||||||
bool resetAlignmentHint( QskAspect );
|
|
||||||
Qt::Alignment alignmentHint( QskAspect, Qt::Alignment = Qt::Alignment() ) const;
|
|
||||||
|
|
||||||
void setFontRole( QskAspect, int role );
|
|
||||||
int fontRole( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
QFont effectiveFont( QskAspect ) const;
|
QFont effectiveFont( QskAspect ) const;
|
||||||
|
|
||||||
void setGraphicRole( QskAspect, int role );
|
|
||||||
int graphicRole( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
|
||||||
|
|
||||||
QskColorFilter effectiveGraphicFilter( QskAspect ) const;
|
QskColorFilter effectiveGraphicFilter( QskAspect ) const;
|
||||||
|
|
||||||
void setAnimationHint( QskAspect, QskAnimationHint );
|
bool setAnimationHint( QskAspect, QskAnimationHint );
|
||||||
QskAnimationHint animationHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
QskAnimationHint animationHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
void setSkinHint( QskAspect, const QVariant& );
|
bool setSkinHint( QskAspect, const QVariant& );
|
||||||
bool resetSkinHint( QskAspect );
|
bool resetSkinHint( QskAspect );
|
||||||
|
|
||||||
QskAnimationHint effectiveAnimation( QskAspect::Type, QskAspect::Subcontrol,
|
QskAnimationHint effectiveAnimation( QskAspect::Type, QskAspect::Subcontrol,
|
||||||
|
@ -187,6 +127,68 @@ class QSK_EXPORT QskSkinnable
|
||||||
void setSkinState( QskAspect::State, bool animated = true );
|
void setSkinState( QskAspect::State, bool animated = true );
|
||||||
void setSkinStateFlag( QskAspect::State, bool on = true );
|
void setSkinStateFlag( QskAspect::State, bool on = true );
|
||||||
|
|
||||||
|
// type aware methods for accessing skin hints
|
||||||
|
|
||||||
|
bool setColor( QskAspect, Qt::GlobalColor );
|
||||||
|
bool setColor( QskAspect, QRgb );
|
||||||
|
bool setColor( QskAspect, const QColor& );
|
||||||
|
bool resetColor( QskAspect );
|
||||||
|
QColor color( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setMetric( QskAspect, qreal metric );
|
||||||
|
bool resetMetric( QskAspect );
|
||||||
|
qreal metric( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setFlagHint( QskAspect, int flag );
|
||||||
|
bool resetFlagHint( QskAspect );
|
||||||
|
int flagHint( QskAspect ) const;
|
||||||
|
template< typename T > T flagHint( QskAspect, T = T() ) const;
|
||||||
|
|
||||||
|
bool setStrutSizeHint( QskAspect, const QSizeF& );
|
||||||
|
bool setStrutSizeHint( QskAspect, qreal width, qreal height );
|
||||||
|
bool resetStrutSizeHint( QskAspect );
|
||||||
|
QSizeF strutSizeHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setMarginHint( QskAspect, qreal );
|
||||||
|
bool setMarginHint( QskAspect, const QMarginsF& );
|
||||||
|
bool resetMarginHint( QskAspect );
|
||||||
|
QMarginsF marginHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setPaddingHint( QskAspect, qreal );
|
||||||
|
bool setPaddingHint( QskAspect, const QMarginsF& );
|
||||||
|
bool resetPaddingHint( QskAspect );
|
||||||
|
QMarginsF paddingHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setGradientHint( QskAspect, const QskGradient& );
|
||||||
|
QskGradient gradientHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setBoxShapeHint( QskAspect, const QskBoxShapeMetrics& );
|
||||||
|
bool resetBoxShapeHint( QskAspect );
|
||||||
|
QskBoxShapeMetrics boxShapeHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setBoxBorderMetricsHint( QskAspect, const QskBoxBorderMetrics& );
|
||||||
|
bool resetBoxBorderMetricsHint( QskAspect );
|
||||||
|
QskBoxBorderMetrics boxBorderMetricsHint(
|
||||||
|
QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setBoxBorderColorsHint( QskAspect, const QskBoxBorderColors& );
|
||||||
|
bool resetBoxBorderColorsHint( QskAspect );
|
||||||
|
QskBoxBorderColors boxBorderColorsHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setSpacingHint( QskAspect, qreal );
|
||||||
|
bool resetSpacingHint( QskAspect );
|
||||||
|
qreal spacingHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setAlignmentHint( QskAspect, Qt::Alignment );
|
||||||
|
bool resetAlignmentHint( QskAspect );
|
||||||
|
Qt::Alignment alignmentHint( QskAspect, Qt::Alignment = Qt::Alignment() ) const;
|
||||||
|
|
||||||
|
bool setFontRole( QskAspect, int role );
|
||||||
|
int fontRole( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
|
bool setGraphicRole( QskAspect, int role );
|
||||||
|
int graphicRole( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateNode( QSGNode* );
|
virtual void updateNode( QSGNode* );
|
||||||
virtual bool isTransitionAccepted( QskAspect ) const;
|
virtual bool isTransitionAccepted( QskAspect ) const;
|
||||||
|
|
Loading…
Reference in New Issue