QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskAspect Class Reference

#include <QskAspect.h>

Detailed Description

Lookup key for a QskSkinHintTable.

QskAspect is used by the themeing system to determine a a certain aspect of a QskSkinnable. While an aspect is simply a 64-bit unsigned integer, it is composed of smaller enum bitfields which can be ORed together to describe a more specific part of the user interface.

For example, the border colors of a QskPushButton while pressed is defined by combining the State (QskAbstractButton::Pressed) with the Subcontrol (QskPushButton::Panel), the Primitive (QskAspect::Border), and the Type (QskAspect::Color) as so:

auto aspect = QskPushButton::Panel | QskAbstractButton::Pressed | QskAspect::Color | QskAspect::Border
See also
QskSkinnable::effectiveSkinHint(), QskSkinHintTable

Definition at line 14 of file QskAspect.h.

Public Types

enum  Type : quint8 { NoType = 0 , Metric = 1 , Color = 2 }
 Represents the type of the Aspect. More...
 
enum  Section : quint8 {
  Body = 0 , Header , Footer , Card ,
  Floating
}
 
enum  Primitive : quint8 {
  NoPrimitive = 0 , Alignment , Direction , Style ,
  Option , GraphicRole , FontRole , Symbol ,
  TextColor , StyleColor , LinkColor , StrutSize ,
  Size , Position , Margin , Padding ,
  Spacing , Shadow , Shape , Border ,
  Graduation
}
 Represents a specific element or attribute. More...
 
enum  Variation : quint8 {
  NoVariation = 0 , Vertical = Qt::Vertical , Horizontal = Qt::Horizontal , Lower = 1 ,
  Upper = 2 , Top = 1 , Left = 2 , Right = 3 ,
  Bottom = 4 , Tiny = 1 , Small = 2 , Large = 3 ,
  Huge = 4
}
 Some sort of variation. More...
 
enum  Subcontrol : quint16 { NoSubcontrol = 0 , LastSubcontrol = ( 1 << 12 ) - 1 }
 For use within the rendering or lay-outing of a specific QskSkinnable. More...
 
enum  State : quint16 {
  NoState = 0 , FirstSystemState = 1 << 0 , FirstUserState = 1 << 5 , LastUserState = 1 << 11 ,
  LastSystemState = 1 << 15 , AllStates = 0xFFFF
}
 

Static Public Attributes

static constexpr uint typeCount = 3
 
static constexpr uint FirstUserSection = Section::Floating + 1
 
static constexpr uint LastSection = ( 1 << 4 ) - 1
 

Public Member Functions

constexpr QskAspect () noexcept
 
constexpr QskAspect (Subcontrol) noexcept
 
constexpr QskAspect (Section) noexcept
 
constexpr QskAspect (Type) noexcept
 
constexpr QskAspect (Variation) noexcept
 
constexpr QskAspect (const QskAspect &) noexcept=default
 
constexpr QskAspect (QskAspect &&) noexcept=default
 
QskAspectoperator= (const QskAspect &) noexcept=default
 
bool operator== (const QskAspect &) const noexcept
 
bool operator!= (const QskAspect &) const noexcept
 
bool operator< (const QskAspect &) const noexcept
 
constexpr QskAspect operator| (Subcontrol) const noexcept
 
constexpr QskAspect operator| (Section) const noexcept
 
constexpr QskAspect operator| (Type) const noexcept
 
constexpr QskAspect operator| (Primitive) const noexcept
 
constexpr QskAspect operator| (Variation) const noexcept
 
constexpr QskAspect operator| (State) const noexcept
 
QskAspectoperator|= (State) noexcept
 
constexpr QskAspect operator& (State) const noexcept
 
QskAspectoperator&= (State) noexcept
 
constexpr QskAspect operator| (States) const noexcept
 
QskAspectoperator|= (States) noexcept
 
constexpr QskAspect operator& (States) const noexcept
 
QskAspectoperator&= (States) noexcept
 
constexpr QskAspect stateless () const noexcept
 
constexpr QskAspect trunk () const noexcept
 
constexpr quint64 value () const noexcept
 
constexpr bool isAnimator () const noexcept
 
void setAnimator (bool on) noexcept
 
constexpr Subcontrol subControl () const noexcept
 
