[PATCH] Added a color selector mode.
Silvio Heinrich
plassy at web.de
Tue Jan 11 04:41:50 CET 2011
In this mode it should be easier to see and pick a color in relationship
to lightness, darkness and value.
---
.../dockers/colorselectorng/kis_color_selector.h | 2 +-
.../kis_color_selector_combo_box.cpp | 9 +++++----
.../colorselectorng/kis_color_selector_simple.cpp | 19 +++++++++++++++++++
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector.h b/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector.h
index bc74c84..def417b 100644
--- a/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector.h
+++ b/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector.h
@@ -33,7 +33,7 @@ class KisColorSelector : public KisColorSelectorBase
Q_OBJECT
public:
enum Type {Ring, Square, Wheel, Triangle, Slider};
- enum Parameters {H, hsvS, V, hslS, L, SL, SV, hsvSH, hslSH, VH, LH};
+ enum Parameters {H, hsvS, V, hslS, L, SL, SV, SV2, hsvSH, hslSH, VH, LH};
struct Configuration {
Type mainType;
Type subType;
diff --git a/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_combo_box.cpp b/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_combo_box.cpp
index de6b347..0940b9c 100644
--- a/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_combo_box.cpp
+++ b/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_combo_box.cpp
@@ -41,10 +41,11 @@ 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::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::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);
diff --git a/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_simple.cpp b/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_simple.cpp
index a13c1af..8de334e 100644
--- a/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_simple.cpp
+++ b/krita/plugins/extensions/dockers/colorselectorng/kis_color_selector_simple.cpp
@@ -32,6 +32,9 @@ KisColorSelectorSimple::KisColorSelectorSimple(KisColorSelector *parent) :
void KisColorSelectorSimple::setColor(const QColor &c)
{
+ QColor color;
+ color.setHsvF(c.hslHueF(), 1.0, 1.0);
+
switch (m_parameter) {
case KisColorSelector::SL:
m_lastClickPos.setX(c.hslSaturationF());
@@ -48,6 +51,14 @@ void KisColorSelectorSimple::setColor(const QColor &c)
m_lastClickPos.setY(1-c.valueF());
emit paramChanged(-1, c.saturationF(), c.valueF(), -1, -1);
break;
+ case KisColorSelector::SV2: {
+ qreal xRel = c.hsvSaturationF();
+ qreal yRel = 1.0 - qBound<qreal>(0.0, (c.valueF() - xRel) / (1.0 - xRel), 1.0);
+ m_lastClickPos.setX(xRel);
+ m_lastClickPos.setY(yRel);
+ emit paramChanged(-1, -1, -1, xRel, yRel);
+ break;
+ }
case KisColorSelector::VH:
m_lastClickPos.setX(qBound<qreal>(0., c.hueF(), 1.));
m_lastClickPos.setY(c.valueF());
@@ -124,6 +135,7 @@ QColor KisColorSelectorSimple::selectColor(int x, int y)
case KisColorSelector::SL:
emit paramChanged(-1, -1, -1, xRel, yRel);
break;
+ case KisColorSelector::SV2:
case KisColorSelector::SV:
emit paramChanged(-1, xRel, yRel, -1, -1);
break;
@@ -188,6 +200,7 @@ void KisColorSelectorSimple::paint(QPainter* painter)
break;
case KisColorSelector::SL:
case KisColorSelector::SV:
+ case KisColorSelector::SV2:
case KisColorSelector::hslSH:
case KisColorSelector::hsvSH:
case KisColorSelector::VH:
@@ -217,6 +230,9 @@ const QColor& KisColorSelectorSimple::colorAt(int x, int y)
else
relPos = 1.-x/qreal(width());
+ QColor color;
+ color.setHsvF(m_hue, 1.0, 1.0);
+
switch(m_parameter) {
case KisColorSelector::SL:
m_qcolor.setHslF(m_hue, xRel, yRel);
@@ -224,6 +240,9 @@ const QColor& KisColorSelectorSimple::colorAt(int x, int y)
case KisColorSelector::SV:
m_qcolor.setHsvF(m_hue, xRel, yRel);
break;
+ case KisColorSelector::SV2:
+ m_qcolor.setHsvF(m_hue, xRel, xRel + (1.0-xRel)*yRel);
+ break;
case KisColorSelector::hsvSH:
m_qcolor.setHsvF(xRel, yRel, m_value);
break;
--
1.7.1
--------------000505050504050905000800--
More information about the kimageshop
mailing list