blob: ce7c30d66d15c7b9b94c3fc651e6f7687775fc7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPALETTE_P_H
#define QPALETTE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qpalette.h"
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPalettePrivate
{
public:
class Data : public QSharedData {
public:
// Every instance of Data has to have a unique serial number, even
// if it gets created by copying another - we wouldn't create a copy
// in the first place if the serial number should be the same!
Data(const Data &other)
: QSharedData(other)
{
for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) {
for (int role = 0; role < int(QPalette::NColorRoles); role++)
br[grp][role] = other.br[grp][role];
}
}
Data() = default;
QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
const int ser_no = qt_palette_count++;
};
QPalettePrivate(const QExplicitlySharedDataPointer<Data> &data)
: ref(1), data(data)
{ }
QPalettePrivate()
: QPalettePrivate(QExplicitlySharedDataPointer<Data>(new Data))
{ }
static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
{
// Exclude NoRole; that bit is used for Accent
return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
}
static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup,
QPalette::ColorRole colorRole)
{
// Map Accent into NoRole for resolving purposes
if (colorRole == QPalette::Accent)
colorRole = QPalette::NoRole;
return colorRole + colorRoleOffset(colorGroup);
}
QAtomicInt ref;
QPalette::ResolveMask resolveMask = {0};
static inline int qt_palette_count = 0;
static inline int qt_palette_private_count = 0;
int detach_no = ++qt_palette_private_count;
QExplicitlySharedDataPointer<Data> data;
};
QT_END_NAMESPACE
#endif // QPALETTE_P_H
|