QskAspect

Lookup key for a QskSkinHintTable. More…

#include <QskAspect.h>

Public Types

  Name
enum quint8 Type { Flag = 0, Metric = 1, Color = 2}
Represents the type of the Aspect.
enum quint8 Primitive { NoPrimitive = 0, Alignment, Style, GraphicRole, FontRole, TextColor, StyleColor, LinkColor, StrutSize, Size, Position, Margin, Padding, Spacing, Shadow, Shape, Border}
Represents a specific element or attribute.
enum quint8 Placement { NoPlacement = 0, Vertical = Qt::Vertical, Horizontal = Qt::Horizontal, Top = 1, Left = 2, Right = 3, Bottom = 4}
Represents an orientation or relative position.
enum quint16 Subcontrol { Control = 0, LastSubcontrol = ( 1 « 12 ) - 1}
For use within the rendering or lay-outing of a specific QskSkinnable.
enum quint16 State { NoState = 0, FirstSystemState = 1 « 0, FirstUserState = 1 « 4, LastUserState = 1 « 11, LastSystemState = 1 « 15, AllStates = 0xFFFF}

Public Functions

  Name    
constexpr QskAspect()    
constexpr QskAspect(Subcontrol subControl)    
constexpr QskAspect(Type type)    
constexpr QskAspect(Placement placement)    
constexpr QskAspect(const QskAspect & ) =default    
constexpr QskAspect(QskAspect && ) =default    
QskAspect & operator=(const QskAspect & ) =default    
bool operator==(const QskAspect & other) const    
bool operator!=(const QskAspect & other) const    
bool operator<(const QskAspect & other) const    
constexpr QskAspect **[operator ](/docs/classes/classQskAspect/#function-operator )**(Subcontrol subControl) const
constexpr QskAspect **[operator ](/docs/classes/classQskAspect/#function-operator )**(Type type) const
constexpr QskAspect **[operator ](/docs/classes/classQskAspect/#function-operator )**(Primitive primitive) const
constexpr QskAspect **[operator ](/docs/classes/classQskAspect/#function-operator )**(Placement placement) const
constexpr QskAspect **[operator ](/docs/classes/classQskAspect/#function-operator )**(State state) const
constexpr QskAspect **[operator ](/docs/classes/classQskAspect/#function-operator )**(States states) const
constexpr QskAspect stateless() const    
constexpr QskAspect trunk() const    
constexpr quint64 value() const    
constexpr bool isAnimator() const    
void setAnimator(bool on)    
constexpr Subcontrol subControl() const    
void setSubControl(Subcontrol subControl)    
constexpr Type type() const    
void setType(Type type)    
constexpr bool isMetric() const    
constexpr bool isColor() const    
constexpr bool isFlag() const    
constexpr Placement placement() const    
void setPlacement(Placement placement)    
constexpr States states() const    
constexpr bool hasStates() const    
State topState() const    
void clearState(State state)    
void setStates(States states)    
void addStates(States states)    
void clearStates(States states =AllStates)    
constexpr Primitive primitive() const    
void setPrimitive(Type type, Primitive primitive)    
void clearPrimitive()    
constexpr Primitive flagPrimitive() const    
constexpr Primitive colorPrimitive() const    
constexpr Primitive metricPrimitive() const    
const char * toPrintable() const    
State registerState(const QMetaObject * metaObject, State state, const char * name)    
Subcontrol nextSubcontrol(const QMetaObject * metaObject, const char * name)    
QByteArray subControlName(Subcontrol subControl)    
QVector< QByteArray > subControlNames(const QMetaObject * metaObject =nullptr)    
QVector< Subcontrol > subControls(const QMetaObject * metaObject)    
quint8 primitiveCount()    
void reservePrimitives(quint8 count)    

Public Attributes

  Name
constexpr uint typeCount
Bits m_bits
quint64 m_value

Detailed Description

class QskAspect;

Lookup key for a QskSkinHintTable.

See: QskSkinnable::effectiveSkinHint(), QskSkinHintTable

QskAspect is used by the themeing system to determine how a given aspect of a control is drawn. 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

Public Types Documentation

enum Type

Enumerator Value Description
Flag 0 Flags are all sort of attributes that are no metrics or colors - f.e an alignment.
Metric 1 Metrics are related to geometries in most cases corresponding to pixel distances. Examples are margin/padding(s).
Color 2 Colors are all sort of color values, like fill gradients, border colors.

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.

enum Primitive

Enumerator Value Description
NoPrimitive 0 No specific primitive
Alignment   Usually used in combination with QskAspect::Flag
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.
``` |
| FontRole | |  

A font role is an id that can be used to retrieve a specific font from the font table.

| TextColor | |  A color for regular text |
| StyleColor | |  This color is used as the outline color for outlined text, and as the shadow color for raised or sunken text. |
| LinkColor | |  The color of links in texts. |
| 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. |
| 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.

| Padding | |  

Margins like being described in the CSS Box Model.

| Spacing | |  

A metric, that is used by layout code for the distance between elements.

| Shadow | |  

A primitive to define colors and metrics for shadows.

| Shape | |   |
| Border | |  

A primitive to define colors and metrics for borders.




Represents a specific element or attribute. 

**See**: [setPrimitive()](/docs/classes/classQskAspect/#function-setprimitive), [clearPrimitive()](/docs/classes/classQskAspect/#function-clearprimitive), [primitive()](/docs/classes/classQskAspect/#function-primitive), reservePrimitives(), primitiveCount() 

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()


### enum Placement

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| NoPlacement | 0|  No specific placement bits  |
| Vertical | Qt::Vertical|  Indicates a vertical orientation  |
| Horizontal | Qt::Horizontal|  Indicates a horizontal orientation  |
| Top | 1|  Indicates a top position  |
| Left | 2|  Indicates a left position  |
| Right | 3|  Indicates a right position  |
| Bottom | 4|  Indicates a bottom position  |



Represents an orientation or relative position. 

**See**: [QskSkinnable::effectivePlacement()](/docs/classes/classQskSkinnable/#function-effectiveplacement)

**Note**: flags indicating an orientation can't be used together with the flags for the position

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


### enum Subcontrol

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| Control | 0|  No specific subcontrol - used as fallback when resolving skin hints  |
| LastSubcontrol | ( 1 << 12 ) - 1|  Highest number that fits into the reserved bits for the subcontrol  |



For use within the rendering or lay-outing of a specific [QskSkinnable](/docs/classes/classQskSkinnable/). 

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. 


### enum State

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| NoState | 0|  No specific state  |
| FirstSystemState | 1 << 0|  First bit of the high priority bits section  |
| FirstUserState | 1 << 4|  First bit of the bits being reserved for application code  |
| LastUserState | 1 << 11|  Last bit of the bits being reserved for application code  |
| LastSystemState | 1 << 15|  Highest state bit  |
| AllStates |   0xFFFF|  A bit mask for setting all state bits  |




Applies to a given aspect when the control is in a given state. [QskSkinnable](/docs/classes/classQskSkinnable/) subclasses (typically [QskControl](/docs/classes/classQskControl/) 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: 

Public Functions Documentation

function QskAspect

inline constexpr QskAspect()

Constructs an aspect with no bits being set.

function QskAspect

inline constexpr QskAspect(
    Subcontrol subControl
)

Parameters:

Constructs an aspect with the subcontrol bits being initialized

function QskAspect

inline constexpr QskAspect(
    Type type
)

Parameters:

Constructs an aspect with the type bits being initialized

function QskAspect

inline constexpr QskAspect(
    Placement placement
)

Parameters:

Constructs an aspect with the placement bits being initialized

function QskAspect

constexpr QskAspect(
    const QskAspect & 
) =default

Copy constructor

function QskAspect

constexpr QskAspect(
    QskAspect && 
) =default

Move constructor

function operator=

QskAspect & operator=(
    const QskAspect & 
) =default

Assignment operator

function operator==

inline bool operator==(
    const QskAspect & other
) const

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

“Equal to” operator

function operator!=

inline bool operator!=(
    const QskAspect & other
) const

See: operator==(), operator<()

“Not equal to” operator

function operator<

inline bool operator<(
    const QskAspect & other
) const

“Less than” operator

function operator|

inline constexpr QskAspect operator|(
    Subcontrol subControl
) const

Sets the subcontrol bits

function operator|

inline constexpr QskAspect operator|(
    Type type
) const

Sets the type bits

function operator|

inline constexpr QskAspect operator|(
    Primitive primitive
) const

Sets the primitive bits

function operator|

inline constexpr QskAspect operator|(
    Placement placement
) const

Sets the placement bits

function operator|

inline constexpr QskAspect operator|(
    State state
) const

Parameters:

ORs state to the state bits

function operator|

inline constexpr QskAspect operator|(
    States states
) const

function stateless

inline constexpr QskAspect stateless() const

Return: A copy of the aspect without the state bits

function trunk

inline constexpr QskAspect trunk() const

Return: A copy of the aspect without the runtime bits ( state, placement ) bits

function value

inline constexpr quint64 value() const

Return: All bits interpreted as quint64

function isAnimator

inline constexpr bool isAnimator() const

Return: true, when the animator bit is set

function setAnimator

inline void setAnimator(
    bool on
)

Set/Clear the animator bit depending on on

function subControl

inline constexpr Subcontrol subControl() const

See: setSubControl()

Return: Subcontrol bits

function setSubControl

inline void setSubControl(
    Subcontrol subControl
)

See: subControl()

Sets the subcontrol bits

function type

inline constexpr Type type() const

See: setType()

Return: Type bits

function setType

inline void setType(
    Type type
)

See: type()

Sets the type bits

function isMetric

inline constexpr bool isMetric() const

Return: true, if type() equals to QskAspect::Metric

function isColor

inline constexpr bool isColor() const

Return: true, if type() equals to QskAspect::Color

function isFlag

inline constexpr bool isFlag() const

Return: true, if type() equals to QskAspect::Flag

function placement

inline constexpr Placement placement() const

See: setPlacement()

Return: Placement bits

function setPlacement

inline void setPlacement(
    Placement placement
)

See: placement()

Sets the placement bits

function states

inline constexpr States states() const

function hasStates

inline constexpr bool hasStates() const

function topState

State topState() const

See: state()

Return: Topmost state bit

function clearState

inline void clearState(
    State state
)

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

Clear the state bit for state

function setStates

inline void setStates(
    States states
)

function addStates

inline void addStates(
    States states
)

function clearStates

inline void clearStates(
    States states =AllStates
)

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

Clears all state bits

function primitive

inline constexpr Primitive primitive() const

See: setPrimitive(), clearPrimitive()

Return: Primitive bits

function setPrimitive

inline void setPrimitive(
    Type type,
    Primitive primitive
)

See: primitive(), clearPrimitive()

Sets the primitive bits

function clearPrimitive

inline void clearPrimitive()

See: setPrimitive(), primitive()

Clears all primitive bits

function flagPrimitive

inline constexpr Primitive flagPrimitive() const

function colorPrimitive

inline constexpr Primitive colorPrimitive() const

function metricPrimitive

inline constexpr Primitive metricPrimitive() const

function toPrintable

const char * toPrintable() const

Return: 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.

function registerState

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

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

function nextSubcontrol

static Subcontrol nextSubcontrol(
    const QMetaObject * metaObject,
    const char * name
)

Return: Unique ( application wide ) identifier

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

function subControlName

static QByteArray subControlName(
    Subcontrol subControl
)

Return: Printable string for a specific subControl

function subControlNames

static QVector< QByteArray > subControlNames(
    const QMetaObject * metaObject =nullptr
)

Return: Printable strings of all subControls for a class represented by metaObject

function subControls

static QVector< Subcontrol > subControls(
    const QMetaObject * metaObject
)

Return: All subControls for a class represented by metaObject

function primitiveCount

static quint8 primitiveCount()

function reservePrimitives

static void reservePrimitives(
    quint8 count
)

Public Attributes Documentation

variable typeCount

static constexpr uint typeCount = 3;

variable m_bits

Bits m_bits;

variable m_value

quint64 m_value;

Updated on 28 July 2023 at 14:02:29 CEST