QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskStateCombination.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_STATE_COMBINATION_H
7#define QSK_STATE_COMBINATION_H
8
9#include "QskAspect.h"
10
11class QSK_EXPORT QskStateCombination
12{
13 public:
14 enum Type
15 {
16 Combination,
17 CombinationNoState
18 };
19
20 constexpr QskStateCombination( QskAspect::State ) noexcept;
21 constexpr QskStateCombination( QskAspect::States = QskAspect::States() ) noexcept;
22 constexpr QskStateCombination( Type, QskAspect::States = QskAspect::States() ) noexcept;
23
24 constexpr bool operator==( QskStateCombination ) const noexcept;
25 constexpr bool operator!=( QskStateCombination ) const noexcept;
26
27 constexpr bool isNull() const noexcept;
28
29 void setType( Type ) noexcept;
30 constexpr Type type() const noexcept;
31
32 void setStates( QskAspect::States ) noexcept;
33 void setState( QskAspect::State, bool on = true ) noexcept;
34 constexpr QskAspect::States states() const noexcept;
35
36 private:
37 Type m_type;
38 QskAspect::States m_states;
39};
40
41Q_DECLARE_TYPEINFO( QskStateCombination, Q_MOVABLE_TYPE );
42
43constexpr inline QskStateCombination::QskStateCombination(
44 QskAspect::State state ) noexcept
45 : QskStateCombination( QskAspect::States( state ) )
46{
47}
48
49constexpr inline QskStateCombination::QskStateCombination(
50 QskAspect::States states ) noexcept
51 : QskStateCombination( Combination, states )
52{
53}
54
55constexpr inline QskStateCombination::QskStateCombination(
56 Type type, QskAspect::States states ) noexcept
57 : m_type( type )
58 , m_states( states )
59{
60}
61
62constexpr bool QskStateCombination::isNull() const noexcept
63{
64 return ( m_type == Combination ) && ( m_states == QskAspect::States() );
65}
66
67inline void QskStateCombination::setType( Type type ) noexcept
68{
69 m_type = type;
70}
71
72constexpr inline QskStateCombination::Type QskStateCombination::type() const noexcept
73{
74 return m_type;
75}
76
77inline void QskStateCombination::setStates( QskAspect::States states ) noexcept
78{
79 m_states = states;
80}
81
82inline void QskStateCombination::setState( QskAspect::State state, bool on ) noexcept
83{
84 if ( on )
85 m_states |= state;
86 else
87 m_states &= ~state;
88}
89
90constexpr inline QskAspect::States QskStateCombination::states() const noexcept
91{
92 return m_states;
93}
94
95constexpr bool QskStateCombination::operator==( QskStateCombination other ) const noexcept
96{
97 return ( m_type == other.m_type ) && ( m_states == other.m_states );
98}
99
100constexpr bool QskStateCombination::operator!=( QskStateCombination other ) const noexcept
101{
102 return !( *this == other );
103}
104
105#endif