void setSubcontrol (Subcontrol) noexcept
 
constexpr bool hasSubcontrol () const noexcept
 
void clearSubcontrol () noexcept
 
constexpr Section section () const noexcept
 
void setSection (Section) noexcept
 
constexpr Type type () const noexcept
 
void setType (Type) noexcept
 
constexpr bool isMetric () const noexcept
 
constexpr bool isColor () const noexcept
 
constexpr Variation variation () const noexcept
 
void setVariation (Variation) noexcept
 
constexpr States states () const noexcept
 
constexpr bool hasStates () const noexcept
 
State topState () const noexcept
 
void clearState (State) noexcept
 
void setStates (States) noexcept
 
void addStates (States) noexcept
 
void clearStates (States=AllStates) noexcept
 
constexpr Primitive primitive () const noexcept
 
void setPrimitive (Type, Primitive primitive) noexcept
 
void clearPrimitive () noexcept
 
constexpr Primitive colorPrimitive () const noexcept
 
constexpr Primitive metricPrimitive () const noexcept
 
const char * toPrintable () const
 

Static Public Member Functions

static State registerState (const QMetaObject *, State, const char *)
 
static Subcontrol nextSubcontrol (const QMetaObject *, const char *)
 
static QByteArray subControlName (Subcontrol)
 
static QVector< QByteArray > subControlNames (const QMetaObject *=nullptr)
 
static QVector< SubcontrolsubControls (const QMetaObject *)
 
static quint8 primitiveCount ()
 
static void reservePrimitives (quint8 count)
 

Member Enumeration Documentation

◆ Primitive

enum QskAspect::Primitive : quint8

Represents a specific element or attribute.

This enum defines an initial list of primitive elements. A primitive is a common element, such as a border, font role etc.

The number of primitives can be extended by additional application specific elements by using reservePrimitives()

See also
setPrimitive(), clearPrimitive(), primitive(), reservePrimitives(), primitiveCount()
Enumerator
NoPrimitive 

No specific primitive

Alignment 

Usually used in combination with QskAspect::Flag

See also
QskSkinnable::alignmentHint(), QskSkinHintTableEditor::alignment()
Style 

Usually used in combination with QskAspect::Flag

GraphicRole 
A graphic role is an id that can be used to retrieve a specific
color filter for a graphic.
See also
QskSkinnable::graphicRoleHint(), QskSkinHintTableEditor::graphicRole(), QskSkin::graphicFilter(), QskSkinnable::effectiveGraphicFilter()
FontRole 
A font role is an id that can be used to retrieve a specific
font from the font table.
See also
QskSkinnable::fontRoleHint(), QskSkinHintTableEditor::fontRole() QskSkin::font(), QskSkinnable::effectiveFont()
TextColor 

A color for regular text

See also
QskTextColors(), QskAspect::StyleColor, QskAspect::LinkColor
StyleColor 

This color is used as the outline color for outlined text, and as the shadow color for raised or sunken text.

See also
QskAspect::TextColor, QskAspect::LinkColor
LinkColor 

The color of links in texts.

See also
QskAspect::TextColor, QskAspect::StyleColor
StrutSize 

A sensible metric - usually a QSizeF.

This size is usually used for layout calculations. It might be interpreted as a minimum, maximum or fixed size.

See also
QskSkinnable::strutSizeHint(), QskSkinHintTableEditor::strutSize()
Size 

A placeholder for defining a metric.

Position 
A metric that is often used for animating controls ( slide in/out )
or handles.
Margin 
Margins like being described in the CSS Box Model.
See also
QskSkinnable::marginHint(), QskSkinHintTableEditor::margin()
Padding 
Margins like being described in the CSS Box Model.
See also
QskSkinnable::paddingHint(), QskSkinHintTableEditor::padding()
Spacing 
A metric, that is used by layout code for the distance between
elements.
See also
QskSkinnable::spacingHint(), QskSkinHintTableEditor::spacing()
Shadow 
A primitive to define colors and metrics for shadows.
See also
QskShadowMetrics()
A primitive to define the shape of an element.
Shape 
See also
QskBoxShapeMetrics, QskSkinnable::boxShapeHint(), QskSkinHintTableEditor::boxShape()
Border 
A primitive to define colors and metrics for borders.
See also
QskSkinnable::boxBorderMetricsHint(), QskSkinnable::boxBorderColorsHint() QskSkinHintTableEditor::boxBorderMetrics(), QskSkinHintTableEditor::boxBorderColors()

