Commit 9dbb17d5 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Clean up of colour selector preferences and luma-configuration

This patch cleans up the big list of advanced colour selectors we have
by splitting them up in the four models availeble. It also gives a brief
explanation of each model.

Underneath that is the luma coefficients. This allows people to
configure how the HSY' selectors calculate luma. It's set defaultly to
rec 709.
parent b69e8669
......@@ -39,38 +39,43 @@ public:
QGridLayout* layout = new QGridLayout(this);
layout->setSpacing(spacing);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Triangle, KisColorSelector::Ring, KisColorSelector::SL , KisColorSelector::H), this), 0,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SL , KisColorSelector::H), this), 0,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SV , KisColorSelector::H), this), 0,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SV2, KisColorSelector::H), this), 0,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SI , KisColorSelector::H), this), 0,4);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SY , KisColorSelector::H), this), 0,5);
//qDebug()<<"Created list";
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Triangle, KisColorSelector::Ring, KisColorSelector::SL , KisColorSelector::H), this), 0,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SV , KisColorSelector::H), this), 0,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SV2, KisColorSelector::H), this), 0,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::VH, KisColorSelector::hsvS), this), 0,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hsvSH, KisColorSelector::V), this), 0,4);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SV2, KisColorSelector::H), this), 1,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SV, KisColorSelector::H), this), 1,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::VH, KisColorSelector::hsvS), this), 1,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::hsvSH, KisColorSelector::V), this), 1,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SV, KisColorSelector::H), this), 1,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SL, KisColorSelector::H), this), 1,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SV2, KisColorSelector::H), this), 1,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SI, KisColorSelector::H), this), 1,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SY, KisColorSelector::H), this), 1,4);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::VH, KisColorSelector::hsvS), this), 2,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::LH, KisColorSelector::hslS), this), 2,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::hsvSH, KisColorSelector::V), this), 2,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::hslSH, KisColorSelector::L), this), 2,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::IH, KisColorSelector::hsiS), this), 2,4);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::YH, KisColorSelector::hsyS), this), 2,5);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::VH, KisColorSelector::hsvS), this), 3,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::LH, KisColorSelector::hslS), this), 3,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hsvSH, KisColorSelector::V), this), 3,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hslSH, KisColorSelector::L), this), 3,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::IH, KisColorSelector::hsiS), this), 4,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::YH, KisColorSelector::hsyS), this), 4,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hsiSH, KisColorSelector::I), this), 4,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hsySH, KisColorSelector::Y), this), 4,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SL , KisColorSelector::H), this), 0,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::LH, KisColorSelector::hslS), this), 0,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hslSH, KisColorSelector::L), this), 0,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SL, KisColorSelector::H), this), 1,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::LH, KisColorSelector::hslS), this), 1,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::hslSH, KisColorSelector::L), this), 1,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SI , KisColorSelector::H), this), 0,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::IH, KisColorSelector::hsiS), this), 0,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hsiSH, KisColorSelector::I), this), 0,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SI, KisColorSelector::H), this), 1,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::IH, KisColorSelector::hsiS), this), 1,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::hsiSH, KisColorSelector::I), this), 1,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Ring, KisColorSelector::SY , KisColorSelector::H), this), 0,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::YH, KisColorSelector::hsyS), this), 0,2);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Wheel, KisColorSelector::Slider, KisColorSelector::hsySH, KisColorSelector::Y), this), 0,3);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::SY, KisColorSelector::H), this), 1,0);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::YH, KisColorSelector::hsyS), this), 1,1);
layout->addWidget(new KisColorSelector(KisColorSelector::Configuration(KisColorSelector::Square, KisColorSelector::Slider, KisColorSelector::hsySH, KisColorSelector::Y), this), 1,2);
setList(0);
for(int i=0; i<this->layout()->count(); i++) {
KisColorSelector* item = dynamic_cast<KisColorSelector*>(this->layout()->itemAt(i)->widget());
......@@ -84,8 +89,40 @@ public:
item->setDisplayBlip(false);
}
}
}
void setList(int model){
for(int i=1; i<layout()->count(); i++) {
layout()->itemAt(i)->widget()->hide();
}
if (model==0){
for(int i=1; i<9; i++) {
layout()->itemAt(i)->widget()->show();
}
}
if (model==1){
for(int i=9; i<15; i++) {
layout()->itemAt(i)->widget()->show();
}
}
if (model==2){
for(int i=15; i<21; i++) {
layout()->itemAt(i)->widget()->show();
}
}
if (model==3){
for(int i=21; i<layout()->count(); i++) {
layout()->itemAt(i)->widget()->show();
}
}
}
protected:
void paintEvent(QPaintEvent *)
{
......@@ -98,10 +135,12 @@ protected:
{
if(rect().contains(e->pos())) {
for(int i=0; i<layout()->count(); i++) {
KisColorSelector* item = dynamic_cast<KisColorSelector*>(layout()->itemAt(i)->widget());
Q_ASSERT(item);
if(item->geometry().adjusted(-spacing/2, -spacing/2, spacing/2, spacing/2).contains(e->pos())) {
if(layout()->itemAt(i)->widget()->isVisible()==true && item->geometry().adjusted(-spacing/2, -spacing/2, spacing/2, spacing/2).contains(e->pos())) {
QRect oldArea=highlightArea;
highlightArea=item->geometry().adjusted(-spacing/2, -spacing/2, spacing/2, spacing/2);
m_lastActiveConfiguration=item->configuration();
......@@ -121,17 +160,21 @@ protected:
KisColorSelectorComboBox* parent = dynamic_cast<KisColorSelectorComboBox*>(this->parent());
Q_ASSERT(parent);
parent->setConfiguration(m_lastActiveConfiguration);
setList(parent->m_model);
}
//qDebug()<<"mousepress";
hide();
e->accept();
}
KisColorSelector::Configuration m_lastActiveConfiguration;
};
KisColorSelectorComboBox::KisColorSelectorComboBox(QWidget* parent) :
QComboBox(parent),
m_private(new KisColorSelectorComboBoxPrivate(this)),
m_currentSelector(this)
m_currentSelector(this),
m_model(0)
{
QLayout* layout = new QGridLayout(this);
layout->addWidget(&m_currentSelector);
......@@ -193,3 +236,9 @@ void KisColorSelectorComboBox::setConfiguration(KisColorSelector::Configuration
m_currentSelector.setColor(KoColor(QColor(255,0,0), m_currentSelector.colorSpace()));
update();
}
void KisColorSelectorComboBox::setList(int model) {
m_model=model;
m_private->setList(m_model);
}
......@@ -34,11 +34,13 @@ public:
void hidePopup();
void showPopup();
KisColorSelector::Configuration configuration() const;
int m_model;
protected:
void paintEvent(QPaintEvent *e);
public slots:
void setColorSpace(const KoColorSpace* colorSpace);
void setConfiguration(KisColorSelector::Configuration);
void setList(int model);
private:
KisColorSelectorComboBoxPrivate* m_private;
KisColorSelector::Configuration m_configuration;
......
......@@ -45,13 +45,31 @@ KisColorSelectorSettings::KisColorSelectorSettings(QWidget *parent) :
ui->lbl_commonColorsNumCols->hide();
ui->commonColorsNumCols->hide();
if (ui->colorSelectorHSVtype->isChecked()==false){
ui->l_HSVtypeInfo->hide();
}
ui->l_HSLtypeInfo->hide();
ui->l_HSItypeInfo->hide();
ui->l_HSYtypeInfo->hide();
resize(minimumSize());
ui->colorSelectorConfiguration->setColorSpace(ui->colorSpace->currentColorSpace());
connect(ui->colorSpace, SIGNAL(colorSpaceChanged(const KoColorSpace*)),
ui->colorSelectorConfiguration, SLOT(setColorSpace(const KoColorSpace*)));
connect(ui->colorSelectorHSVtype, SIGNAL(toggled(bool)),
this, SLOT(hsxchange()));
connect(ui->colorSelectorHSLtype, SIGNAL(toggled(bool)),
this, SLOT(hsxchange()));
connect(ui->colorSelectorHSItype, SIGNAL(toggled(bool)),
this, SLOT(hsxchange()));
connect(ui->colorSelectorHSYtype, SIGNAL(toggled(bool)),
this, SLOT(hsxchange()));
connect(this, SIGNAL(hsxchanged(int)),
ui->colorSelectorConfiguration, SLOT(setList(int)));
connect(ui->minimalShadeSelectorLineCount, SIGNAL(valueChanged(int)),
ui->minimalShadeSelectorLineSettings, SLOT(setLineCount(int)));
......@@ -172,6 +190,22 @@ void KisColorSelectorSettings::savePreferences() const
KisColorSelectorComboBox* cstw = dynamic_cast<KisColorSelectorComboBox*>(ui->colorSelectorConfiguration);
cfg.writeEntry("colorSelectorConfiguration", cstw->configuration().toString());
QString hsxSettingType("HSV");
if(ui->colorSelectorHSLtype->isChecked())
hsxSettingType="HSL";
if(ui->colorSelectorHSItype->isChecked())
hsxSettingType="HSI";
if(ui->colorSelectorHSYtype->isChecked())
hsxSettingType="HSY";
cfg.writeEntry("hsxSettingType", hsxSettingType);
//luma//
cfg.writeEntry("lumaR", ui->l_lumaR->text());
cfg.writeEntry("lumaG", ui->l_lumaG->text());
cfg.writeEntry("lumaB", ui->l_lumaB->text());
//slider//
hsxcfg.writeEntry("hsvH", ui->csl_hsvH->isChecked());
hsxcfg.writeEntry("hsvS", ui->csl_hsvS->isChecked());
hsxcfg.writeEntry("hsvV", ui->csl_hsvV->isChecked());
......@@ -293,10 +327,20 @@ void KisColorSelectorSettings::loadPreferences()
ui->minimalShadeSelectorLineSettings->fromString(cfg.readEntry("minimalShadeSelectorLineConfig", "0|0.2|0|0|0|0|0;1|0|1|1|0|0|0;2|0|-1|1|0|0|0;"));
ui->minimalShadeSelectorLineHeight->setValue(cfg.readEntry("minimalShadeSelectorLineHeight", 10));
QString hsxSettingType=cfg.readEntry("hsxSettingType", "HSV");
ui->colorSelectorHSVtype->setChecked(hsxSettingType=="HSV");
ui->colorSelectorHSLtype->setChecked(hsxSettingType=="HSL");
ui->colorSelectorHSItype->setChecked(hsxSettingType=="HSI");
ui->colorSelectorHSYtype->setChecked(hsxSettingType=="HSY");
//color selector
KisColorSelectorComboBox* cstw = dynamic_cast<KisColorSelectorComboBox*>(ui->colorSelectorConfiguration);
cstw->setConfiguration(KisColorSelector::Configuration::fromString(cfg.readEntry("colorSelectorConfiguration", "3|0|5|0"))); // triangle selector
//luma values//
ui->l_lumaR->setText(cfg.readEntry("lumaR", "0.2126"));
ui->l_lumaG->setText(cfg.readEntry("lumaG", "0.7152"));
ui->l_lumaB->setText(cfg.readEntry("lumaB", "0.0722"));
//color sliders//
ui->csl_hsvH->setChecked(hsxcfg.readEntry("hsvH", false));
ui->csl_hsvS->setChecked(hsxcfg.readEntry("hsvS", false));
......@@ -379,9 +423,19 @@ void KisColorSelectorSettings::loadDefaultPreferences()
ui->minimalShadeSelectorLineHeight->setValue(10);
//color selector
ui->colorSelectorHSVtype->setChecked(true);
ui->colorSelectorHSVtype->setChecked(false);
ui->colorSelectorHSVtype->setChecked(false);
ui->colorSelectorHSVtype->setChecked(false);
KisColorSelectorComboBox* cstw = dynamic_cast<KisColorSelectorComboBox*>(ui->colorSelectorConfiguration);
cstw->setConfiguration(KisColorSelector::Configuration("3|0|5|0")); // triangle selector
//luma//
ui->l_lumaR->setText("0.2126");
ui->l_lumaG->setText("0.7152");
ui->l_lumaB->setText("0.0722");
//color sliders//
ui->csl_hsvH->setChecked(false);
ui->csl_hsvS->setChecked(false);
......@@ -397,6 +451,19 @@ void KisColorSelectorSettings::loadDefaultPreferences()
ui->csl_hsyY->setChecked(false);
}
void KisColorSelectorSettings::hsxchange() {
int hsxSettingType=0;
if(ui->colorSelectorHSLtype->isChecked())
hsxSettingType=1;
if(ui->colorSelectorHSItype->isChecked())
hsxSettingType=2;
if(ui->colorSelectorHSYtype->isChecked())
hsxSettingType=3;
emit hsxchanged(hsxSettingType);
}
KisColorSelectorSettingsDialog::KisColorSelectorSettingsDialog(QWidget *parent) :
QDialog(parent),
m_widget(new KisColorSelectorSettings(this))
......@@ -418,3 +485,5 @@ KisColorSelectorSettingsDialog::KisColorSelectorSettingsDialog(QWidget *parent)
SIGNAL(clicked()), m_widget, SLOT(loadDefaultPreferences()));
}
......@@ -44,12 +44,14 @@ public slots:
void savePreferences() const;
void loadPreferences();
void loadDefaultPreferences();
void hsxchange();
signals:
void settingsChanged() const;
void hsxchanged(int);
protected:
// void changeEvent(QEvent *e);
//void changeEvent(QEvent *e);
private:
Ui::KisColorSelectorSettings *ui;
......
......@@ -20,6 +20,10 @@
#include <QPainter>
#include <QColor>
#include <cmath>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kcomponentdata.h>
#include <kglobal.h>
#include "kis_display_color_converter.h"
#include "kis_acs_pixel_cache_renderer.h"
......@@ -120,12 +124,15 @@ void KisColorSelectorSimple::setColor(const KoColor &color)
qreal hslH, hslS, hslL;
qreal hsiH, hsiS, hsiI;
qreal hsyH, hsyS, hsyY;
KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
R = cfg.readEntry("lumaR", 0.2126);
G = cfg.readEntry("lumaG", 0.7152);
B = cfg.readEntry("lumaB", 0.0722);
m_parent->converter()->getHsvF(color, &hsvH, &hsvS, &hsvV);
m_parent->converter()->getHslF(color, &hslH, &hslS, &hslL);
//here we add our convertor options
m_parent->converter()->getHsiF(color, &hsiH, &hsiS, &hsiI);
m_parent->converter()->getHsyF(color, &hsyH, &hsyS, &hsyY);
m_parent->converter()->getHsyF(color, &hsyH, &hsyS, &hsyY, R, G, B);
//workaround, for some reason the HSI and HSY algorithms are fine, but they don't seem to update the selectors properly.
hsiH=hslH;
......@@ -344,7 +351,7 @@ KoColor KisColorSelectorSimple::colorAt(int x, int y)
color = m_parent->converter()->fromHsiF(m_hue, xRel, yRel);
break;
case KisColorSelector::SY:
color = m_parent->converter()->fromHsyF(m_hue, xRel, yRel);
color = m_parent->converter()->fromHsyF(m_hue, xRel, yRel, R, G, B);
break;
case KisColorSelector::hsvSH:
color = m_parent->converter()->fromHsvF(xRel, yRel, m_value);
......@@ -356,7 +363,7 @@ KoColor KisColorSelectorSimple::colorAt(int x, int y)
color = m_parent->converter()->fromHsiF(xRel, yRel, m_intensity);
break;
case KisColorSelector::hsySH:
color = m_parent->converter()->fromHsyF(xRel, yRel, m_luma);
color = m_parent->converter()->fromHsyF(xRel, yRel, m_luma, R, G, B);
break;
case KisColorSelector::VH:
color = m_parent->converter()->fromHsvF(xRel, m_hsvSaturation, yRel);
......@@ -368,7 +375,7 @@ KoColor KisColorSelectorSimple::colorAt(int x, int y)
color = m_parent->converter()->fromHsiF(xRel, m_hsiSaturation, yRel);
break;
case KisColorSelector::YH:
color = m_parent->converter()->fromHsyF(xRel, m_hsySaturation, yRel);
color = m_parent->converter()->fromHsyF(xRel, m_hsySaturation, yRel, R, G, B);
break;
case KisColorSelector::H:
color = m_parent->converter()->fromHsvF(relPos, 1, 1);
......@@ -392,10 +399,10 @@ KoColor KisColorSelectorSimple::colorAt(int x, int y)
color = m_parent->converter()->fromHsiF(m_hue, m_hsiSaturation, relPos);
break;
case KisColorSelector::hsyS:
color = m_parent->converter()->fromHsyF(m_hue, relPos, m_luma);
color = m_parent->converter()->fromHsyF(m_hue, relPos, m_luma, R, G, B);
break;
case KisColorSelector::Y:
color = m_parent->converter()->fromHsyF(m_hue, m_hsySaturation, relPos);
color = m_parent->converter()->fromHsyF(m_hue, m_hsySaturation, relPos, R, G, B);
break;
default:
Q_ASSERT(false);
......
......@@ -49,6 +49,9 @@ private:
private:
QPointF m_lastClickPos;
QImage m_pixelCache;
qreal R;
qreal G;
qreal B;
};
#endif
......@@ -21,6 +21,10 @@
#include <QPainter>
#include <QColor>
#include <cmath>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kcomponentdata.h>
#include <kglobal.h>
#include "kis_display_color_converter.h"
#include "kis_acs_pixel_cache_renderer.h"
......@@ -94,10 +98,14 @@ void KisColorSelectorWheel::setColor(const KoColor &color)
qreal hslH, hslS, hslL;
qreal hsiH, hsiS, hsiI;
qreal hsyH, hsyS, hsyY;
KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
R = cfg.readEntry("lumaR", 0.2126);
G = cfg.readEntry("lumaG", 0.7152);
B = cfg.readEntry("lumaB", 0.0722);
m_parent->converter()->getHsvF(color, &hsvH, &hsvS, &hsvV);
m_parent->converter()->getHslF(color, &hslH, &hslS, &hslL);
m_parent->converter()->getHsiF(color, &hsiH, &hsiS, &hsiI);
m_parent->converter()->getHsyF(color, &hsyH, &hsyS, &hsyY);
m_parent->converter()->getHsyF(color, &hsyH, &hsyS, &hsyY, R, G, B);
//workaround, for some reason the HSI and HSY algorithms are fine, but they don't seem to update the selectors properly.
hsiH=hslH;
......@@ -225,7 +233,6 @@ KoColor KisColorSelectorWheel::colorAt(int x, int y, bool forceValid)
angle += M_PI;
angle /= 2 * M_PI;
switch(m_parameter) {
case KisColorSelector::hsvSH:
color = m_parent->converter()->fromHsvF(angle, radius, m_value);
......@@ -237,7 +244,7 @@ KoColor KisColorSelectorWheel::colorAt(int x, int y, bool forceValid)
color = m_parent->converter()->fromHsiF(angle, radius, m_intensity);
break;
case KisColorSelector::hsySH:
color = m_parent->converter()->fromHsyF(angle, radius, m_luma);
color = m_parent->converter()->fromHsyF(angle, radius, m_luma, R, G, B);
break;
case KisColorSelector::VH:
color = m_parent->converter()->fromHsvF(angle, m_hsvSaturation, radius);
......@@ -249,7 +256,7 @@ KoColor KisColorSelectorWheel::colorAt(int x, int y, bool forceValid)
color = m_parent->converter()->fromHsiF(angle, m_hsiSaturation, radius);
break;
case KisColorSelector::YH:
color = m_parent->converter()->fromHsyF(angle, m_hsySaturation, radius);
color = m_parent->converter()->fromHsyF(angle, m_hsySaturation, radius, R, G, B);
break;
default:
Q_ASSERT(false);
......
......@@ -49,6 +49,9 @@ private:
QPointF m_lastClickPos;
QImage m_pixelCache;
QPoint m_pixelCacheOffset;
qreal R;
qreal G;
qreal B;
};
#endif // KIS_COLOR_SELECTOR_WHEEL_H
......@@ -80,7 +80,7 @@ void KisMyPaintShadeSelector::paintEvent(QPaintEvent *) {
KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
QString shadeMyPaintType=cfg.readEntry("shadeMyPaintType", "HSV");
int size = qMin(width(), height());
int s_radius = size/2.6;
......@@ -156,7 +156,7 @@ void KisMyPaintShadeSelector::paintEvent(QPaintEvent *) {
if(shadeMyPaintType=="HSV"){color = converter()->fromHsvF(fh, fs, fv);}
else if(shadeMyPaintType=="HSL"){color = converter()->fromHslF(fh, fs, fv);}
else if(shadeMyPaintType=="HSI"){color = converter()->fromHsiF(fh, fs, fv);}
else if(shadeMyPaintType=="HSY"){color = converter()->fromHsyF(fh, fs, fv);}
else if(shadeMyPaintType=="HSY"){color = converter()->fromHsyF(fh, fs, fv, R, G, B);}
else{qDebug()<<"MyPaint Color selector don't work right.";
color = converter()->fromHsvF(fh, fs, fv);}
//qDebug()<<color->toQcolor();
......@@ -253,10 +253,15 @@ void KisMyPaintShadeSelector::setColor(const KoColor &color) {
KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
QString shadeMyPaintType=cfg.readEntry("shadeMyPaintType", "HSV");
R = cfg.readEntry("lumaR", 0.2126);
G = cfg.readEntry("lumaG", 0.7152);
B = cfg.readEntry("lumaB", 0.0722);
if(shadeMyPaintType=="HSV"){this->converter()->getHsvF(color, &m_colorH, &m_colorS, &m_colorV);}
if(shadeMyPaintType=="HSL"){this->converter()->getHslF(color, &m_colorH, &m_colorS, &m_colorV);}
if(shadeMyPaintType=="HSI"){this->converter()->getHsiF(color, &m_colorH, &m_colorS, &m_colorV);}
if(shadeMyPaintType=="HSY"){this->converter()->getHsyF(color, &m_colorH, &m_colorS, &m_colorV);}
if(shadeMyPaintType=="HSY"){this->converter()->getHsyF(color, &m_colorH, &m_colorS, &m_colorV, R, G, B);}
m_lastRealColor = color;
this->updateColorPreview(color);
......
......@@ -52,7 +52,7 @@ protected:
private:
qreal m_colorH, m_colorS, m_colorV;
qreal R, G, B;
QTimer* m_updateTimer;
KoColor m_lastRealColor;
KisPaintDeviceSP m_realPixelCache;
......
......@@ -32,6 +32,9 @@
#include <QFontMetrics>
#include <klocale.h>
#include <kconfiggroup.h>
#include <kcomponentdata.h>
#include <kglobal.h>
#include <QDoubleSpinBox>
......@@ -104,6 +107,10 @@ void KisHSXColorSliderInput::setValue(double v)
qreal h=0.0;
qreal s=0.0;
qreal l=0.0;
KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector");
R = cfg.readEntry("lumaR", 0.2126);
G = cfg.readEntry("lumaG", 0.7152);
B = cfg.readEntry("lumaB", 0.0722);
switch (m_type) {
case 0:
......@@ -150,7 +157,7 @@ void KisHSXColorSliderInput::setValue(double v)
h=m_hue/360.0f;
s=m_sat/100.0f;
l=m_val/100.0f;
*m_color = this->converter()->fromHsyF(h, s, l);
*m_color = this->converter()->fromHsyF(h, s, l, R, G, B);
if (m_hueupdating==false) {
emit(hueUpdated(static_cast<int>(m_hue)));
}
......@@ -205,14 +212,14 @@ void KisHSXColorSliderInput::setValue(double v)
h=m_hue/360.0f;
s=m_sat/100.0f;
l=m_val/100.0f;
*m_color = this->converter()->fromHsyF(h, s, l);
*m_color = this->converter()->fromHsyF(h, s, l, R, G, B);