24#include <QDoubleSpinBox>
25#include <QRegularExpression>
26#include <QRegularExpressionValidator>
28#include <klocalizedstring.h>
43 QWidget(parent), m_channelInfo(channelInfo), m_color(color), m_displayRenderer(displayRenderer),
44 m_usePercentage(usePercentage)
50 QHBoxLayout* m_layout =
new QHBoxLayout(
this);
51 m_layout->setContentsMargins(0,0,0,0);
52 m_layout->setSpacing(1);
55 m_layout->addWidget(m_label);
58 m_colorSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
62 m_layout->addWidget(m_input);
66 KisColorInput(parent, channelInfo, color, displayRenderer, usePercentage)
76 *(
reinterpret_cast<quint8*
>(data)) =
v;
79 *(
reinterpret_cast<quint16*
>(data)) =
v;
82 *(
reinterpret_cast<quint32*
>(data)) =
v;
101 quint8
value = *(
reinterpret_cast<quint8*
>(data));
104 *(
reinterpret_cast<quint8*
>(dataMin)) = 0x0;
105 *(
reinterpret_cast<quint8*
>(dataMax)) = 0xFF;
109 quint16
value = *(
reinterpret_cast<quint16*
>(data));
112 *(
reinterpret_cast<quint16*
>(dataMin)) = 0x0;
113 *(
reinterpret_cast<quint16*
>(dataMax)) = 0xFFFF;
117 quint32
value = *(
reinterpret_cast<quint32*
>(data));
120 *(
reinterpret_cast<quint32*
>(dataMin)) = 0x0;
121 *(
reinterpret_cast<quint32*
>(dataMax)) = 0xFFFF'FFFF;
211 KisColorInput(parent, channelInfo, color, displayRenderer, usePercentage)
222 *(
reinterpret_cast<half*
>(data)) =
v;
226 *(
reinterpret_cast<float*
>(data)) =
v;
242 m_dblNumInput->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
252 value = *(
reinterpret_cast<half*
>(data));
256 value = *(
reinterpret_cast<float*
>(data));
289 value = *(
reinterpret_cast<half*
>(data));
292 *(
reinterpret_cast<half*
>(dataMin)) =
m_minValue;
293 *(
reinterpret_cast<half*
>(dataMax)) =
m_maxValue;
297 value = *(
reinterpret_cast<float*
>(data));
300 *(
reinterpret_cast<float*
>(dataMin)) =
m_minValue;
301 *(
reinterpret_cast<float*
>(dataMax)) =
m_maxValue;
315 int newPrecision = 2 + qMax(qreal(0.0), std::ceil(-std::log10(
m_maxValue)));
331 KisColorInput(parent, 0, color, displayRenderer, usePercentage)
333 QHBoxLayout* m_layout =
new QHBoxLayout(
this);
334 m_layout->setContentsMargins(0,0,0,0);
335 m_layout->setSpacing(1);
337 QLabel* m_label =
new QLabel(i18n(
"Color name:"),
this);
338 m_label->setMinimumWidth(50);
339 m_layout->addWidget(m_label);
342 m_input->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
350 m_layout->addWidget(m_input);
356 valueString.remove(QChar(
'#'));
365 int value = valueString.left(2).toInt(0, 16);
366 *(
reinterpret_cast<quint8*
>(data)) =
value;
367 valueString.remove(0, 2);
375 QString hexString(
"#");
383 hexString.append(QString(
"%1").arg(*(
reinterpret_cast<quint8*
>(data)), 2, 16, QChar(
'0')));
398 QString pattern = QString(
"#?[a-fA-F0-9]{%1,%2}").arg(digits).arg(digits);
399 m_hexInput->setValidator(
new QRegularExpressionValidator(QRegularExpression(pattern),
this));
421 i18nc(
"@label:slider Abbreviation for 'Hue'",
"H:"),
422 i18nc(
"@label:slider Abbreviation for 'Saturation'",
"S:"),
424 qreal maxValues[3] = { 360, 100, 100 };
426 QGridLayout *slidersLayout =
new QGridLayout(
this);
427 slidersLayout->setContentsMargins(0,0,0,0);
428 slidersLayout->setHorizontalSpacing(1);
430 for (
int i = 0; i < 3; i++) {
432 QLabel *label =
new QLabel(labelNames[i],
this);
433 slidersLayout->addWidget(label, i, 0);
438 slider->setMinimum(0);
439 slider->setMaximum(maxValues[i]);
440 slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
441 slidersLayout->addWidget(slider, i, 1);
445 input->setMinimum(0);
446 input->setMaximum(maxValues[i]);
448 input->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
449 input->setMinimumWidth(60);
450 input->setMaximumWidth(60);
452 slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
453 slidersLayout->addWidget(input, i, 2);
489 minC.setHsvF(0, 1, 1);
490 maxC.setHsvF(1, 1, 1);
501 m_xLabel->setText(i18nc(
"@label:slider Abbreviation for 'Lightness' of HSL color model",
"L:"));
504 m_xLabel->setText(i18nc(
"@label:slider Abbreviation for 'Luma' of HSY color model",
"Y:"));
507 m_xLabel->setText(i18nc(
"@label:slider Abbreviation for 'Intensity' of HSI color model",
"I:"));
511 m_xLabel->setText(i18nc(
"@label:slider Abbreviation for 'Value' of HSV color model",
"V:"));
552 x = qBound(0.0, x, 360.0);
560 x = qBound(0.0, x, 100.0);
568 x = qBound(0.0, x, 100.0);
593 minC.setHsvF(
m_h, 0,
m_x);
594 maxC.setHsvF(
m_h, 1,
m_x);
597 minC.setHsvF(
m_h,
m_s, 0);
598 maxC.setHsvF(
m_h,
m_s, 1);
617 if (!(current.red() == theirs.red() && current.green() == theirs.green() && current.blue() == theirs.blue())) {
657 r = qBound(0.0, r, 1.0);
658 g = qBound(0.0, g, 1.0);
659 b = qBound(0.0, b, 1.0);
682#if (QT_VERSION > QT_VERSION_CHECK(6, 0, 0))
689#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
690 color.getHslF(&tempH, s, x);
693 color.getHslF(&th, &fS, &fX);
700 RGBToHSY(color.redF(), color.greenF(), color.blueF(), &tempH, s, x);
705 RGBToHSI(color.redF(), color.greenF(), color.blueF(), &tempH, s, x);
712#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
713 color.getHsvF(&tempH, s, x);
716 color.getHsvF(&th, &fS, &fX);
723 if (tempH >= 0.0 && tempH <= 1.0) {
float value(const T *src, size_t ch)
QList< QString > QStringList
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)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
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.
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.
@ COLOR
The channel represents a color.
@ 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
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.
const KoColorSpace * colorSpace() const
return the current colorSpace
void toQColor(QColor *c) const
a convenience method for the above.
void setText(QSpinBox *spinBox, const QStringView textTemplate)
void setColors(const KoColor minColor, const KoColor maxColor)
void setCircularHue(bool)
void setMixMode(MIX_MODE mode)
void setColors(const KoColor &minColor, const KoColor &maxColor)