Definition at line 47 of file QskAspect.h.

◆ Section

enum QskAspect::Section : quint8

Definition at line 31 of file QskAspect.h.

◆ State

enum QskAspect::State : quint16

Applies to a given aspect when the control is in a given state. QskSkinnable subclasses (typically QskControl subclasses) can define UI states, as denoted by any OR combination of State flags. For example, a checked QskPushButton has the QskPushButton::Checked state flag set when it is checked.

The skin hint resolving algorithms is removing the state bits one by one until it finds a match, what gives lower bits a higher priority. This is a rather obscure and error prone approach and needs to be replaced by something more user friendly. But until this has been done the state bits are divided into 3 sections:

- [ QskAspect::FirstSystemState, QskAspect::FirstUserState [
    High priority state bits
- [ QskAspect::FirstUserState, QskAspect::LastUserState ]
    State bits reserved for application code
- ] QskAspect::LastUserState, QskAspect::LastSystemState ]
    Low priority state bits
Enumerator
NoState 

No specific state

FirstSystemState 

First bit of the high priority bits section

FirstUserState 

First bit of the bits being reserved for application code

LastUserState 

Last bit of the bits being reserved for application code

LastSystemState 

Highest state bit

AllStates 

A bit mask for setting all state bits

Definition at line 111 of file QskAspect.h.

◆ Subcontrol

enum QskAspect::Subcontrol : quint16

For use within the rendering or lay-outing of a specific QskSkinnable.

While the Default value applies to any control (and can be used as a fallback), specifying a Subcontrol limits the aspect's scope to that sub-component (or subcontrol) of the control. For example, the Subcontrol type QskPushButton::Panel refers to the background panel of a push button.

Beside the default values below subcontrols are defined and registered using the QSK_SUBCONTROL and QSK_SUBCONTROLS macros.

Enumerator
LastSubcontrol 

Highest number that fits into the reserved bits for the subcontrol

Definition at line 103 of file QskAspect.h.

◆ Type

enum QskAspect::Type : quint8

Represents the type of the Aspect.

The type categorizes the aspect to be a metric, color or "something else".

Often primitives are related to a specific category. F.e QskAspect::Alignment will probably always be a QskAspect::Flag, while QskAspect::Border will usually be combined with QskAspect::Color and QskAspect::Metric.

Smooth transitions can be set up depending on these categories. F.e when changing from daylight to darkness color schemem only values of QskAspect::Color aspects need to be considered. But when changing the Look&Feel of the application all type of aspects need to be considered.

Enumerator
Metric 

Metrics are related to geometries in most cases corresponding to pixel distances. Examples are margin/padding(s).

Color 

Colors are all sort of color values, like fill gradients, border colors.

Definition at line 20 of file QskAspect.h.

◆ Variation

enum QskAspect::Variation : quint8

Some sort of variation.

The variation bits can be used to have different definitions for a skinnable depending on its position, orientation or emphasis. F.e a tab bar looks slightly different depending on its position.

Note
flags indicating an orientation can't be used together with the flags for the position
See also
QskSkinnable::effectiveVariation()
Enumerator
NoVariation 

No specific variation bits

Vertical 

Indicates a vertical orientation

Horizontal 

Indicates a horizontal orientation

Top 

Indicates a top position

Left 

Indicates a left position

Right 

Indicates a right position

Bottom 

Indicates a bottom position

Definition at line 81 of file QskAspect.h.

Constructor & Destructor Documentation

◆ QskAspect() [1/7]

constexpr QskAspect::QskAspect ( )
inlineconstexprnoexcept

Constructs an aspect with no bits being set.

Definition at line 260 of file QskAspect.h.

◆ QskAspect() [2/7]

constexpr QskAspect::QskAspect ( Subcontrol  subControl)
inlineconstexprnoexcept

Constructs an aspect with the subcontrol bits being initialized

Parameters
subControlInitial subcontrol

Definition at line 265 of file QskAspect.h.

◆ QskAspect() [3/7]

