Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_color_input.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
3 * SPDX-FileCopyrightText: 2011 Sven Langkamp <sven.langkamp@gmail.com>
4 * SPDX-FileCopyrightText: 2015 Moritz Molch <kde@moritzmolch.de>
5 *
6 * SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8
9#include "kis_color_input.h"
10
11#include <KoConfig.h>
12#ifdef HAVE_OPENEXR
13#include <half.h>
14#endif
15
16#include <cmath>
17
18#include <kis_debug.h>
19
20#include <QHBoxLayout>
21#include <QLabel>
22#include <QLineEdit>
23#include <QSpinBox>
24#include <QDoubleSpinBox>
25#include <QRegularExpression>
26#include <QRegularExpressionValidator>
27
28#include <klocalizedstring.h>
29
30#include <KoChannelInfo.h>
31#include <KoColor.h>
32#include <KoColorSlider.h>
33#include <KoColorSpace.h>
34#include <KisHsvColorSlider.h>
35#include <KoColorConversions.h>
37
40#include "kis_signals_blocker.h"
41
42KisColorInput::KisColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
43 QWidget(parent), m_channelInfo(channelInfo), m_color(color), m_displayRenderer(displayRenderer),
44 m_usePercentage(usePercentage)
45{
46}
47
49{
50 QHBoxLayout* m_layout = new QHBoxLayout(this);
51 m_layout->setContentsMargins(0,0,0,0);
52 m_layout->setSpacing(1);
53
54 QLabel* m_label = new QLabel(i18n("%1:", m_channelInfo->name()), this);
55 m_layout->addWidget(m_label);
56
57 m_colorSlider = new KoColorSlider(Qt::Horizontal, this, m_displayRenderer);
58 m_colorSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
59 m_layout->addWidget(m_colorSlider);
60
61 QWidget* m_input = createInput();
62 m_layout->addWidget(m_input);
63}
64
65KisIntegerColorInput::KisIntegerColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
66 KisColorInput(parent, channelInfo, color, displayRenderer, usePercentage)
67{
68 init();
69}
70
72{
73 quint8* data = m_color->data() + m_channelInfo->pos();
76 *(reinterpret_cast<quint8*>(data)) = v;
77 break;
79 *(reinterpret_cast<quint16*>(data)) = v;
80 break;
82 *(reinterpret_cast<quint32*>(data)) = v;
83 break;
84 default:
85 Q_ASSERT(false);
86 }
87 emit(updated());
88}
89
91{
92 KoColor min = *m_color;
93 KoColor max = *m_color;
94 quint8* data = m_color->data() + m_channelInfo->pos();
95 quint8* dataMin = min.data() + m_channelInfo->pos();
96 quint8* dataMax = max.data() + m_channelInfo->pos();
97 m_intNumInput->blockSignals(true);
98 m_colorSlider->blockSignals(true);
101 quint8 value = *(reinterpret_cast<quint8*>(data));
102 m_intNumInput->setValue(m_usePercentage ? round(value * 100.0 / 0xFF) : value);
103 m_colorSlider->setValue(value);
104 *(reinterpret_cast<quint8*>(dataMin)) = 0x0;
105 *(reinterpret_cast<quint8*>(dataMax)) = 0xFF;
106 break;
107 }
109 quint16 value = *(reinterpret_cast<quint16*>(data));
110 m_intNumInput->setValue(m_usePercentage ? round(value * 100.0 / 0xFFFF) : value);
111 m_colorSlider->setValue(value);
112 *(reinterpret_cast<quint16*>(dataMin)) = 0x0;
113 *(reinterpret_cast<quint16*>(dataMax)) = 0xFFFF;
114 break;
115 }
117 quint32 value = *(reinterpret_cast<quint32*>(data));
118 m_intNumInput->setValue(m_usePercentage ? round(value * 100.0 / 0xFFFF'FFFF) : value);
119 m_colorSlider->setValue(value);
120 *(reinterpret_cast<quint32*>(dataMin)) = 0x0;
121 *(reinterpret_cast<quint32*>(dataMax)) = 0xFFFF'FFFF;
122 break;
123 }
124 default:
125 Q_ASSERT(false);
126 }
127 m_colorSlider->setColors(min, max);
128 m_intNumInput->blockSignals(false);
129 m_colorSlider->blockSignals(false);
130}
131
133{
135 m_intNumInput->setMinimum(0);
136 m_colorSlider->setMinimum(0);
137
138 if (m_usePercentage) {
139 KisSpinBoxI18nHelper::setText(m_intNumInput, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
140 }
141
143
144 connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(onColorSliderChanged(int)));
145 connect(m_intNumInput, SIGNAL(valueChanged(int)), this, SLOT(onNumInputChanged(int)));
146 return m_intNumInput;
147}
148
150{
151 m_intNumInput->clearFocus(); // make sure focus doesn't interfere with updating
152
156
157 m_intNumInput->blockSignals(true); // prevent clamping from triggering a value update
158 m_intNumInput->setMaximum(m_usePercentage ? 100 : (1 << 8 * m_channelInfo->size()) - 1);
159 m_colorSlider->setMaximum((1 << 8 * m_channelInfo->size()) - 1);
160 m_intNumInput->blockSignals(false);
161}
162
164{
165 m_usePercentage = val;
166
167 m_intNumInput->clearFocus(); // make sure focus doesn't interfere with updating
168
169 if (m_usePercentage) {
170 KisSpinBoxI18nHelper::setText(m_intNumInput, i18nc("{n} is the number value, % is the percent sign", "{n}%"));
171 } else {
172 m_intNumInput->setPrefix("");
173 m_intNumInput->setSuffix("");
174 }
175
177}
178
180{
181 m_intNumInput->blockSignals(true);
182
186
187 m_intNumInput->setValue(m_usePercentage ? round(val * 100.0 / ((1 << 8 * m_channelInfo->size()) - 1))
188 : val);
189
190 m_intNumInput->blockSignals(false);
191 setValue(val);
192}
193
195{
196 m_colorSlider->blockSignals(true);
197
201
202 m_colorSlider->setValue(m_usePercentage ? val / 100.0 * ((1 << 8 * m_channelInfo->size()) - 1)
203 : val);
204
205 m_colorSlider->blockSignals(false);
206 setValue(m_usePercentage ? val / 100.0 * ((1 << 8 * m_channelInfo->size()) - 1)
207 : val);
208}
209
210KisFloatColorInput::KisFloatColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage) :
211 KisColorInput(parent, channelInfo, color, displayRenderer, usePercentage)
212{
213 init();
214}
215
217{
218 quint8* data = m_color->data() + m_channelInfo->pos();
219 switch (m_channelInfo->channelValueType()) {
220#ifdef HAVE_OPENEXR
222 *(reinterpret_cast<half*>(data)) = v;
223 break;
224#endif
226 *(reinterpret_cast<float*>(data)) = v;
227 break;
228 default:
229 Q_ASSERT(false);
230 }
231 emit(updated());
232}
233
235{
237 m_dblNumInput->setMinimum(0);
238 m_dblNumInput->setMaximum(1.0);
239 m_dblNumInput->setSingleStep(0.01);
240 connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int)));
241 connect(m_dblNumInput, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
242 m_dblNumInput->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
243 m_dblNumInput->setMinimumWidth(60);
244 m_dblNumInput->setMaximumWidth(60);
245
246 quint8* data = m_color->data() + m_channelInfo->pos();
247 qreal value = 1.0;
248
249 switch (m_channelInfo->channelValueType()) {
250#ifdef HAVE_OPENEXR
252 value = *(reinterpret_cast<half*>(data));
253 break;
254#endif
256 value = *(reinterpret_cast<float*>(data));
257 break;
258 default:
259 Q_ASSERT(false);
260 }
262
263 return m_dblNumInput;
264}
265
267{
268 const qreal floatRange = m_maxValue - m_minValue;
269 m_dblNumInput->setValue(m_minValue + (i / 255.0) * floatRange);
270}
271
273{
274 KoColor min = *m_color;
275 KoColor max = *m_color;
276 quint8* data = m_color->data() + m_channelInfo->pos();
277 quint8* dataMin = min.data() + m_channelInfo->pos();
278 quint8* dataMax = max.data() + m_channelInfo->pos();
279
280 qreal value = 1.0;
283 m_dblNumInput->blockSignals(true);
284 m_colorSlider->blockSignals(true);
285
286 switch (m_channelInfo->channelValueType()) {
287#ifdef HAVE_OPENEXR
289 value = *(reinterpret_cast<half*>(data));
290 m_minValue = qMin(value, m_minValue);
291 m_maxValue = qMax(value, m_maxValue);
292 *(reinterpret_cast<half*>(dataMin)) = m_minValue;
293 *(reinterpret_cast<half*>(dataMax)) = m_maxValue;
294 break;
295#endif
297 value = *(reinterpret_cast<float*>(data));
298 m_minValue = qMin(value, m_minValue);
299 m_maxValue = qMax(value, m_maxValue);
300 *(reinterpret_cast<float*>(dataMin)) = m_minValue;
301 *(reinterpret_cast<float*>(dataMax)) = m_maxValue;
302 break;
303 default:
304 Q_ASSERT(false);
305 }
306
307 if (m_minValue != m_dblNumInput->minimum()) {
308 m_dblNumInput->setMinimum(m_minValue);
309 }
310 if (m_maxValue != m_dblNumInput->maximum()) {
311 m_dblNumInput->setMaximum(m_maxValue);
312 }
313
314 // ensure at least 3 significant digits are always shown
315 int newPrecision = 2 + qMax(qreal(0.0), std::ceil(-std::log10(m_maxValue)));
316 if (newPrecision != m_dblNumInput->decimals()) {
317 m_dblNumInput->setDecimals(newPrecision);
318 m_dblNumInput->updateGeometry();
319 }
321
322 m_colorSlider->setColors(min, max);
323
324 const qreal floatRange = m_maxValue - m_minValue;
325 m_colorSlider->setValue((value - m_minValue) / floatRange * 255);
326 m_dblNumInput->blockSignals(false);
327 m_colorSlider->blockSignals(false);
328}
329
330KisHexColorInput::KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, bool usePercentage, bool usePreview) :
331 KisColorInput(parent, 0, color, displayRenderer, usePercentage)
332{
333 QHBoxLayout* m_layout = new QHBoxLayout(this);
334 m_layout->setContentsMargins(0,0,0,0);
335 m_layout->setSpacing(1);
336
337 QLabel* m_label = new QLabel(i18n("Color name:"), this);
338 m_label->setMinimumWidth(50);
339 m_layout->addWidget(m_label);
340
341 QWidget* m_input = createInput();
342 m_input->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
343
344 if(usePreview) {
345 m_colorPreview = new QLabel("");
346 m_colorPreview->setMinimumWidth(30);
347 m_layout->addWidget(m_colorPreview);
348 }
349
350 connect(m_input, SIGNAL(textChanged(const QString&)), SLOT(setValue()));
351 connect(m_input, SIGNAL(textEdited(const QString &)), SLOT(textChanged(const QString &)));
352
353 m_layout->addWidget(m_input);
354}
355
356void KisHexColorInput::textChanged(const QString &text)
357{
358 this->m_hexInput->setText(text.trimmed());
359}
360
362{
363 QString valueString = m_hexInput->text();
364 valueString.remove(QChar('#'));
365
367 channels = KoChannelInfo::displayOrderSorted(channels);
368 Q_FOREACH (KoChannelInfo* channel, channels) {
369 if (channel->channelType() == KoChannelInfo::COLOR) {
370 Q_ASSERT(channel->channelValueType() == KoChannelInfo::UINT8);
371 quint8* data = m_color->data() + channel->pos();
372
373 int value = valueString.left(2).toInt(0, 16);
374 *(reinterpret_cast<quint8*>(data)) = value;
375 valueString.remove(0, 2);
376 }
377 }
378 emit(updated());
379}
380
382{
383 QString hexString("#");
384
386 channels = KoChannelInfo::displayOrderSorted(channels);
387 Q_FOREACH (KoChannelInfo* channel, channels) {
388 if (channel->channelType() == KoChannelInfo::COLOR) {
389 Q_ASSERT(channel->channelValueType() == KoChannelInfo::UINT8);
390 quint8* data = m_color->data() + channel->pos();
391 hexString.append(QString("%1").arg(*(reinterpret_cast<quint8*>(data)), 2, 16, QChar('0')));
392 }
393 }
394 m_hexInput->setText(hexString);
395 if( m_colorPreview) {
396 m_colorPreview->setStyleSheet(QString("background-color: %1").arg(m_displayRenderer->toQColor(*m_color).name()));
397 }
398}
399
401{
402 m_hexInput = new QLineEdit(this);
403 m_hexInput->setAlignment(Qt::AlignRight);
404
405 int digits = 2*m_color->colorSpace()->colorChannelCount();
406 QString pattern = QString("\\s*#?[a-fA-F0-9]{%1,%2}\\s*").arg(digits).arg(digits);
407 m_hexInput->setValidator(new QRegularExpressionValidator(QRegularExpression(pattern), this));
408 connect(m_hexInput, SIGNAL(editingFinished()), this, SLOT(setValue()));
409 return m_hexInput;
410}
411
412
414 : QWidget(parent)
415 , m_color(color)
416 , m_hSlider(nullptr)
417 , m_sSlider(nullptr)
418 , m_xSlider(nullptr)
419 , m_hInput(nullptr)
420 , m_sInput(nullptr)
421 , m_xInput(nullptr)
422 , m_h(0)
423 , m_s(0)
424 , m_x(0)
425 , m_mixMode(KisHsvColorSlider::MIX_MODE::HSV)
426{
427
428 const QStringList labelNames = QStringList({
429 i18nc("@label:slider Abbreviation for 'Hue'", "H:"),
430 i18nc("@label:slider Abbreviation for 'Saturation'", "S:"),
431 QString(/* x will get initialized later in setMixMode */) });
432 qreal maxValues[3] = { 360, 100, 100 };
433
434 QGridLayout *slidersLayout = new QGridLayout(this);
435 slidersLayout->setContentsMargins(0,0,0,0);
436 slidersLayout->setHorizontalSpacing(1); // less space around the sliders
437
438 for (int i = 0; i < 3; i++) {
439 // Label
440 QLabel *label = new QLabel(labelNames[i], this);
441 slidersLayout->addWidget(label, i, 0);
442
443 // Slider itself
444 KisHsvColorSlider *slider = new KisHsvColorSlider(Qt::Horizontal, this);
445 slider->setMixMode(m_mixMode);
446 slider->setMinimum(0);
447 slider->setMaximum(maxValues[i]);
448 slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
449 slidersLayout->addWidget(slider, i, 1);
450
451 // Input box
453 input->setMinimum(0);
454 input->setMaximum(maxValues[i]);
455
456 input->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
457 input->setMinimumWidth(60);
458 input->setMaximumWidth(60);
459
460 slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
461 slidersLayout->addWidget(input, i, 2);
462
463 switch (i) {
464 case 0:
465 m_hSlider = slider;
466 m_hInput = input;
467 case 1:
468 m_sSlider = slider;
469 m_sInput = input;
470 case 2:
471 m_xLabel = label; // Save the HSX label so we can update it
472 m_xSlider = slider;
473 m_xInput = input;
474 }
475 }
476
477 // Connect slots
478 connect(m_hSlider, SIGNAL(valueChanged(int)), this, SLOT(hueSliderChanged(int)));
479 connect(m_hInput, SIGNAL(valueChanged(double)), this, SLOT(setHue(double)));
480 connect(m_sSlider, SIGNAL(valueChanged(int)), this, SLOT(saturationSliderChanged(int)));
481 connect(m_sInput, SIGNAL(valueChanged(double)), this, SLOT(setSaturation(double)));
482 connect(m_xSlider, SIGNAL(valueChanged(int)), this, SLOT(valueSliderChanged(int)));
483 connect(m_xInput, SIGNAL(valueChanged(double)), this, SLOT(setValue(double)));
484
486
487 // Set initial values
488 QColor c = m_color->toQColor();
489 getHsxF(c, &m_h, &m_s, &m_x);
490
494
495 // Update sliders
496 QColor minC, maxC;
497 minC.setHsvF(0, 1, 1);
498 maxC.setHsvF(1, 1, 1);
499 m_hSlider->setColors(minC, maxC);
501
503}
504
506
507 switch (mixMode) {
509 m_xLabel->setText(i18nc("@label:slider Abbreviation for 'Lightness' of HSL color model", "L:"));
510 break;
512 m_xLabel->setText(i18nc("@label:slider Abbreviation for 'Luma' of HSY color model", "Y:"));
513 break;
515 m_xLabel->setText(i18nc("@label:slider Abbreviation for 'Intensity' of HSI color model", "I:"));
516 break;
517 default: // fallthrough
519 m_xLabel->setText(i18nc("@label:slider Abbreviation for 'Value' of HSV color model", "V:"));
520 break;
521 }
522
523 QColor c = m_color->toQColor();
524 m_mixMode = mixMode;
525 getHsxF(c, &m_h, &m_s, &m_x);
526
529
530 sendUpdate();
531}
532
534{
535 {
536 KisSignalsBlocker blocker(
539 );
540 m_hSlider->setValue(m_h * 360);
541 m_sSlider->setValue(m_s * 100);
542 m_xSlider->setValue(m_x * 100);
543
544 m_hInput->setValue(m_h * 360);
545 m_sInput->setValue(m_s * 100);
546 m_xInput->setValue(m_x * 100);
547 }
548
550
551 QColor c;
552 fillColor(c);
553
555 emit(updated());
556}
557
559{
560 x = qBound(0.0, x, 360.0);
561
562 m_h = x / 360;
563 sendUpdate();
564}
565
567{
568 x = qBound(0.0, x, 100.0);
569
570 m_s = x / 100;
571 sendUpdate();
572}
573
575{
576 x = qBound(0.0, x, 100.0);
577
578 m_x = x / 100;
579 sendUpdate();
580}
581
586
591
596
598 // Update sliders
599 QColor minC, maxC;
600
601 minC.setHsvF(m_h, 0, m_x);
602 maxC.setHsvF(m_h, 1, m_x);
603 m_sSlider->setColors(minC, maxC);
604
605 minC.setHsvF(m_h, m_s, 0);
606 maxC.setHsvF(m_h, m_s, 1);
607 m_xSlider->setColors(minC, maxC);
608}
609
611{
612 KisSignalsBlocker blocker(
615 );
616
617 // Check if it is the same color we have
618 QColor current;
619
620 fillColor(current);
621
622 QColor theirs = m_color->toQColor();
623
624 // Truncate to integer for this check
625 if (!(current.red() == theirs.red() && current.green() == theirs.green() && current.blue() == theirs.blue())) {
626 // Apply the update
627 qreal theirH;
628 getHsxF(theirs, &theirH, &m_s, &m_x);
629
630 // Don't jump the Hue slider around to 0 if it is currently on 360
631 const qreal EPSILON = 1e-6;
632 if (!((1.0 - m_h) < EPSILON && (theirH - 0.0) < EPSILON)) {
633 m_h = theirH;
634 }
635
636 m_hInput->setValue(m_h * 360);
637 m_sInput->setValue(m_s * 100);
638 m_xInput->setValue(m_x * 100);
639
641
642 // Update slider positions
643 m_hSlider->setValue(m_h * 360);
644 m_sSlider->setValue(m_s * 100);
645 m_xSlider->setValue(m_x * 100);
646 }
647}
648
650 fillColor(c, m_h, m_s, m_x);
651}
652
653void KisHsvColorInput::fillColor(QColor& c, const qreal& h, const qreal& s, const qreal& x)
654{
655 switch (m_mixMode) {
657 c.setHslF(h, s, x);
658 break;
659
661 qreal r, g, b;
662 HSYToRGB(h, s, x, &r, &g, &b);
663
664 // Clamp
665 r = qBound(0.0, r, 1.0);
666 g = qBound(0.0, g, 1.0);
667 b = qBound(0.0, b, 1.0);
668
669 c.setRgbF(r, g, b);
670 break;
671 }
672
674 qreal r, g, b;
675 HSIToRGB(h, s, x, &r, &g, &b);
676 c.setRgbF(r, g, b);
677 break;
678 }
679
680 default: // fallthrough
682 c.setHsvF(h, s, x);
683 break;
684 }
685}
686
687void KisHsvColorInput::getHsxF(const QColor& color, qreal* h, qreal* s, qreal* x)
688{
689 qreal tempH;
690#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0))
691 float fS = *s;
692 float fX = *x;
693#endif
694 switch (m_mixMode) {
696 {
697#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
698 color.getHslF(&tempH, s, x);
699#else
700 float th;
701 color.getHslF(&th, &fS, &fX);
702 tempH = th;
703 *s = fS;
704 *x = fX;
705#endif
706 }
707 break;
708
710 RGBToHSY(color.redF(), color.greenF(), color.blueF(), &tempH, s, x);
711 break;
712 }
713
715 RGBToHSI(color.redF(), color.greenF(), color.blueF(), &tempH, s, x);
716 break;
717 }
718
719 default: // fallthrough
721 {
722#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
723 color.getHsvF(&tempH, s, x);
724#else
725 float th;
726 color.getHsvF(&th, &fS, &fX);
727 tempH = th;
728 *s = fS;
729 *x = fX;
730#endif
731 }
732 break;
733 }
734
735 if (tempH >= 0.0 && tempH <= 1.0) {
736 *h = tempH;
737 }
738}
float value(const T *src, size_t ch)
qreal v
QList< QString > QStringList
#define EPSILON
void HSYToRGB(const qreal h, const qreal s, const qreal y, qreal *red, qreal *green, qreal *blue, qreal R, qreal G, qreal B)
void RGBToHSI(qreal r, qreal g, qreal b, qreal *h, qreal *s, qreal *i)
void HSIToRGB(const qreal h, const qreal s, const qreal i, qreal *red, qreal *green, qreal *blue)
void RGBToHSY(const qreal r, const qreal g, const qreal b, qreal *h, qreal *s, qreal *y, qreal R, qreal G, qreal B)
const KoChannelInfo * m_channelInfo
KoColor * m_color
KisColorInput(QWidget *parent, const KoChannelInfo *, KoColor *color, KoColorDisplayRendererInterface *displayRenderer=KoDumbColorDisplayRenderer::instance(), bool usePercentage=false)
KoColorDisplayRendererInterface * m_displayRenderer
KoColorSlider * m_colorSlider
virtual QWidget * createInput()=0
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
void setValue(double value, bool overwriteExpression=false)
Set the value of the spinbox.
KisFloatColorInput(QWidget *parent, const KoChannelInfo *, KoColor *color, KoColorDisplayRendererInterface *displayRenderer=KoDumbColorDisplayRenderer::instance(), bool usePercentage=false)
QWidget * createInput() override
KisDoubleParseSpinBox * m_dblNumInput
KisHexColorInput(QWidget *parent, KoColor *color, KoColorDisplayRendererInterface *displayRenderer=KoDumbColorDisplayRenderer::instance(), bool usePercentage=false, bool usePreview=false)
QWidget * createInput() override
void textChanged(const QString &text)
QLineEdit * m_hexInput
KisDoubleParseSpinBox * m_sInput
void getHsxF(const QColor &color, qreal *h, qreal *s, qreal *x)
KisHsvColorSlider * m_xSlider
void setSaturation(double)
KisHsvColorSlider::MIX_MODE m_mixMode
KisHsvColorSlider * m_hSlider
KisDoubleParseSpinBox * m_xInput
void saturationSliderChanged(int)
KisHsvColorInput(QWidget *parent, KoColor *color)
KisHsvColorSlider * m_sSlider
void setMixMode(KisHsvColorSlider::MIX_MODE mixMode)
void fillColor(QColor &color)
KisDoubleParseSpinBox * m_hInput
The KisIntParseSpinBox class is a cleverer SpinBox, able to parse arithmetic expressions.
void setValue(int value, bool overwriteExpression=false)
Set the value of the spinbox.
QWidget * createInput() override
KisIntegerColorInput(QWidget *parent, const KoChannelInfo *, KoColor *color, KoColorDisplayRendererInterface *displayRenderer=KoDumbColorDisplayRenderer::instance(), bool usePercentage=false)
void setPercentageWise(bool val) override
KisIntParseSpinBox * m_intNumInput
@ COLOR
The channel represents a color.
qint32 size() const
qint32 pos() const
@ UINT8
use this for an unsigned integer 8bits channel
@ UINT16
use this for an integer 16bits channel
@ FLOAT32
use this for a float 32bits channel
@ FLOAT16
use this for a float 16bits channel
@ UINT32
use this for an unsigned integer 21bits channel
enumChannelType channelType() const
enumChannelValueType channelValueType() const
QString name() const
static QList< KoChannelInfo * > displayOrderSorted(const QList< KoChannelInfo * > &channels)
virtual qreal minVisibleFloatValue(const KoChannelInfo *chaninfo) const =0
virtual QColor toQColor(const KoColor &c, bool proofToPaintColors=false) const =0
virtual qreal maxVisibleFloatValue(const KoChannelInfo *chaninfo) const =0
QList< KoChannelInfo * > channels
virtual quint32 colorChannelCount() const =0
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
Definition KoColor.cpp:213
quint8 * data()
Definition KoColor.h:144
const KoColorSpace * colorSpace() const
return the current colorSpace
Definition KoColor.h:82
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
void setText(QSpinBox *spinBox, const QStringView textTemplate)
void setColors(const KoColor minColor, const KoColor maxColor)
void setMixMode(MIX_MODE mode)
void setColors(const KoColor &minColor, const KoColor &maxColor)