Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/artisticcolorselector/kis_color_selector.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 41 | KisColorSelector::KisColorSelector(QWidget* parent, KisColor::Type type) | |||
---|---|---|---|---|---|
46 | , m_selectedColor(m_colorConverter) | 46 | , m_selectedColor(m_colorConverter) | ||
47 | , m_fgColor(m_colorConverter) | 47 | , m_fgColor(m_colorConverter) | ||
48 | , m_bgColor(m_colorConverter) | 48 | , m_bgColor(m_colorConverter) | ||
49 | , m_clickedRing(-1) | 49 | , m_clickedRing(-1) | ||
50 | , m_gamutMaskOn(false) | 50 | , m_gamutMaskOn(false) | ||
51 | , m_currentGamutMask(nullptr) | 51 | , m_currentGamutMask(nullptr) | ||
52 | , m_maskPreviewActive(true) | 52 | , m_maskPreviewActive(true) | ||
53 | , m_widgetUpdatesSelf(false) | 53 | , m_widgetUpdatesSelf(false) | ||
54 | , m_isDirtyWheel(false) | ||||
55 | , m_isDirtyLightStrip(false) | ||||
56 | , m_isDirtyGamutMask(false) | ||||
57 | , m_isDirtyColorPreview(false) | ||||
54 | { | 58 | { | ||
55 | m_viewConverter = new KisGamutMaskViewConverter(); | 59 | m_viewConverter = new KisGamutMaskViewConverter(); | ||
56 | 60 | | |||
57 | setLumaCoefficients(DEFAULT_LUMA_R, DEFAULT_LUMA_G, DEFAULT_LUMA_B,DEFAULT_LUMA_GAMMA); | 61 | setLumaCoefficients(DEFAULT_LUMA_R, DEFAULT_LUMA_G, DEFAULT_LUMA_B,DEFAULT_LUMA_GAMMA); | ||
58 | 62 | | |||
59 | recalculateRings(DEFAULT_SATURATION_STEPS, DEFAULT_HUE_STEPS); | 63 | recalculateRings(DEFAULT_SATURATION_STEPS, DEFAULT_HUE_STEPS); | ||
60 | recalculateAreas(DEFAULT_VALUE_SCALE_STEPS); | 64 | recalculateAreas(DEFAULT_VALUE_SCALE_STEPS); | ||
61 | selectColor(KisColor(Qt::red, m_colorConverter, KisColor::HSY, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma)); | 65 | selectColor(KisColor(Qt::red, m_colorConverter, KisColor::HSY, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma)); | ||
62 | 66 | | |||
63 | using namespace std::placeholders; // For _1 placeholder | 67 | using namespace std::placeholders; // For _1 placeholder | ||
64 | auto function = std::bind(&KisColorSelector::slotUpdateColorAndPreview, this, _1); | 68 | auto function = std::bind(&KisColorSelector::slotUpdateColorAndPreview, this, _1); | ||
65 | m_updateColorCompressor.reset(new ColorCompressorType(20 /* ms */, function)); | 69 | m_updateColorCompressor.reset(new ColorCompressorType(20 /* ms */, function)); | ||
66 | } | 70 | } | ||
67 | 71 | | |||
68 | void KisColorSelector::setColorSpace(KisColor::Type type) | 72 | void KisColorSelector::setColorSpace(KisColor::Type type) | ||
69 | { | 73 | { | ||
70 | m_colorSpace = type; | 74 | m_colorSpace = type; | ||
71 | m_selectedColor = KisColor(m_selectedColor, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 75 | m_selectedColor = KisColor(m_selectedColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
76 | | ||||
77 | m_isDirtyLightStrip = true; | ||||
78 | m_isDirtyWheel = true; | ||||
72 | 79 | | |||
73 | #ifdef DEBUG_ARC_SELECTOR | 80 | #ifdef DEBUG_ARC_SELECTOR | ||
74 | dbgPlugins << "KisColorSelector::setColorSpace: set to:" << m_colorSpace; | 81 | dbgPlugins << "KisColorSelector::setColorSpace: set to:" << m_colorSpace; | ||
75 | #endif | 82 | #endif | ||
76 | 83 | | |||
77 | update(); | 84 | update(); | ||
78 | } | 85 | } | ||
79 | 86 | | |||
80 | void KisColorSelector::setColorConverter(KisDisplayColorConverter *colorConverter) | 87 | void KisColorSelector::setColorConverter(KisDisplayColorConverter *colorConverter) | ||
81 | { | 88 | { | ||
82 | m_colorConverter = colorConverter; | 89 | m_colorConverter = colorConverter; | ||
90 | | ||||
91 | m_selectedColor = KisColor(m_selectedColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||||
92 | m_fgColor = KisColor(m_fgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||||
93 | m_bgColor = KisColor(m_bgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||||
94 | | ||||
83 | update(); | 95 | update(); | ||
84 | } | 96 | } | ||
85 | 97 | | |||
86 | void KisColorSelector::setNumLightPieces(int num) | 98 | void KisColorSelector::setNumLightPieces(int num) | ||
87 | { | 99 | { | ||
88 | num = qBound(MIN_NUM_LIGHT_PIECES, num, MAX_NUM_LIGHT_PIECES); | 100 | num = qBound(MIN_NUM_LIGHT_PIECES, num, MAX_NUM_LIGHT_PIECES); | ||
89 | 101 | | |||
90 | recalculateAreas(quint8(num)); | 102 | recalculateAreas(quint8(num)); | ||
Show All 25 Lines | 123 | { | |||
116 | if (m_selectedRing >= 0) | 128 | if (m_selectedRing >= 0) | ||
117 | m_selectedRing = getSaturationIndex(m_selectedColor.getS()); | 129 | m_selectedRing = getSaturationIndex(m_selectedColor.getS()); | ||
118 | 130 | | |||
119 | update(); | 131 | update(); | ||
120 | } | 132 | } | ||
121 | 133 | | |||
122 | void KisColorSelector::selectColor(const KisColor& color) | 134 | void KisColorSelector::selectColor(const KisColor& color) | ||
123 | { | 135 | { | ||
124 | m_selectedColor = KisColor(color, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 136 | m_selectedColor = KisColor(color, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
125 | m_selectedPiece = getHueIndex(m_selectedColor.getH() * PI2); | 137 | m_selectedPiece = getHueIndex(m_selectedColor.getH() * PI2); | ||
126 | m_selectedRing = getSaturationIndex(m_selectedColor.getS()); | 138 | m_selectedRing = getSaturationIndex(m_selectedColor.getS()); | ||
127 | m_selectedLightPiece = getLightIndex(m_selectedColor.getX()); | 139 | m_selectedLightPiece = getLightIndex(m_selectedColor.getX()); | ||
128 | update(); | 140 | update(); | ||
129 | } | 141 | } | ||
130 | 142 | | |||
131 | void KisColorSelector::setFgColor(const KoColor& fgColor) | 143 | void KisColorSelector::setFgColor(const KoColor& fgColor) | ||
132 | { | 144 | { | ||
133 | if (!m_widgetUpdatesSelf) { | 145 | if (!m_widgetUpdatesSelf) { | ||
134 | m_fgColor = KisColor(fgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 146 | m_fgColor = KisColor(fgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
135 | m_selectedColor = KisColor(fgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 147 | m_selectedColor = KisColor(fgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
136 | 148 | | |||
149 | m_isDirtyWheel = true; | ||||
150 | m_isDirtyLightStrip = true; | ||||
151 | m_isDirtyColorPreview = true; | ||||
137 | #ifdef DEBUG_ARC_SELECTOR | 152 | #ifdef DEBUG_ARC_SELECTOR | ||
138 | dbgPlugins << "KisColorSelector::setFgColor: m_fgColor set to:" | 153 | dbgPlugins << "KisColorSelector::setFgColor: m_fgColor set to:" | ||
139 | << "H:" << m_fgColor.getH() | 154 | << "H:" << m_fgColor.getH() | ||
140 | << "S:" << m_fgColor.getS() | 155 | << "S:" << m_fgColor.getS() | ||
141 | << "X:" << m_fgColor.getX(); | 156 | << "X:" << m_fgColor.getX(); | ||
142 | 157 | | |||
143 | dbgPlugins << "KisColorSelector::setFgColor: m_selectedColor set to:" | 158 | dbgPlugins << "KisColorSelector::setFgColor: m_selectedColor set to:" | ||
144 | << "H:" << m_selectedColor.getH() | 159 | << "H:" << m_selectedColor.getH() | ||
145 | << "S:" << m_selectedColor.getS() | 160 | << "S:" << m_selectedColor.getS() | ||
146 | << "X:" << m_selectedColor.getX(); | 161 | << "X:" << m_selectedColor.getX(); | ||
147 | #endif | 162 | #endif | ||
148 | update(); | 163 | update(); | ||
149 | } | 164 | } | ||
150 | } | 165 | } | ||
151 | 166 | | |||
152 | void KisColorSelector::setBgColor(const KoColor& bgColor) | 167 | void KisColorSelector::setBgColor(const KoColor& bgColor) | ||
153 | { | 168 | { | ||
154 | if (!m_widgetUpdatesSelf) { | 169 | if (!m_widgetUpdatesSelf) { | ||
155 | m_bgColor = KisColor(bgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 170 | m_bgColor = KisColor(bgColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
171 | | ||||
172 | m_isDirtyColorPreview = true; | ||||
173 | | ||||
156 | #ifdef DEBUG_ARC_SELECTOR | 174 | #ifdef DEBUG_ARC_SELECTOR | ||
157 | dbgPlugins << "KisColorSelector::setBgColor: m_bgColor set to:" | 175 | dbgPlugins << "KisColorSelector::setBgColor: m_bgColor set to:" | ||
158 | << "H:" << m_bgColor.getH() | 176 | << "H:" << m_bgColor.getH() | ||
159 | << "S:" << m_bgColor.getS() | 177 | << "S:" << m_bgColor.getS() | ||
160 | << "X:" << m_bgColor.getX(); | 178 | << "X:" << m_bgColor.getX(); | ||
161 | #endif | 179 | #endif | ||
162 | update(); | 180 | update(); | ||
163 | } | 181 | } | ||
164 | } | 182 | } | ||
165 | 183 | | |||
166 | void KisColorSelector::setLight(qreal light) | 184 | void KisColorSelector::setLight(qreal light) | ||
167 | { | 185 | { | ||
168 | m_selectedColor.setX(qBound(0.0, light, 1.0)); | 186 | m_selectedColor.setX(qBound(0.0, light, 1.0)); | ||
169 | m_selectedLightPiece = getLightIndex(m_selectedColor.getX()); | 187 | m_selectedLightPiece = getLightIndex(m_selectedColor.getX()); | ||
188 | m_isDirtyLightStrip = true; | ||||
170 | update(); | 189 | update(); | ||
171 | } | 190 | } | ||
172 | 191 | | |||
173 | void KisColorSelector::setLumaCoefficients(qreal lR, qreal lG, qreal lB, qreal lGamma) | 192 | void KisColorSelector::setLumaCoefficients(qreal lR, qreal lG, qreal lB, qreal lGamma) | ||
174 | { | 193 | { | ||
175 | m_lumaR = lR; | 194 | m_lumaR = lR; | ||
176 | m_lumaG = lG; | 195 | m_lumaG = lG; | ||
177 | m_lumaB = lB; | 196 | m_lumaB = lB; | ||
178 | m_lumaGamma = lGamma; | 197 | m_lumaGamma = lGamma; | ||
179 | 198 | | |||
180 | m_selectedColor = KisColor(m_selectedColor, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 199 | m_selectedColor = KisColor(m_selectedColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
200 | | ||||
201 | m_isDirtyLightStrip = true; | ||||
202 | m_isDirtyWheel = true; | ||||
181 | 203 | | |||
182 | #ifdef DEBUG_ARC_SELECTOR | 204 | #ifdef DEBUG_ARC_SELECTOR | ||
183 | dbgPlugins << "KisColorSelector::setLumaCoefficients: " << m_lumaR | 205 | dbgPlugins << "KisColorSelector::setLumaCoefficients: " << m_lumaR | ||
184 | << " " << m_lumaG << " " << m_lumaB << " " << m_lumaGamma; | 206 | << " " << m_lumaG << " " << m_lumaB << " " << m_lumaGamma; | ||
185 | #endif | 207 | #endif | ||
186 | 208 | | |||
187 | update(); | 209 | update(); | ||
188 | } | 210 | } | ||
Show All 12 Lines | |||||
201 | { | 223 | { | ||
202 | if (!gamutMask) { | 224 | if (!gamutMask) { | ||
203 | return; | 225 | return; | ||
204 | } | 226 | } | ||
205 | 227 | | |||
206 | m_currentGamutMask = gamutMask; | 228 | m_currentGamutMask = gamutMask; | ||
207 | m_viewConverter->setViewSize(m_renderAreaSize); | 229 | m_viewConverter->setViewSize(m_renderAreaSize); | ||
208 | m_viewConverter->setMaskSize(m_currentGamutMask->maskSize()); | 230 | m_viewConverter->setMaskSize(m_currentGamutMask->maskSize()); | ||
231 | | ||||
232 | if (m_enforceGamutMask) { | ||||
233 | m_isDirtyWheel = true; | ||||
234 | } else { | ||||
235 | m_isDirtyGamutMask = true; | ||||
236 | } | ||||
237 | | ||||
238 | update(); | ||||
239 | } | ||||
240 | | ||||
241 | void KisColorSelector::setDirty() | ||||
242 | { | ||||
243 | m_isDirtyWheel = true; | ||||
244 | m_isDirtyLightStrip = true; | ||||
245 | m_isDirtyGamutMask = true; | ||||
246 | m_isDirtyColorPreview = true; | ||||
247 | | ||||
209 | update(); | 248 | update(); | ||
210 | } | 249 | } | ||
211 | 250 | | |||
212 | KoGamutMask* KisColorSelector::gamutMask() | 251 | KoGamutMask* KisColorSelector::gamutMask() | ||
213 | { | 252 | { | ||
214 | return m_currentGamutMask; | 253 | return m_currentGamutMask; | ||
215 | } | 254 | } | ||
216 | 255 | | |||
217 | bool KisColorSelector::gamutMaskOn() | 256 | bool KisColorSelector::gamutMaskOn() | ||
218 | { | 257 | { | ||
219 | return m_gamutMaskOn; | 258 | return m_gamutMaskOn; | ||
220 | } | 259 | } | ||
221 | 260 | | |||
222 | 261 | | |||
223 | void KisColorSelector::setGamutMaskOn(bool gamutMaskOn) | 262 | void KisColorSelector::setGamutMaskOn(bool gamutMaskOn) | ||
224 | { | 263 | { | ||
225 | if (m_currentGamutMask) { | 264 | if (m_currentGamutMask) { | ||
226 | m_gamutMaskOn = gamutMaskOn; | 265 | m_gamutMaskOn = gamutMaskOn; | ||
266 | | ||||
267 | if (m_enforceGamutMask) { | ||||
268 | m_isDirtyWheel = true; | ||||
269 | } else { | ||||
270 | m_isDirtyGamutMask = true; | ||||
271 | } | ||||
272 | | ||||
227 | update(); | 273 | update(); | ||
228 | } | 274 | } | ||
229 | } | 275 | } | ||
230 | 276 | | |||
231 | void KisColorSelector::setEnforceGamutMask(bool enforce) | 277 | void KisColorSelector::setEnforceGamutMask(bool enforce) | ||
232 | { | 278 | { | ||
233 | m_enforceGamutMask = enforce; | 279 | m_enforceGamutMask = enforce; | ||
280 | m_isDirtyGamutMask = true; | ||||
281 | m_isDirtyWheel = true; | ||||
234 | update(); | 282 | update(); | ||
235 | } | 283 | } | ||
236 | 284 | | |||
237 | QPointF KisColorSelector::mapCoordToView(const QPointF& pt, const QRectF& viewRect) const | 285 | QPointF KisColorSelector::mapCoordToView(const QPointF& pt, const QRectF& viewRect) const | ||
238 | { | 286 | { | ||
239 | qreal w = viewRect.width() / 2.0; | 287 | qreal w = viewRect.width() / 2.0; | ||
240 | qreal h = viewRect.height() / 2.0; | 288 | qreal h = viewRect.height() / 2.0; | ||
241 | 289 | | |||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | |||||
361 | qreal KisColorSelector::getSaturation(int saturationIdx) const | 409 | qreal KisColorSelector::getSaturation(int saturationIdx) const | ||
362 | { | 410 | { | ||
363 | qreal sat = qreal(saturationIdx) / qreal(getNumRings()-1); | 411 | qreal sat = qreal(saturationIdx) / qreal(getNumRings()-1); | ||
364 | return m_inverseSaturation ? (1.0 - sat) : sat; | 412 | return m_inverseSaturation ? (1.0 - sat) : sat; | ||
365 | } | 413 | } | ||
366 | 414 | | |||
367 | void KisColorSelector::recalculateAreas(quint8 numLightPieces) | 415 | void KisColorSelector::recalculateAreas(quint8 numLightPieces) | ||
368 | { | 416 | { | ||
369 | | ||||
370 | qreal LIGHT_STRIP_RATIO = 0.075; | 417 | qreal LIGHT_STRIP_RATIO = 0.075; | ||
371 | if (m_showValueScaleNumbers) { | 418 | if (m_showValueScaleNumbers) { | ||
372 | LIGHT_STRIP_RATIO = 0.25; | 419 | LIGHT_STRIP_RATIO = 0.25; | ||
373 | } | 420 | } | ||
374 | 421 | | |||
375 | int width = QWidget::width(); | 422 | int width = QWidget::width(); | ||
376 | int height = QWidget::height(); | 423 | int height = QWidget::height(); | ||
377 | int size = qMin(width, height); | 424 | int size = qMin(width, height); | ||
378 | int stripThick = int(size * LIGHT_STRIP_RATIO); | 425 | int stripThick = int(size * LIGHT_STRIP_RATIO); | ||
379 | 426 | | |||
380 | width -= stripThick; | 427 | width -= stripThick; | ||
381 | 428 | | |||
382 | size = qMin(width, height); | 429 | size = qMin(width, height); | ||
383 | 430 | | |||
384 | int x = (width - size) / 2; | 431 | int x = (width - size) / 2; | ||
385 | int y = (height - size) / 2; | 432 | int y = (height - size) / 2; | ||
386 | 433 | | |||
387 | m_renderAreaSize = QSize(size,size); | 434 | m_renderAreaSize = QSize(size,size); | ||
388 | m_viewConverter->setViewSize(m_renderAreaSize); | 435 | m_viewConverter->setViewSize(m_renderAreaSize); | ||
389 | 436 | | |||
437 | m_widgetArea = QRect(0, 0, QWidget::width(), QWidget::height()); | ||||
390 | m_renderArea = QRect(x+stripThick, y, size, size); | 438 | m_renderArea = QRect(x+stripThick, y, size, size); | ||
391 | m_lightStripArea = QRect(0, 0, stripThick, QWidget::height()); | 439 | m_lightStripArea = QRect(0, 0, stripThick, QWidget::height()); | ||
392 | 440 | | |||
393 | m_renderBuffer = QImage(size, size, QImage::Format_ARGB32_Premultiplied); | 441 | m_renderBuffer = QImage(size, size, QImage::Format_ARGB32_Premultiplied); | ||
442 | m_colorPreviewBuffer = QImage(QWidget::width(), QWidget::height(), QImage::Format_ARGB32_Premultiplied); | ||||
394 | m_maskBuffer = QImage(size, size, QImage::Format_ARGB32_Premultiplied); | 443 | m_maskBuffer = QImage(size, size, QImage::Format_ARGB32_Premultiplied); | ||
444 | m_lightStripBuffer = QImage(stripThick, QWidget::height(), QImage::Format_ARGB32_Premultiplied); | ||||
445 | | ||||
395 | m_numLightPieces = numLightPieces; | 446 | m_numLightPieces = numLightPieces; | ||
447 | | ||||
448 | m_isDirtyGamutMask = true; | ||||
449 | m_isDirtyLightStrip = true; | ||||
450 | m_isDirtyWheel = true; | ||||
451 | m_isDirtyColorPreview = true; | ||||
396 | } | 452 | } | ||
397 | 453 | | |||
398 | void KisColorSelector::recalculateRings(quint8 numRings, quint8 numPieces) | 454 | void KisColorSelector::recalculateRings(quint8 numRings, quint8 numPieces) | ||
399 | { | 455 | { | ||
400 | m_colorRings.resize(numRings); | 456 | m_colorRings.resize(numRings); | ||
401 | m_numPieces = numPieces; | 457 | m_numPieces = numPieces; | ||
402 | 458 | | |||
403 | for(int i=0; i<numRings; ++i) { | 459 | for(int i=0; i<numRings; ++i) { | ||
404 | qreal innerRadius = qreal(i) / qreal(numRings); | 460 | qreal innerRadius = qreal(i) / qreal(numRings); | ||
405 | qreal outerRadius = qreal(i+1) / qreal(numRings); | 461 | qreal outerRadius = qreal(i+1) / qreal(numRings); | ||
406 | qreal saturation = qreal(i) / qreal(numRings-1); | 462 | qreal saturation = qreal(i) / qreal(numRings-1); | ||
407 | 463 | | |||
408 | createRing(m_colorRings[i], numPieces, innerRadius, outerRadius+0.001); | 464 | createRing(m_colorRings[i], numPieces, innerRadius, outerRadius+0.001); | ||
409 | m_colorRings[i].saturation = m_inverseSaturation ? (1.0 - saturation) : saturation; | 465 | m_colorRings[i].saturation = m_inverseSaturation ? (1.0 - saturation) : saturation; | ||
410 | } | 466 | } | ||
467 | | ||||
468 | m_isDirtyWheel = true; | ||||
411 | } | 469 | } | ||
412 | 470 | | |||
413 | void KisColorSelector::createRing(ColorRing& ring, quint8 numPieces, qreal innerRadius, qreal outerRadius) | 471 | void KisColorSelector::createRing(ColorRing& ring, quint8 numPieces, qreal innerRadius, qreal outerRadius) | ||
414 | { | 472 | { | ||
415 | int numParts = qMax<int>(numPieces, 1); | 473 | int numParts = qMax<int>(numPieces, 1); | ||
416 | 474 | | |||
417 | ring.innerRadius = innerRadius; | 475 | ring.innerRadius = innerRadius; | ||
418 | ring.outerRadius = outerRadius; | 476 | ring.outerRadius = outerRadius; | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
460 | void KisColorSelector::requestUpdateColorAndPreview(const KisColor &color, Acs::ColorRole role) | 518 | void KisColorSelector::requestUpdateColorAndPreview(const KisColor &color, Acs::ColorRole role) | ||
461 | { | 519 | { | ||
462 | #ifdef DEBUG_ARC_SELECTOR | 520 | #ifdef DEBUG_ARC_SELECTOR | ||
463 | dbgPlugins << "KisColorSelector::requestUpdateColorAndPreview: requesting update to: " | 521 | dbgPlugins << "KisColorSelector::requestUpdateColorAndPreview: requesting update to: " | ||
464 | << "H:" << color.getH() | 522 | << "H:" << color.getH() | ||
465 | << "S:" << color.getS() | 523 | << "S:" << color.getS() | ||
466 | << "X:" << color.getX(); | 524 | << "X:" << color.getX(); | ||
467 | #endif | 525 | #endif | ||
526 | | ||||
468 | m_updateColorCompressor->start(qMakePair(color, role)); | 527 | m_updateColorCompressor->start(qMakePair(color, role)); | ||
469 | } | 528 | } | ||
470 | 529 | | |||
471 | void KisColorSelector::slotUpdateColorAndPreview(QPair<KisColor, Acs::ColorRole> color) | 530 | void KisColorSelector::slotUpdateColorAndPreview(QPair<KisColor, Acs::ColorRole> color) | ||
472 | { | 531 | { | ||
473 | const bool selectAsFgColor = color.second == Acs::Foreground; | 532 | const bool selectAsFgColor = color.second == Acs::Foreground; | ||
474 | 533 | | |||
475 | if (selectAsFgColor) { m_fgColor = color.first; } | 534 | if (selectAsFgColor) { | ||
476 | else { m_bgColor = color.first; } | 535 | m_fgColor = KisColor(color.first, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
536 | } else { | ||||
537 | m_bgColor = KisColor(color.first, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||||
538 | } | ||||
477 | 539 | | |||
478 | m_selectedColor = color.first; | 540 | m_selectedColor = KisColor(color.first, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
541 | | ||||
542 | m_isDirtyLightStrip = true; | ||||
543 | m_isDirtyColorPreview = true; | ||||
544 | m_isDirtyWheel = true; | ||||
479 | 545 | | |||
480 | #ifdef DEBUG_ARC_SELECTOR | 546 | #ifdef DEBUG_ARC_SELECTOR | ||
481 | dbgPlugins << "KisColorSelector::slotUpdateColorAndPreview: m_selectedColor set to:" | 547 | dbgPlugins << "KisColorSelector::slotUpdateColorAndPreview: m_selectedColor set to:" | ||
482 | << "H:" << m_selectedColor.getH() | 548 | << "H:" << m_selectedColor.getH() | ||
483 | << "S:" << m_selectedColor.getS() | 549 | << "S:" << m_selectedColor.getS() | ||
484 | << "X:" << m_selectedColor.getX(); | 550 | << "X:" << m_selectedColor.getX(); | ||
485 | #endif | 551 | #endif | ||
486 | 552 | | |||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 598 | else { | |||
553 | painter.fillPath(ring.pieced[0], QBrush(gradient)); | 619 | painter.fillPath(ring.pieced[0], QBrush(gradient)); | ||
554 | } | 620 | } | ||
555 | 621 | | |||
556 | painter.restore(); | 622 | painter.restore(); | ||
557 | } | 623 | } | ||
558 | 624 | | |||
559 | void KisColorSelector::drawOutline(QPainter& painter, const QRect& rect) | 625 | void KisColorSelector::drawOutline(QPainter& painter, const QRect& rect) | ||
560 | { | 626 | { | ||
627 | painter.save(); | ||||
628 | | ||||
561 | painter.setRenderHint(QPainter::Antialiasing, true); | 629 | painter.setRenderHint(QPainter::Antialiasing, true); | ||
562 | painter.resetTransform(); | 630 | painter.resetTransform(); | ||
563 | painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2); | 631 | painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2); | ||
564 | painter.scale(rect.width()/2, rect.height()/2); | 632 | painter.scale(rect.width()/2, rect.height()/2); | ||
565 | 633 | | |||
566 | QPen normalPen = QPen(QBrush(COLOR_NORMAL_OUTLINE), 0.005); | 634 | QPen normalPen = QPen(QBrush(COLOR_NORMAL_OUTLINE), 0.005); | ||
567 | QPen selectedPen; | 635 | QPen selectedPen; | ||
568 | 636 | | |||
Show All 37 Lines | 664 | if (m_selectedRing >= 0) { | |||
606 | painter.setPen(selectedPen); | 674 | painter.setPen(selectedPen); | ||
607 | painter.drawEllipse(QRectF(-iRad, -iRad, iRad*2.0, iRad*2.0)); | 675 | painter.drawEllipse(QRectF(-iRad, -iRad, iRad*2.0, iRad*2.0)); | ||
608 | painter.drawEllipse(QRectF(-oRad, -oRad, oRad*2.0, oRad*2.0)); | 676 | painter.drawEllipse(QRectF(-oRad, -oRad, oRad*2.0, oRad*2.0)); | ||
609 | 677 | | |||
610 | QPointF lineCoords = mapHueToAngle(m_selectedColor.getH()); | 678 | QPointF lineCoords = mapHueToAngle(m_selectedColor.getH()); | ||
611 | painter.drawLine(QPointF(lineCoords.x()*iRad, lineCoords.y()*iRad), QPointF(lineCoords.x()*oRad, lineCoords.y()*oRad)); | 679 | painter.drawLine(QPointF(lineCoords.x()*iRad, lineCoords.y()*iRad), QPointF(lineCoords.x()*oRad, lineCoords.y()*oRad)); | ||
612 | } | 680 | } | ||
613 | } | 681 | } | ||
682 | | ||||
683 | painter.restore(); | ||||
614 | } | 684 | } | ||
615 | 685 | | |||
616 | void KisColorSelector::drawLightStrip(QPainter& painter, const QRect& rect) | 686 | void KisColorSelector::drawLightStrip(QPainter& painter, const QRect& rect) | ||
617 | { | 687 | { | ||
618 | qreal penSize = qreal(qMin(QWidget::width(), QWidget::height())) / 200.0; | 688 | qreal penSize = qreal(qMin(QWidget::width(), QWidget::height())) / 200.0; | ||
619 | qreal penSizeSmall = penSize / 1.2; | 689 | qreal penSizeSmall = penSize / 1.2; | ||
620 | QPen selectedPen; | 690 | QPen selectedPen; | ||
621 | 691 | | |||
622 | KisColor valueScaleColor(m_selectedColor, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 692 | KisColor valueScaleColor(m_selectedColor, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
623 | KisColor grayScaleColor(Qt::gray, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | 693 | KisColor grayScaleColor(Qt::gray, m_colorConverter, m_colorSpace, m_lumaR, m_lumaG, m_lumaB, m_lumaGamma); | ||
624 | int rectSize = rect.height(); | 694 | int rectSize = rect.height(); | ||
625 | 695 | | |||
626 | painter.resetTransform(); | | |||
627 | painter.save(); | 696 | painter.save(); | ||
697 | painter.resetTransform(); | ||||
628 | painter.setRenderHint(QPainter::Antialiasing, true); | 698 | painter.setRenderHint(QPainter::Antialiasing, true); | ||
629 | 699 | | |||
630 | QTransform matrix; | 700 | QTransform matrix; | ||
631 | matrix.translate(rect.x(), rect.y()); | 701 | matrix.translate(rect.x(), rect.y()); | ||
632 | matrix.scale(rect.width(), rect.height()); | 702 | matrix.scale(rect.width(), rect.height()); | ||
633 | 703 | | |||
634 | qreal rectColorLeftX; | 704 | qreal rectColorLeftX; | ||
635 | qreal rectColorWidth; | 705 | qreal rectColorWidth; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 763 | if (m_showValueScaleNumbers) { | |||
695 | 765 | | |||
696 | int valueScalePieces = getNumLightPieces(); | 766 | int valueScalePieces = getNumLightPieces(); | ||
697 | if (getNumLightPieces() == 1) { | 767 | if (getNumLightPieces() == 1) { | ||
698 | valueScalePieces = 11; | 768 | valueScalePieces = 11; | ||
699 | } | 769 | } | ||
700 | 770 | | |||
701 | QFont font = painter.font(); | 771 | QFont font = painter.font(); | ||
702 | QFontMetrics fm = painter.fontMetrics(); | 772 | QFontMetrics fm = painter.fontMetrics(); | ||
703 | while (fm.boundingRect("100%").width() > rect.width()*rectColorLeftX) { | 773 | int retries = 10; // limit number of font size searches to prevent endless cycles | ||
774 | while ((retries > 0) && (fm.boundingRect("100%").width() > rect.width()*rectColorLeftX)) { | ||||
704 | font.setPointSize(font.pointSize() - 1); | 775 | font.setPointSize(font.pointSize() - 1); | ||
705 | painter.setFont(font); | 776 | painter.setFont(font); | ||
706 | fm = painter.fontMetrics(); | 777 | fm = painter.fontMetrics(); | ||
778 | retries--; | ||||
707 | } | 779 | } | ||
708 | 780 | | |||
709 | for(int i=0; i<valueScalePieces; ++i) { | 781 | for(int i=0; i<valueScalePieces; ++i) { | ||
710 | qreal t1 = qreal(i) / qreal(valueScalePieces); | 782 | qreal t1 = qreal(i) / qreal(valueScalePieces); | ||
711 | qreal t2 = qreal(i+1) / qreal(valueScalePieces); | 783 | qreal t2 = qreal(i+1) / qreal(valueScalePieces); | ||
712 | qreal light = 1.0 - (qreal(i) / qreal(valueScalePieces-1)); | 784 | qreal light = 1.0 - (qreal(i) / qreal(valueScalePieces-1)); | ||
713 | qreal diff = t2 - t1;// + 0.001; | 785 | qreal diff = t2 - t1;// + 0.001; | ||
714 | 786 | | |||
715 | grayScaleColor.setX(light); | 787 | grayScaleColor.setX(light); | ||
716 | 788 | | |||
717 | QRectF rectValue = QRectF(0.0, t1, rectColorLeftX, diff); | 789 | QRectF rectValue = QRectF(0.0, t1, rectColorLeftX, diff); | ||
718 | rectValue = matrix.mapRect(rectValue); | 790 | rectValue = matrix.mapRect(rectValue); | ||
719 | 791 | | |||
720 | painter.fillRect(rectValue, grayScaleColor.toQColor()); | 792 | painter.fillRect(rectValue, grayScaleColor.toQColor()); | ||
721 | 793 | | |||
794 | // if the right font size was not found in time, | ||||
795 | // skip drawing the numbers | ||||
796 | if (retries > 0) { | ||||
722 | int valueNumber = 0; | 797 | int valueNumber = 0; | ||
723 | if (m_colorSpace == KisColor::HSY) { | 798 | if (m_colorSpace == KisColor::HSY) { | ||
724 | valueNumber = 100 - round(pow(pow(grayScaleColor.getX(), m_lumaGamma), 1.0/2.2)*100); | 799 | valueNumber = 100 - round(pow(pow(grayScaleColor.getX(), m_lumaGamma), 1.0/2.2)*100); | ||
725 | } else { | 800 | } else { | ||
726 | valueNumber = 100 - grayScaleColor.getX()*100; | 801 | valueNumber = 100 - grayScaleColor.getX()*100; | ||
727 | } | 802 | } | ||
728 | 803 | | |||
729 | if (valueNumber < 55) { | 804 | if (valueNumber < 55) { | ||
730 | painter.setPen(QPen(QBrush(COLOR_DARK), penSize)); | 805 | painter.setPen(QPen(QBrush(COLOR_DARK), penSize)); | ||
731 | } else { | 806 | } else { | ||
732 | painter.setPen(QPen(QBrush(COLOR_LIGHT), penSize)); | 807 | painter.setPen(QPen(QBrush(COLOR_LIGHT), penSize)); | ||
733 | } | 808 | } | ||
734 | 809 | | |||
735 | painter.drawText(rectValue, Qt::AlignRight|Qt::AlignBottom, QString("%1%").arg(QString::number(valueNumber))); | 810 | painter.drawText(rectValue, Qt::AlignRight|Qt::AlignBottom, QString("%1%").arg(QString::number(valueNumber))); | ||
736 | } | 811 | } | ||
737 | } | 812 | } | ||
813 | } | ||||
738 | 814 | | |||
739 | painter.restore(); | 815 | painter.restore(); | ||
740 | } | 816 | } | ||
741 | 817 | | |||
742 | void KisColorSelector::drawBlip(QPainter& painter, const QRect& rect) | 818 | void KisColorSelector::drawBlip(QPainter& painter, const QRect& rect) | ||
743 | { | 819 | { | ||
820 | painter.save(); | ||||
821 | | ||||
744 | painter.setRenderHint(QPainter::Antialiasing, true); | 822 | painter.setRenderHint(QPainter::Antialiasing, true); | ||
745 | painter.resetTransform(); | 823 | painter.resetTransform(); | ||
746 | painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2); | 824 | painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2); | ||
747 | painter.scale(rect.width()/2, rect.height()/2); | 825 | painter.scale(rect.width()/2, rect.height()/2); | ||
748 | 826 | | |||
749 | QPointF fgColorPos = mapColorToUnit(m_fgColor); | 827 | QPointF fgColorPos = mapColorToUnit(m_fgColor); | ||
750 | 828 | | |||
751 | #ifdef DEBUG_ARC_SELECTOR | 829 | #ifdef DEBUG_ARC_SELECTOR | ||
752 | dbgPlugins << "KisColorSelector::drawBlip: " | 830 | dbgPlugins << "KisColorSelector::drawBlip: " | ||
753 | << "colorPoint H:" << m_fgColor.getH() << " S:" << m_fgColor.getS() | 831 | << "colorPoint H:" << m_fgColor.getH() << " S:" << m_fgColor.getS() | ||
754 | << "-> coord X:" << fgColorPos.x() << " Y:" << fgColorPos.y(); | 832 | << "-> coord X:" << fgColorPos.x() << " Y:" << fgColorPos.y(); | ||
755 | #endif | 833 | #endif | ||
756 | 834 | | |||
757 | painter.setPen(QPen(QBrush(COLOR_SELECTED_DARK), 0.01)); | 835 | painter.setPen(QPen(QBrush(COLOR_SELECTED_DARK), 0.01)); | ||
758 | painter.drawEllipse(fgColorPos, 0.05, 0.05); | 836 | painter.drawEllipse(fgColorPos, 0.05, 0.05); | ||
759 | 837 | | |||
760 | painter.setPen(QPen(QBrush(COLOR_SELECTED_LIGHT), 0.01)); | 838 | painter.setPen(QPen(QBrush(COLOR_SELECTED_LIGHT), 0.01)); | ||
761 | painter.setBrush(m_fgColor.toQColor()); | | |||
762 | painter.drawEllipse(fgColorPos, 0.04, 0.04); | 839 | painter.drawEllipse(fgColorPos, 0.04, 0.04); | ||
840 | | ||||
841 | painter.restore(); | ||||
763 | } | 842 | } | ||
764 | 843 | | |||
765 | void KisColorSelector::drawGamutMaskShape(QPainter &painter, const QRect &rect) | 844 | void KisColorSelector::drawGamutMaskShape(QPainter &painter, const QRect &rect) | ||
766 | { | 845 | { | ||
767 | painter.save(); | 846 | painter.save(); | ||
768 | painter.setRenderHint(QPainter::Antialiasing, true); | 847 | painter.setRenderHint(QPainter::Antialiasing, true); | ||
769 | 848 | | |||
770 | painter.resetTransform(); | 849 | painter.resetTransform(); | ||
Show All 11 Lines | |||||
782 | m_currentGamutMask->paint(painter, *m_viewConverter, m_maskPreviewActive); | 861 | m_currentGamutMask->paint(painter, *m_viewConverter, m_maskPreviewActive); | ||
783 | 862 | | |||
784 | painter.setCompositionMode(QPainter::CompositionMode_SourceOver); | 863 | painter.setCompositionMode(QPainter::CompositionMode_SourceOver); | ||
785 | m_currentGamutMask->paintStroke(painter, *m_viewConverter, m_maskPreviewActive); | 864 | m_currentGamutMask->paintStroke(painter, *m_viewConverter, m_maskPreviewActive); | ||
786 | 865 | | |||
787 | painter.restore(); | 866 | painter.restore(); | ||
788 | } | 867 | } | ||
789 | 868 | | |||
790 | void KisColorSelector::paintEvent(QPaintEvent* /*event*/) | 869 | void KisColorSelector::drawColorPreview(QPainter &painter, const QRect &rect) | ||
791 | { | 870 | { | ||
792 | // 0 red -> (1,0,0) | 871 | painter.save(); | ||
793 | // 1 yellow -> (1,1,0) | 872 | painter.setRenderHint(QPainter::Antialiasing, true); | ||
794 | // 2 green -> (0,1,0) | | |||
795 | // 3 cyan -> (0,1,1) | | |||
796 | // 4 blue -> (0,0,1) | | |||
797 | // 5 maenta -> (1,0,1) | | |||
798 | // 6 red -> (1,0,0) | | |||
799 | | ||||
800 | m_renderBuffer.fill(0); | | |||
801 | | ||||
802 | QPainter imgPainter(&m_renderBuffer); | | |||
803 | QPainter wdgPainter(this); | | |||
804 | | ||||
805 | // draw the fg and bg color previews | | |||
806 | // QPainter settings must be saved and restored afterwards, otherwise the wheel drawing is totally broken | | |||
807 | wdgPainter.save(); | | |||
808 | wdgPainter.setRenderHint(QPainter::Antialiasing, true); | | |||
809 | 873 | | |||
810 | QRect fgRect(0, 0, QWidget::width(), QWidget::height()); | 874 | painter.fillRect(rect, m_fgColor.toQColor()); | ||
811 | wdgPainter.fillRect(fgRect, m_fgColor.toQColor()); | | |||
812 | 875 | | |||
813 | int bgSide = qMin(QWidget::width()*0.15,QWidget::height()*0.15); | 876 | int bgSide = qMin(rect.width()*0.15,rect.height()*0.15); | ||
814 | 877 | | |||
815 | if (m_showBgColor) { | 878 | if (m_showBgColor) { | ||
816 | QPointF bgPolyPoints[3] = { | 879 | QPointF bgPolyPoints[3] = { | ||
817 | QPointF(QWidget::width(), QWidget::height()), | 880 | QPointF(rect.width(), rect.height()), | ||
818 | QPointF(QWidget::width()-bgSide, QWidget::height()), | 881 | QPointF(rect.width()-bgSide, rect.height()), | ||
819 | QPointF(QWidget::width(), QWidget::height()-bgSide) | 882 | QPointF(rect.width(), rect.height()-bgSide) | ||
820 | }; | 883 | }; | ||
821 | 884 | | |||
822 | wdgPainter.setBrush(m_bgColor.toQColor()); | 885 | painter.setBrush(m_bgColor.toQColor()); | ||
823 | wdgPainter.setPen(m_bgColor.toQColor()); | 886 | painter.setPen(m_bgColor.toQColor()); | ||
824 | wdgPainter.drawPolygon(bgPolyPoints, 3); | 887 | painter.drawPolygon(bgPolyPoints, 3); | ||
825 | } | 888 | } | ||
826 | 889 | | |||
827 | wdgPainter.restore(); | 890 | painter.restore(); | ||
891 | } | ||||
892 | | ||||
893 | void KisColorSelector::paintEvent(QPaintEvent* /*event*/) | ||||
894 | { | ||||
895 | QPainter wdgPainter(this); | ||||
896 | | ||||
897 | // draw the fg and bg color previews | ||||
898 | if (m_isDirtyColorPreview) { | ||||
899 | m_colorPreviewBuffer.fill(Qt::transparent); | ||||
900 | QPainter colorPreviewPainter(&m_colorPreviewBuffer); | ||||
901 | drawColorPreview(colorPreviewPainter, m_widgetArea); | ||||
902 | | ||||
903 | m_isDirtyColorPreview = false; | ||||
904 | } | ||||
905 | wdgPainter.drawImage(m_widgetArea, m_colorPreviewBuffer); | ||||
906 | // draw the fg and bg color previews | ||||
907 | | ||||
908 | // draw the wheel | ||||
909 | if (m_isDirtyWheel) { | ||||
910 | m_renderBuffer.fill(Qt::transparent); | ||||
911 | QPainter wheelPainter(&m_renderBuffer); | ||||
828 | 912 | | |||
829 | for(int i=0; i<m_colorRings.size(); ++i) | 913 | for(int i=0; i<m_colorRings.size(); ++i) | ||
830 | drawRing(imgPainter, m_colorRings[i], m_renderArea); | 914 | drawRing(wheelPainter, m_colorRings[i], m_renderArea); | ||
831 | 915 | | |||
916 | m_isDirtyWheel = false; | ||||
917 | } | ||||
832 | wdgPainter.drawImage(m_renderArea, m_renderBuffer); | 918 | wdgPainter.drawImage(m_renderArea, m_renderBuffer); | ||
919 | // draw the wheel | ||||
833 | 920 | | |||
834 | // draw the mask either in continuous mode or in discrete mode when enforcing is turned off | 921 | // draw the mask either in continuous mode or in discrete mode when enforcing is turned off | ||
835 | // if enforcing is turned on in discrete mode, | 922 | // if enforcing is turned on in discrete mode, | ||
836 | // drawRing function takes care of delineating the mask swatches | 923 | // drawRing function takes care of delineating the mask swatches | ||
837 | if (m_gamutMaskOn | 924 | if (m_gamutMaskOn | ||
838 | && ((getNumPieces() == 1) || (!m_enforceGamutMask))) { | 925 | && ((getNumPieces() == 1) || (!m_enforceGamutMask))) { | ||
839 | 926 | | |||
840 | m_maskBuffer.fill(0); | 927 | if (m_isDirtyGamutMask) { | ||
928 | m_maskBuffer.fill(Qt::transparent); | ||||
841 | QPainter maskPainter(&m_maskBuffer); | 929 | QPainter maskPainter(&m_maskBuffer); | ||
842 | drawGamutMaskShape(maskPainter, m_renderArea); | 930 | drawGamutMaskShape(maskPainter, m_renderArea); | ||
843 | 931 | | |||
932 | m_isDirtyGamutMask = false; | ||||
933 | } | ||||
844 | wdgPainter.drawImage(m_renderArea, m_maskBuffer); | 934 | wdgPainter.drawImage(m_renderArea, m_maskBuffer); | ||
845 | } | 935 | } | ||
936 | // draw gamut mask | ||||
846 | 937 | | |||
847 | drawOutline (wdgPainter, m_renderArea); | 938 | drawOutline(wdgPainter, m_renderArea); | ||
848 | drawLightStrip(wdgPainter, m_lightStripArea); | 939 | | ||
940 | // draw light strip | ||||
941 | if (m_isDirtyLightStrip) { | ||||
942 | m_lightStripBuffer.fill(Qt::transparent); | ||||
943 | QPainter lightStripPainter(&m_lightStripBuffer); | ||||
944 | | ||||
945 | drawLightStrip(lightStripPainter, m_lightStripArea); | ||||
946 | m_isDirtyLightStrip = false; | ||||
947 | } | ||||
948 | wdgPainter.drawImage(m_lightStripArea, m_lightStripBuffer); | ||||
949 | // draw light strip | ||||
950 | | ||||
849 | drawBlip (wdgPainter, m_renderArea); | 951 | drawBlip(wdgPainter, m_renderArea); | ||
850 | } | 952 | } | ||
851 | 953 | | |||
852 | void KisColorSelector::mousePressEvent(QMouseEvent* event) | 954 | void KisColorSelector::mousePressEvent(QMouseEvent* event) | ||
853 | { | 955 | { | ||
854 | m_widgetUpdatesSelf = true; | 956 | m_widgetUpdatesSelf = true; | ||
855 | #ifdef DEBUG_ARC_SELECTOR | 957 | #ifdef DEBUG_ARC_SELECTOR | ||
856 | dbgPlugins << "KisColorSelector::mousePressEvent: m_widgetUpdatesSelf = true"; | 958 | dbgPlugins << "KisColorSelector::mousePressEvent: m_widgetUpdatesSelf = true"; | ||
857 | #endif | 959 | #endif | ||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | |||||
1065 | { | 1167 | { | ||
1066 | num = qBound(MIN_NUM_LIGHT_PIECES, num, MAX_NUM_LIGHT_PIECES); | 1168 | num = qBound(MIN_NUM_LIGHT_PIECES, num, MAX_NUM_LIGHT_PIECES); | ||
1067 | m_defaultValueScaleSteps = num; | 1169 | m_defaultValueScaleSteps = num; | ||
1068 | } | 1170 | } | ||
1069 | 1171 | | |||
1070 | void KisColorSelector::setShowBgColor(bool value) | 1172 | void KisColorSelector::setShowBgColor(bool value) | ||
1071 | { | 1173 | { | ||
1072 | m_showBgColor = value; | 1174 | m_showBgColor = value; | ||
1175 | m_isDirtyColorPreview = true; | ||||
1073 | update(); | 1176 | update(); | ||
1074 | } | 1177 | } | ||
1075 | 1178 | | |||
1076 | void KisColorSelector::setShowValueScaleNumbers(bool value) | 1179 | void KisColorSelector::setShowValueScaleNumbers(bool value) | ||
1077 | { | 1180 | { | ||
1078 | m_showValueScaleNumbers = value; | 1181 | m_showValueScaleNumbers = value; | ||
1079 | recalculateAreas(quint8(getNumLightPieces())); | 1182 | recalculateAreas(quint8(getNumLightPieces())); | ||
1080 | update(); | 1183 | update(); | ||
1081 | } | 1184 | } | ||
1082 | 1185 | | |||
1083 | bool KisColorSelector::saturationIsInvertible() | | |||
1084 | { | | |||
1085 | if (!m_gamutMaskOn) return true; | | |||
1086 | bool b = (m_enforceGamutMask && getNumPieces() == 1) ? false : true; | | |||
1087 | return b; | | |||
1088 | } | | |||
1089 | |