constexpr QskAspect::QskAspect ( Section  section)
inlineconstexprnoexcept

Definition at line 270 of file QskAspect.h.

◆ QskAspect() [4/7]

constexpr QskAspect::QskAspect ( Type  type)
inlineconstexprnoexcept

Constructs an aspect with the type bits being initialized

Parameters
typeInitial type

Definition at line 275 of file QskAspect.h.

◆ QskAspect() [5/7]

constexpr QskAspect::QskAspect ( Variation  variation)
inlineconstexprnoexcept

Constructs an aspect with the variation bits being initialized

Parameters
variationInitial variation

Definition at line 280 of file QskAspect.h.

◆ QskAspect() [6/7]

QskAspect::QskAspect ( const QskAspect )
constexprdefaultnoexcept

Copy constructor

◆ QskAspect() [7/7]

QskAspect::QskAspect ( QskAspect &&  )
constexprdefaultnoexcept

Move constructor

Member Function Documentation

◆ addStates()

void QskAspect::addStates ( States  states)
inlinenoexcept

ORs state to the state bits

See also
setState(), clearState(), hasState(), state()

Definition at line 477 of file QskAspect.h.

◆ clearPrimitive()

void QskAspect::clearPrimitive ( )
inlinenoexcept

Clears all primitive bits

See also
setPrimitive(), primitive()

Definition at line 520 of file QskAspect.h.

◆ clearState()

void QskAspect::clearState ( State  state)
inlinenoexcept

Clear the state bit for state

See also
setState(), addState(), hasState(), state()

Definition at line 487 of file QskAspect.h.

◆ clearStates()

void QskAspect::clearStates ( States  states = AllStates)
inlinenoexcept

Clears all state bits

See also
clearState() setState(), addState(), hasState(), state()

Definition at line 492 of file QskAspect.h.

◆ clearSubcontrol()

void QskAspect::clearSubcontrol ( )
inlinenoexcept

Definition at line 432 of file QskAspect.h.

◆ colorPrimitive()

constexpr QskAspect::Primitive QskAspect::colorPrimitive ( ) const
inlineconstexprnoexcept
Returns
primitive bits, when the aspect is a QskAspect::Color

Definition at line 508 of file QskAspect.h.

◆ hasStates()

constexpr bool QskAspect::hasStates ( ) const
inlineconstexprnoexcept
Returns
true, if any of the state bits is set

Definition at line 482 of file QskAspect.h.

◆ hasSubcontrol()

constexpr bool QskAspect::hasSubcontrol ( ) const
inlineconstexprnoexcept

Definition at line 427 of file QskAspect.h.

◆ isAnimator()

constexpr bool QskAspect::isAnimator ( ) const
inlineconstexprnoexcept
Returns
true, when the animator bit is set

Definition at line 407 of file QskAspect.h.

◆ isColor()

constexpr bool QskAspect::isColor ( ) const
inlineconstexprnoexcept
Returns
true, if type() equals to QskAspect::Color

Definition at line 462 of file QskAspect.h.

◆ isMetric()

constexpr bool QskAspect::isMetric ( ) const
inlineconstexprnoexcept
Returns
true, if type() equals to QskAspect::Metric

Definition at line 457 of file QskAspect.h.

◆ metricPrimitive()

constexpr QskAspect::Primitive QskAspect::metricPrimitive ( ) const
inlineconstexprnoexcept
Returns
metric bits, when the aspect is a QskAspect::Metric

Definition at line 514 of file QskAspect.h.

◆ nextSubcontrol()

QskAspect::Subcontrol QskAspect::nextSubcontrol ( const QMetaObject *  metaObject,
const char *  name 
)
static
Returns
Unique ( application wide ) identifier

This method is called from the QSK_SUBCONTROL macro and is usually never called manually in application code

Definition at line 91 of file QskAspect.cpp.

◆ operator!=()

bool QskAspect::operator!= ( const QskAspect other) const
inlinenoexcept

"Not equal to" operator

See also
operator==(), operator<()

Definition at line 302 of file QskAspect.h.

◆ operator&() [1/2]

constexpr QskAspect QskAspect::operator& ( State  state) const
inlineconstexprnoexcept

Definition at line 354 of file QskAspect.h.

◆ operator&() [2/2]

