Flag/Color/Metric-Primitive united to Primitive - the initial concept
was not correct anymore as primitives like Border/Shadow are used for Color and Metric
This commit is contained in:
parent
777149aecb
commit
3112df6c2f
|
@ -35,16 +35,17 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static quint8 qskPrimitiveCount[ 3 ] =
|
static quint8 qskPrimitiveCount = QMetaEnum::fromType< QskAspect::Primitive >().keyCount();
|
||||||
{ QskAspect::FontRole + 1, QskAspect::Border + 1, QskAspect::LinkColor + 1 };
|
|
||||||
|
|
||||||
quint8 QskAspect::primitiveCount( Type type )
|
quint8 QskAspect::primitiveCount()
|
||||||
{
|
{
|
||||||
return qskPrimitiveCount[ type ];
|
return qskPrimitiveCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskAspect::reservePrimitives( Type type, quint8 count )
|
void QskAspect::reservePrimitives( quint8 count )
|
||||||
{
|
{
|
||||||
|
// applications might need to increase the count to add additional primitives
|
||||||
|
|
||||||
constexpr quint8 maxCount = 1 << 5; // we have 5 bits for the primitives
|
constexpr quint8 maxCount = 1 << 5; // we have 5 bits for the primitives
|
||||||
|
|
||||||
Q_ASSERT( count <= maxCount );
|
Q_ASSERT( count <= maxCount );
|
||||||
|
@ -57,8 +58,8 @@ void QskAspect::reservePrimitives( Type type, quint8 count )
|
||||||
count = maxCount;
|
count = maxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count > qskPrimitiveCount[ type ] )
|
if ( count > qskPrimitiveCount )
|
||||||
qskPrimitiveCount[ type ] = count;
|
qskPrimitiveCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC( AspectRegistry, qskAspectRegistry )
|
Q_GLOBAL_STATIC( AspectRegistry, qskAspectRegistry )
|
||||||
|
@ -231,19 +232,9 @@ QDebug operator<<( QDebug debug, QskAspect::Type type )
|
||||||
return qskDebugEnum( debug, "Type", type );
|
return qskDebugEnum( debug, "Type", type );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, QskAspect::FlagPrimitive primitive )
|
QDebug operator<<( QDebug debug, QskAspect::Primitive primitive )
|
||||||
{
|
{
|
||||||
return qskDebugEnum( debug, "FlagPrimitive", primitive );
|
return qskDebugEnum( debug, "Primitive", primitive );
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, QskAspect::ColorPrimitive primitive )
|
|
||||||
{
|
|
||||||
return qskDebugEnum( debug, "ColorPrimitive", primitive );
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, QskAspect::MetricPrimitive primitive )
|
|
||||||
{
|
|
||||||
return qskDebugEnum( debug, "MetricPrimitive", primitive );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<( QDebug debug, QskAspect::Subcontrol subControl )
|
QDebug operator<<( QDebug debug, QskAspect::Subcontrol subControl )
|
||||||
|
|
|
@ -28,48 +28,34 @@ class QSK_EXPORT QskAspect
|
||||||
|
|
||||||
static constexpr uint typeCount = 3;
|
static constexpr uint typeCount = 3;
|
||||||
|
|
||||||
enum FlagPrimitive : quint8
|
enum Primitive : quint8
|
||||||
{
|
{
|
||||||
NoFlagPrimitive,
|
NoPrimitive = 0,
|
||||||
|
|
||||||
Alignment,
|
Alignment,
|
||||||
Direction,
|
Direction,
|
||||||
Style,
|
Style,
|
||||||
Decoration,
|
Decoration,
|
||||||
GraphicRole,
|
GraphicRole,
|
||||||
FontRole
|
FontRole,
|
||||||
};
|
|
||||||
Q_ENUM( FlagPrimitive )
|
|
||||||
|
|
||||||
enum MetricPrimitive : quint8
|
TextColor,
|
||||||
{
|
StyleColor,
|
||||||
NoMetricPrimitive,
|
LinkColor,
|
||||||
|
|
||||||
StrutSize,
|
StrutSize,
|
||||||
|
|
||||||
Size,
|
Size,
|
||||||
Position,
|
Position,
|
||||||
|
|
||||||
Margin,
|
Margin,
|
||||||
Padding,
|
Padding,
|
||||||
Shadow,
|
|
||||||
|
|
||||||
Spacing,
|
Spacing,
|
||||||
|
|
||||||
|
Shadow,
|
||||||
Shape,
|
Shape,
|
||||||
Border
|
Border
|
||||||
};
|
};
|
||||||
Q_ENUM( MetricPrimitive )
|
Q_ENUM( Primitive )
|
||||||
|
|
||||||
enum ColorPrimitive : quint8
|
|
||||||
{
|
|
||||||
NoColorPrimitive,
|
|
||||||
|
|
||||||
TextColor,
|
|
||||||
StyleColor,
|
|
||||||
LinkColor
|
|
||||||
};
|
|
||||||
Q_ENUM( ColorPrimitive )
|
|
||||||
|
|
||||||
enum Placement : quint8
|
enum Placement : quint8
|
||||||
{
|
{
|
||||||
|
@ -123,9 +109,7 @@ class QSK_EXPORT QskAspect
|
||||||
|
|
||||||
constexpr QskAspect operator|( Subcontrol ) const noexcept;
|
constexpr QskAspect operator|( Subcontrol ) const noexcept;
|
||||||
constexpr QskAspect operator|( Type ) const noexcept;
|
constexpr QskAspect operator|( Type ) const noexcept;
|
||||||
constexpr QskAspect operator|( FlagPrimitive ) const noexcept;
|
constexpr QskAspect operator|( Primitive ) const noexcept;
|
||||||
constexpr QskAspect operator|( MetricPrimitive ) const noexcept;
|
|
||||||
constexpr QskAspect operator|( ColorPrimitive ) const noexcept;
|
|
||||||
constexpr QskAspect operator|( Placement ) const noexcept;
|
constexpr QskAspect operator|( Placement ) const noexcept;
|
||||||
constexpr QskAspect operator|( State ) const noexcept;
|
constexpr QskAspect operator|( State ) const noexcept;
|
||||||
|
|
||||||
|
@ -159,14 +143,14 @@ class QSK_EXPORT QskAspect
|
||||||
void clearState( State ) noexcept;
|
void clearState( State ) noexcept;
|
||||||
void clearStates() noexcept;
|
void clearStates() noexcept;
|
||||||
|
|
||||||
constexpr FlagPrimitive flagPrimitive() const noexcept;
|
constexpr Primitive primitive() const noexcept;
|
||||||
constexpr ColorPrimitive colorPrimitive() const noexcept;
|
void setPrimitive( Type, Primitive primitive ) noexcept;
|
||||||
constexpr MetricPrimitive metricPrimitive() const noexcept;
|
|
||||||
|
|
||||||
void setPrimitive( Type, uint primitive ) noexcept;
|
|
||||||
constexpr uint primitive() const noexcept;
|
|
||||||
void clearPrimitive() noexcept;
|
void clearPrimitive() noexcept;
|
||||||
|
|
||||||
|
constexpr Primitive flagPrimitive() const noexcept;
|
||||||
|
constexpr Primitive colorPrimitive() const noexcept;
|
||||||
|
constexpr Primitive metricPrimitive() const noexcept;
|
||||||
|
|
||||||
const char* toPrintable() const;
|
const char* toPrintable() const;
|
||||||
|
|
||||||
static State registerState( const QMetaObject*, State, const char* );
|
static State registerState( const QMetaObject*, State, const char* );
|
||||||
|
@ -176,8 +160,8 @@ class QSK_EXPORT QskAspect
|
||||||
static QVector< QByteArray > subControlNames( const QMetaObject* = nullptr );
|
static QVector< QByteArray > subControlNames( const QMetaObject* = nullptr );
|
||||||
static QVector< Subcontrol > subControls( const QMetaObject* );
|
static QVector< Subcontrol > subControls( const QMetaObject* );
|
||||||
|
|
||||||
static quint8 primitiveCount( Type );
|
static quint8 primitiveCount();
|
||||||
static void reservePrimitives( Type, quint8 count );
|
static void reservePrimitives( quint8 count );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
constexpr QskAspect( Subcontrol, Type, Placement ) noexcept;
|
constexpr QskAspect( Subcontrol, Type, Placement ) noexcept;
|
||||||
|
@ -268,22 +252,12 @@ inline constexpr QskAspect QskAspect::operator|( Type type ) const noexcept
|
||||||
m_bits.primitive, m_bits.placement, m_bits.states );
|
m_bits.primitive, m_bits.placement, m_bits.states );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect QskAspect::operator|( FlagPrimitive primitive ) const noexcept
|
inline constexpr QskAspect QskAspect::operator|( Primitive primitive ) const noexcept
|
||||||
{
|
{
|
||||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||||
primitive, m_bits.placement, m_bits.states );
|
primitive, m_bits.placement, m_bits.states );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect QskAspect::operator|( MetricPrimitive primitive ) const noexcept
|
|
||||||
{
|
|
||||||
return operator|( static_cast< FlagPrimitive >( primitive ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect QskAspect::operator|( ColorPrimitive primitive ) const noexcept
|
|
||||||
{
|
|
||||||
return operator|( static_cast< FlagPrimitive >( primitive ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect QskAspect::operator|( Placement placement ) const noexcept
|
inline constexpr QskAspect QskAspect::operator|( Placement placement ) const noexcept
|
||||||
{
|
{
|
||||||
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
return QskAspect( m_bits.subControl, m_bits.type, m_bits.isAnimator,
|
||||||
|
@ -388,38 +362,38 @@ inline void QskAspect::clearStates() noexcept
|
||||||
m_bits.states = 0;
|
m_bits.states = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect::FlagPrimitive QskAspect::flagPrimitive() const noexcept
|
inline constexpr QskAspect::Primitive QskAspect::primitive() const noexcept
|
||||||
{
|
{
|
||||||
return ( m_bits.type == Flag )
|
return static_cast< QskAspect::Primitive >( m_bits.primitive );
|
||||||
? static_cast< FlagPrimitive >( m_bits.primitive ) : NoFlagPrimitive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect::ColorPrimitive QskAspect::colorPrimitive() const noexcept
|
inline void QskAspect::setPrimitive( Type type, QskAspect::Primitive primitive ) noexcept
|
||||||
{
|
|
||||||
return ( m_bits.type == Color )
|
|
||||||
? static_cast< ColorPrimitive >( m_bits.primitive ) : NoColorPrimitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect::MetricPrimitive QskAspect::metricPrimitive() const noexcept
|
|
||||||
{
|
|
||||||
return ( m_bits.type == Metric )
|
|
||||||
? static_cast< MetricPrimitive >( m_bits.primitive ) : NoMetricPrimitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr uint QskAspect::primitive() const noexcept
|
|
||||||
{
|
|
||||||
return m_bits.primitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void QskAspect::setPrimitive( Type type, uint primitive ) noexcept
|
|
||||||
{
|
{
|
||||||
m_bits.type = type;
|
m_bits.type = type;
|
||||||
m_bits.primitive = primitive;
|
m_bits.primitive = primitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline constexpr QskAspect::Primitive QskAspect::flagPrimitive() const noexcept
|
||||||
|
{
|
||||||
|
return ( m_bits.type == Flag )
|
||||||
|
? static_cast< Primitive >( m_bits.primitive ) : NoPrimitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr QskAspect::Primitive QskAspect::colorPrimitive() const noexcept
|
||||||
|
{
|
||||||
|
return ( m_bits.type == Color )
|
||||||
|
? static_cast< Primitive >( m_bits.primitive ) : NoPrimitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr QskAspect::Primitive QskAspect::metricPrimitive() const noexcept
|
||||||
|
{
|
||||||
|
return ( m_bits.type == Metric )
|
||||||
|
? static_cast< Primitive >( m_bits.primitive ) : NoPrimitive;
|
||||||
|
}
|
||||||
|
|
||||||
inline void QskAspect::clearPrimitive() noexcept
|
inline void QskAspect::clearPrimitive() noexcept
|
||||||
{
|
{
|
||||||
m_bits.primitive = 0;
|
m_bits.primitive = NoPrimitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect::Placement QskAspect::placement() const noexcept
|
inline constexpr QskAspect::Placement QskAspect::placement() const noexcept
|
||||||
|
@ -493,37 +467,13 @@ inline constexpr QskAspect operator|(
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect operator|(
|
inline constexpr QskAspect operator|(
|
||||||
QskAspect::Subcontrol subControl, QskAspect::FlagPrimitive primitive ) noexcept
|
QskAspect::Subcontrol subControl, QskAspect::Primitive primitive ) noexcept
|
||||||
{
|
{
|
||||||
return QskAspect( subControl ) | primitive;
|
return QskAspect( subControl ) | primitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr QskAspect operator|(
|
inline constexpr QskAspect operator|(
|
||||||
QskAspect::FlagPrimitive primitive, QskAspect::Subcontrol subControl ) noexcept
|
QskAspect::Primitive primitive, QskAspect::Subcontrol subControl ) noexcept
|
||||||
{
|
|
||||||
return subControl | primitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect operator|(
|
|
||||||
QskAspect::Subcontrol subControl, QskAspect::ColorPrimitive primitive ) noexcept
|
|
||||||
{
|
|
||||||
return QskAspect( subControl ) | primitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect operator|(
|
|
||||||
QskAspect::ColorPrimitive primitive, QskAspect::Subcontrol subControl ) noexcept
|
|
||||||
{
|
|
||||||
return subControl | primitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect operator|(
|
|
||||||
QskAspect::Subcontrol subControl, QskAspect::MetricPrimitive primitive ) noexcept
|
|
||||||
{
|
|
||||||
return QskAspect( subControl ) | primitive;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskAspect operator|(
|
|
||||||
QskAspect::MetricPrimitive primitive, QskAspect::Subcontrol subControl ) noexcept
|
|
||||||
{
|
{
|
||||||
return subControl | primitive;
|
return subControl | primitive;
|
||||||
}
|
}
|
||||||
|
@ -560,11 +510,7 @@ class QDebug;
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Type );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Type );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Subcontrol );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Subcontrol );
|
||||||
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Primitive );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::FlagPrimitive );
|
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::ColorPrimitive );
|
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::MetricPrimitive );
|
|
||||||
|
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Placement );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::Placement );
|
||||||
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::State );
|
QSK_EXPORT QDebug operator<<( QDebug, QskAspect::State );
|
||||||
|
|
||||||
|
|
|
@ -1077,6 +1077,7 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated )
|
||||||
if ( control->window() && animated && isTransitionAccepted( QskAspect() ) )
|
if ( control->window() && animated && isTransitionAccepted( QskAspect() ) )
|
||||||
{
|
{
|
||||||
const auto placement = effectivePlacement();
|
const auto placement = effectivePlacement();
|
||||||
|
const auto primitiveCount = QskAspect::primitiveCount();
|
||||||
|
|
||||||
const auto subControls = control->subControls();
|
const auto subControls = control->subControls();
|
||||||
for ( const auto subControl : subControls )
|
for ( const auto subControl : subControls )
|
||||||
|
@ -1098,10 +1099,9 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated )
|
||||||
that differ between the states
|
that differ between the states
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const auto primitiveCount = QskAspect::primitiveCount( type );
|
for ( uint i = 0; i < primitiveCount; i++ )
|
||||||
|
|
||||||
for ( uint primitive = 0; primitive < primitiveCount; primitive++ )
|
|
||||||
{
|
{
|
||||||
|
const auto primitive = static_cast< QskAspect::Primitive >( i );
|
||||||
aspect.setPrimitive( type, primitive );
|
aspect.setPrimitive( type, primitive );
|
||||||
|
|
||||||
auto a1 = aspect | m_data->skinState;
|
auto a1 = aspect | m_data->skinState;
|
||||||
|
|
Loading…
Reference in New Issue