Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_node_view_color_scheme.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QTreeView>
10#include <QStyle>
11
12#include <kis_painting_tweaks.h>
13#include <QApplication>
14
15#include <QGlobalStatic>
16#include <kis_config.h>
18
20{
22 if (colorLabels.isEmpty()) {
23 colorLabels << Qt::transparent;
24 colorLabels << QColor(91,173,220);
25 colorLabels << QColor(151,202,63);
26 colorLabels << QColor(247,229,61);
27 colorLabels << QColor(255,170,63);
28 colorLabels << QColor(177,102,63);
29 colorLabels << QColor(238,50,51);
30 colorLabels << QColor(191,106,209);
31 colorLabels << QColor(118,119,114);
32
33 const QColor noLabelSetColor = qApp->palette().color(QPalette::Highlight);
34 for (auto it = colorLabels.begin(); it != colorLabels.end(); ++it) {
35 KisPaintingTweaks::dragColor(&(*it), noLabelSetColor, 0.35);
36 }
37 }
38 }
39
41};
42
44
45
50
54
59
60QColor KisNodeViewColorScheme::gridColor(const QStyleOptionViewItem &option, QTreeView *view) const
61{
62 const int gridHint = view->style()->styleHint(QStyle::SH_Table_GridLineColor, &option, view);
63 const QColor gridColor = static_cast<QRgb>(gridHint);
64 return gridColor;
65}
66
68{
69 return 16;
70}
71
73{
74 return 2;
75}
76
77
79{
80 KisConfig cfg(true);
81 return cfg.layerThumbnailSize(false);
82}
83
85{
86 return 3;
87}
88
90{
91 return 12;
92}
93
95{
96 return 1;
97}
98
99
101{
102 return 2;
103}
104
105
107{
108 return 16;
109}
110
112{
113 return 1;
114}
115
117{
118 return 1;
119}
120
122{
123 return border() + 2 * thumbnailMargin() + thumbnailSize();
124}
125
127{
128 return border() +
130 border();
131}
132
134{
135 KisConfig cfg(true);
136 int percentage = cfg.layerTreeIndentation();
137 int absoluteMax = 2 * thumbnailMargin() + thumbnailSize() + border();
138
139 return qMax(8, percentage*absoluteMax/100);
140}
141
146
148{
149 return QRect(0, 0,
150 visibilitySize() + 2 * visibilityMargin() + 2 * border(),
151 visibilitySize() + 2 * visibilityMargin() + 1 * border());
152}
153
155{
156 return QRect(0, 0,
157 thumbnailSize() + 2 * thumbnailMargin() + 2 * border(),
158 thumbnailSize() + 2 * thumbnailMargin() + 1 * border());
159}
160
162{
163 return QRect(0, 0,
164 decorationSize() + 2 * decorationMargin() + 2 * border(),
165 decorationSize() + 2 * decorationMargin() + 1 * border());
166}
167
169{
170 const int newY = rowHeight() - decorationMargin() - decorationSize();
171 QRect rc = relDecorationRect();
172 rc.moveTop(newY);
173 return rc;
174}
175
177{
182 if (index >= m_d->colorLabels.size()) {
183 index = 1 + index % (m_d->colorLabels.size() - 1);
184 } else {
185 index = index % m_d->colorLabels.size();
186 }
187
188 return m_d->colorLabels[index];
189}
190
192{
193 return m_d->colorLabels;
194}
Q_GLOBAL_STATIC(KisStoragePluginRegistry, s_instance)
int layerThumbnailSize(bool defaultValue=false) const
int layerTreeIndentation(bool defaultValue=false) const
QColor colorFromLabelIndex(int index) const
QColor gridColor(const QStyleOptionViewItem &option, QTreeView *view) const
static KisNodeViewColorScheme * instance()
const QScopedPointer< Private > m_d
QVector< QColor > allColorLabels() const
unsigned int QRgb
void dragColor(QColor *color, const QColor &baseColor, qreal threshold)