constexpr QskAspect QskAspect::operator& ( States  states) const
inlineconstexprnoexcept

Definition at line 378 of file QskAspect.h.

◆ operator&=() [1/2]

QskAspect & QskAspect::operator&= ( State  state)
inlinenoexcept

Definition at line 360 of file QskAspect.h.

◆ operator&=() [2/2]

QskAspect & QskAspect::operator&= ( States  states)
inlinenoexcept

Definition at line 384 of file QskAspect.h.

◆ operator<()

bool QskAspect::operator< ( const QskAspect other) const
inlinenoexcept

"Less than" operator

Definition at line 307 of file QskAspect.h.

◆ operator=()

QskAspect::operator= ( const QskAspect )
defaultnoexcept

Assignment operator

◆ operator==()

bool QskAspect::operator== ( const QskAspect other) const
inlinenoexcept

"Equal to" operator

See also
operator!=(), operator<()

Definition at line 297 of file QskAspect.h.

◆ operator|() [1/7]

constexpr QskAspect QskAspect::operator| ( Primitive  primitive) const
inlineconstexprnoexcept

Sets the primitive bits

Definition at line 330 of file QskAspect.h.

◆ operator|() [2/7]

constexpr QskAspect QskAspect::operator| ( Section  section) const
inlineconstexprnoexcept

Definition at line 318 of file QskAspect.h.

◆ operator|() [3/7]

constexpr QskAspect QskAspect::operator| ( State  state) const
inlineconstexprnoexcept

ORs state to the state bits

Parameters
stateAdditional state bit

Definition at line 342 of file QskAspect.h.

◆ operator|() [4/7]

constexpr QskAspect QskAspect::operator| ( States  states) const
inlineconstexprnoexcept

ORs states to the state bits

Parameters
statesAdditional state bits

Definition at line 366 of file QskAspect.h.

◆ operator|() [5/7]

constexpr QskAspect QskAspect::operator| ( Subcontrol  subControl) const
inlineconstexprnoexcept

Sets the subcontrol bits

Definition at line 312 of file QskAspect.h.

◆ operator|() [6/7]

constexpr QskAspect QskAspect::operator| ( Type  type) const
inlineconstexprnoexcept

Sets the type bits

Definition at line 324 of file QskAspect.h.

◆ operator|() [7/7]

constexpr QskAspect QskAspect::operator| ( Variation  variation) const
inlineconstexprnoexcept

Sets the variation bits

Definition at line 336 of file QskAspect.h.

◆ operator|=() [1/2]

QskAspect & QskAspect::operator|= ( State  state)
inlinenoexcept

Definition at line 348 of file QskAspect.h.

◆ operator|=() [2/2]

QskAspect & QskAspect::operator|= ( States  states)
inlinenoexcept

Definition at line 372 of file QskAspect.h.

◆ primitive()

constexpr QskAspect::Primitive QskAspect::primitive ( ) const
inlineconstexprnoexcept
Returns
Primitive bits
See also
setPrimitive(), clearPrimitive()

Definition at line 497 of file QskAspect.h.

◆ primitiveCount()

quint8 QskAspect::primitiveCount ( )
static

Definition at line 51 of file QskAspect.cpp.

◆ registerState()

QskAspect::State QskAspect::registerState ( const QMetaObject *  metaObject,
State  state,
const char *  name 
)
static

Registers a printable string for a state.

This method is called from the QSK_STATE and QSK_SYSTEM_STATE macros and is usually never called manually in application code

Definition at line 78 of file QskAspect.cpp.

◆ reservePrimitives()

void QskAspect::reservePrimitives ( quint8  count)
static

Definition at line 56 of file QskAspect.cpp.

◆ section()

constexpr QskAspect::Section QskAspect::section ( ) const
inlineconstexprnoexcept

Definition at line 437 of file QskAspect.h.

◆ setAnimator()

void QskAspect::setAnimator ( bool  on)
inlinenoexcept

Set/Clear the animator bit depending on on

Definition at line 412 of file QskAspect.h.

◆ setPrimitive()

void QskAspect::setPrimitive ( Type  type,
QskAspect::Primitive  primitive 
)
inlinenoexcept

Sets the primitive bits

See also
primitive(), clearPrimitive()

