QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskFontRole.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_FONT_ROLE_H
7#define QSK_FONT_ROLE_H
8
9#include "QskGlobal.h"
10#include <qmetatype.h>
11
12class QSK_EXPORT QskFontRole
13{
14 Q_GADGET
15
16 Q_PROPERTY( Category category READ category WRITE setCategory )
17 Q_PROPERTY( Emphasis emphasis READ emphasis WRITE setEmphasis )
18
19 public:
20 enum Category
21 {
22 Caption,
23 Body,
24 Subtitle,
25 Title,
26 Headline,
27 Display
28 };
29 Q_ENUM( Category );
30
31 enum Emphasis
32 {
33 VeryLow,
34 Low,
35
36 Normal,
37
38 High,
39 VeryHigh
40 };
41 Q_ENUM( Emphasis );
42
43 constexpr QskFontRole( Category = Body, Emphasis = Normal ) noexcept;
44
45 constexpr bool operator==( const QskFontRole& ) const noexcept;
46 constexpr bool operator!=( const QskFontRole& ) const noexcept;
47
48 void setCategory( Category ) noexcept;
49 constexpr Category category() const noexcept;
50
51 void setEmphasis( Emphasis ) noexcept;
52 constexpr Emphasis emphasis() const noexcept;
53
54 QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
55
56 private:
57 unsigned char m_category;
58 unsigned char m_emphasis;
59};
60
61inline constexpr QskFontRole::QskFontRole( Category category, Emphasis emphasis ) noexcept
62 : m_category( category )
63 , m_emphasis( emphasis )
64{
65}
66
67inline constexpr bool QskFontRole::operator==( const QskFontRole& other ) const noexcept
68{
69 return ( m_category == other.m_category ) && ( m_emphasis == other.m_emphasis );
70}
71
72inline constexpr bool QskFontRole::operator!=( const QskFontRole& other ) const noexcept
73{
74 return !( *this == other );
75}
76
77inline void QskFontRole::setCategory( Category category ) noexcept
78{
79 m_category = category;
80}
81
82inline constexpr QskFontRole::Category QskFontRole::category() const noexcept
83{
84 return static_cast< Category >( m_category );
85}
86
87inline void QskFontRole::setEmphasis( Emphasis emphasis ) noexcept
88{
89 m_emphasis = emphasis;
90}
91
92inline constexpr QskFontRole::Emphasis QskFontRole::emphasis() const noexcept
93{
94 return static_cast< Emphasis >( m_emphasis );
95}
96
97inline QskHashValue qHash( const QskFontRole fontRole, QskHashValue seed = 0 ) noexcept
98{
99 return fontRole.hash( seed );
100}
101
102namespace std
103{
104 template< > struct hash< QskFontRole >
105 {
106 size_t operator()( const QskFontRole& fontRole ) const noexcept
107 {
108 return fontRole.hash();
109 }
110 };
111}
112
113#ifndef QT_NO_DEBUG_STREAM
114
115QSK_EXPORT QDebug operator<<( QDebug, const QskFontRole& );
116
117#endif
118
119Q_DECLARE_TYPEINFO( QskFontRole, Q_MOVABLE_TYPE );
120Q_DECLARE_METATYPE( QskFontRole )
121
122#endif