Definition at line 502 of file QskAspect.h.

◆ setSection()

void QskAspect::setSection ( Section  section)
inlinenoexcept

Definition at line 442 of file QskAspect.h.

◆ setStates()

void QskAspect::setStates ( States  states)
inlinenoexcept

Sets the state bits

See also
addState(), clearState(), hasState(), state()

Definition at line 472 of file QskAspect.h.

◆ setSubcontrol()

void QskAspect::setSubcontrol ( Subcontrol  subControl)
inlinenoexcept

Definition at line 422 of file QskAspect.h.

◆ setType()

void QskAspect::setType ( Type  type)
inlinenoexcept

Sets the type bits

See also
type()

Definition at line 452 of file QskAspect.h.

◆ setVariation()

void QskAspect::setVariation ( Variation  variation)
inlinenoexcept

Sets the variation bits

See also
variation()

Definition at line 530 of file QskAspect.h.

◆ stateless()

constexpr QskAspect QskAspect::stateless ( ) const
inlineconstexprnoexcept
Returns
A copy of the aspect without the state bits

Definition at line 390 of file QskAspect.h.

◆ states()

constexpr QskAspect::States QskAspect::states ( ) const
inlineconstexprnoexcept
Returns
State bits
See also
setState()

Definition at line 467 of file QskAspect.h.

◆ subControl()

constexpr QskAspect::Subcontrol QskAspect::subControl ( ) const
inlineconstexprnoexcept
Returns
Subcontrol bits
See also
setSubControl()

Definition at line 417 of file QskAspect.h.

◆ subControlName()

QByteArray QskAspect::subControlName ( Subcontrol  subControl)
static
Returns
Printable string for a specific subControl

Definition at line 111 of file QskAspect.cpp.

◆ subControlNames()

QVector< QByteArray > QskAspect::subControlNames ( const QMetaObject *  metaObject = nullptr)
static
Returns
Printable strings of all subControls for a class represented by metaObject

Definition at line 122 of file QskAspect.cpp.

◆ subControls()

QVector< QskAspect::Subcontrol > QskAspect::subControls ( const QMetaObject *  metaObject)
static
Returns
All subControls for a class represented by metaObject

Definition at line 140 of file QskAspect.cpp.

◆ toPrintable()

const char * QskAspect::toPrintable ( ) const
Returns
A printable string for debug purposes
Note
The string is internally stored in a buffer that gets reused every 10 calls. If the string is not only for an immediate debug statement it needs to be copied out.

Definition at line 330 of file QskAspect.cpp.

◆ topState()

QskAspect::State QskAspect::topState ( ) const
noexcept
Returns
Topmost state bit
See also
state()

Definition at line 347 of file QskAspect.cpp.

◆ trunk()

constexpr QskAspect QskAspect::trunk ( ) const
inlineconstexprnoexcept
Returns
A copy of the aspect without the runtime bits ( state, variation ) bits

Definition at line 396 of file QskAspect.h.

◆ type()

constexpr QskAspect::Type QskAspect::type ( ) const
inlineconstexprnoexcept
Returns
Type bits
See also
setType()

Definition at line 447 of file QskAspect.h.

◆ value()

constexpr quint64 QskAspect::value ( ) const
inlineconstexprnoexcept
Returns
All bits interpreted as quint64

Definition at line 402 of file QskAspect.h.

◆ variation()

constexpr QskAspect::Variation QskAspect::variation ( ) const
inlineconstexprnoexcept
Returns
Variation bits
See also
setVariation()

Definition at line 525 of file QskAspect.h.

Member Data Documentation

◆ FirstUserSection

constexpr uint QskAspect::FirstUserSection = Section::Floating + 1
staticconstexpr

Definition at line 44 of file QskAspect.h.

◆ LastSection

constexpr uint QskAspect::LastSection = ( 1 << 4 ) - 1
staticconstexpr

Definition at line 45 of file QskAspect.h.

◆ m_bits

Bits QskAspect::m_bits

Definition at line 240 of file QskAspect.h.

◆ m_value

quint64 QskAspect::m_value

Definition at line 241 of file QskAspect.h.

◆ typeCount

constexpr uint QskAspect::typeCount = 3
staticconstexpr

Definition at line 29 of file QskAspect.h.