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

Fix updating in modal dialog.

Also add an extra check for 8bit so we can be a bit more precise in 16bit and higher.

Ref T2438
parent cdd0cd6a
...@@ -73,9 +73,10 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo ...@@ -73,9 +73,10 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo
m_ui->visualSelector->slotSetColor(color); m_ui->visualSelector->slotSetColor(color);
m_ui->visualSelector->setDisplayRenderer(displayRenderer); m_ui->visualSelector->setDisplayRenderer(displayRenderer);
m_ui->visualSelector->setConfig(false, config.modal);
if (config.visualColorSelector) { if (config.visualColorSelector) {
connect(m_ui->visualSelector, SIGNAL(sigNewColor(KoColor)), this, SLOT(slotColorUpdated(KoColor))); connect(m_ui->visualSelector, SIGNAL(sigNewColor(KoColor)), this, SLOT(slotColorUpdated(KoColor)));
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_ui->visualSelector, SLOT(ConfigurationChanged())); connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_ui->visualSelector, SLOT(ConfigurationChanged()));
} else { } else {
m_ui->visualSelector->hide(); m_ui->visualSelector->hide();
} }
...@@ -98,8 +99,8 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo ...@@ -98,8 +99,8 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo
} }
} }
if (config.paletteBox) { if (config.paletteBox) {
connect(m_ui->paletteBox, SIGNAL(colorChanged(KoColor,bool)), this, SLOT(slotColorUpdated(KoColor))); connect(m_ui->paletteBox, SIGNAL(colorChanged(KoColor,bool)), this, SLOT(slotColorUpdated(KoColor)));
m_ui->paletteBox->setDisplayRenderer(displayRenderer); m_ui->paletteBox->setDisplayRenderer(displayRenderer);
} else { } else {
m_ui->paletteBox->hide(); m_ui->paletteBox->hide();
} }
......
...@@ -45,6 +45,8 @@ struct KisVisualColorSelector::Private ...@@ -45,6 +45,8 @@ struct KisVisualColorSelector::Private
const KoColorSpace *currentCS; const KoColorSpace *currentCS;
QList <KisVisualColorSelectorShape*> widgetlist; QList <KisVisualColorSelectorShape*> widgetlist;
bool updateSelf = false; bool updateSelf = false;
bool updateLonesome = false; //for Modal dialogs.
bool circular = false;
const KoColorDisplayRendererInterface *displayRenderer = 0; const KoColorDisplayRendererInterface *displayRenderer = 0;
KisVisualColorSelector::Configuration acs_config; KisVisualColorSelector::Configuration acs_config;
//Current coordinates. //Current coordinates.
...@@ -76,7 +78,7 @@ void KisVisualColorSelector::slotSetColor(KoColor c) ...@@ -76,7 +78,7 @@ void KisVisualColorSelector::slotSetColor(KoColor c)
slotsetColorSpace(c.colorSpace()); slotsetColorSpace(c.colorSpace());
} }
} }
updateSelectorElements(); updateSelectorElements(QObject::sender());
} }
void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs) void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs)
...@@ -89,6 +91,12 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs) ...@@ -89,6 +91,12 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs)
} }
void KisVisualColorSelector::setConfig(bool forceCircular, bool forceSelfUpdate)
{
m_d->updateLonesome = forceSelfUpdate;
m_d->circular = forceCircular;
}
void KisVisualColorSelector::ConfigurationChanged() void KisVisualColorSelector::ConfigurationChanged()
{ {
m_d->updateTimer = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this); m_d->updateTimer = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this);
...@@ -211,21 +219,28 @@ void KisVisualColorSelector::slotRebuildSelectors() ...@@ -211,21 +219,28 @@ void KisVisualColorSelector::slotRebuildSelectors()
} }
KisVisualColorSelectorShape *bar; KisVisualColorSelectorShape *bar;
if (m_d->acs_config.subType==Ring) { if (m_d->acs_config.subType==Ring) {
bar = new KisVisualEllipticalSelectorShape(this, bar = new KisVisualEllipticalSelectorShape(this,
KisVisualColorSelectorShape::onedimensional, KisVisualColorSelectorShape::onedimensional,
modelS, modelS,
m_d->currentCS, channel1, channel1, m_d->currentCS, channel1, channel1,
m_d->displayRenderer, borderWidth,KisVisualEllipticalSelectorShape::border); m_d->displayRenderer, borderWidth,KisVisualEllipticalSelectorShape::border);
bar->resize(sizeValue, sizeValue); bar->resize(sizeValue, sizeValue);
} else if (m_d->acs_config.subType==Slider) { } else if (m_d->acs_config.subType==Slider && m_d->circular==false) {
bar = new KisVisualRectangleSelectorShape(this, bar = new KisVisualRectangleSelectorShape(this,
KisVisualRectangleSelectorShape::onedimensional, KisVisualColorSelectorShape::onedimensional,
modelS, modelS,
m_d->currentCS, channel1, channel2, m_d->currentCS, channel1, channel1,
m_d->displayRenderer, borderWidth); m_d->displayRenderer, borderWidth);
bar->setMaximumWidth(borderWidth); bar->setMaximumWidth(borderWidth);
bar->setMinimumWidth(borderWidth); bar->setMinimumWidth(borderWidth);
bar->setMinimumHeight(sizeValue); bar->setMinimumHeight(sizeValue);
} else if (m_d->acs_config.subType==Slider && m_d->circular==true) {
bar = new KisVisualEllipticalSelectorShape(this,
KisVisualColorSelectorShape::onedimensional,
modelS,
m_d->currentCS, channel1, channel1,
m_d->displayRenderer, borderWidth, KisVisualEllipticalSelectorShape::borderMirrored);
bar->resize(sizeValue, sizeValue);
} }
bar->setColor(m_d->currentcolor); bar->setColor(m_d->currentcolor);
...@@ -234,21 +249,21 @@ void KisVisualColorSelector::slotRebuildSelectors() ...@@ -234,21 +249,21 @@ void KisVisualColorSelector::slotRebuildSelectors()
KisVisualColorSelectorShape *block; KisVisualColorSelectorShape *block;
if (m_d->acs_config.mainType==Triangle) { if (m_d->acs_config.mainType==Triangle) {
block = new KisVisualTriangleSelectorShape(this, KisVisualColorSelectorShape::twodimensional, block = new KisVisualTriangleSelectorShape(this, KisVisualColorSelectorShape::twodimensional,
modelS, modelS,
m_d->currentCS, channel2, channel3, m_d->currentCS, channel2, channel3,
m_d->displayRenderer); m_d->displayRenderer);
block->setGeometry(bar->getSpaceForTriangle(newrect)); block->setGeometry(bar->getSpaceForTriangle(newrect));
} else if (m_d->acs_config.mainType==Square) { } else if (m_d->acs_config.mainType==Square) {
block = new KisVisualRectangleSelectorShape(this, KisVisualColorSelectorShape::twodimensional, block = new KisVisualRectangleSelectorShape(this, KisVisualColorSelectorShape::twodimensional,
modelS, modelS,
m_d->currentCS, channel2, channel3, m_d->currentCS, channel2, channel3,
m_d->displayRenderer); m_d->displayRenderer);
block->setGeometry(bar->getSpaceForSquare(newrect)); block->setGeometry(bar->getSpaceForSquare(newrect));
} else { } else {
block = new KisVisualEllipticalSelectorShape(this, KisVisualColorSelectorShape::twodimensional, block = new KisVisualEllipticalSelectorShape(this, KisVisualColorSelectorShape::twodimensional,
modelS, modelS,
m_d->currentCS, channel2, channel3, m_d->currentCS, channel2, channel3,
m_d->displayRenderer); m_d->displayRenderer);
block->setGeometry(bar->getSpaceForCircle(newrect)); block->setGeometry(bar->getSpaceForCircle(newrect));
} }
...@@ -289,7 +304,7 @@ void KisVisualColorSelector::setDisplayRenderer (const KoColorDisplayRendererInt ...@@ -289,7 +304,7 @@ void KisVisualColorSelector::setDisplayRenderer (const KoColorDisplayRendererInt
} }
} }
void KisVisualColorSelector::updateSelectorElements() void KisVisualColorSelector::updateSelectorElements(QObject *source)
{ {
//first lock all elements from sending updates, then update all elements. //first lock all elements from sending updates, then update all elements.
Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) {
...@@ -297,10 +312,12 @@ void KisVisualColorSelector::updateSelectorElements() ...@@ -297,10 +312,12 @@ void KisVisualColorSelector::updateSelectorElements()
} }
Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) {
if (m_d->updateSelf==false) { if (shape!=source) {
shape->setColor(m_d->currentcolor); if (m_d->updateSelf) {
} else { shape->setColorFromSibling(m_d->currentcolor);
shape->setColorFromSibling(m_d->currentcolor); } else {
shape->setColor(m_d->currentcolor);
}
} }
} }
Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) {
...@@ -312,8 +329,12 @@ void KisVisualColorSelector::updateSelectorElements() ...@@ -312,8 +329,12 @@ void KisVisualColorSelector::updateSelectorElements()
void KisVisualColorSelector::updateFromWidgets(KoColor c) void KisVisualColorSelector::updateFromWidgets(KoColor c)
{ {
m_d->currentcolor = c; m_d->currentcolor = c;
Q_EMIT sigNewColor(c);
m_d->updateSelf = true; m_d->updateSelf = true;
if (m_d->updateLonesome) {
slotSetColor(c);
} else {
Q_EMIT sigNewColor(c);
}
} }
void KisVisualColorSelector::leaveEvent(QEvent *) void KisVisualColorSelector::leaveEvent(QEvent *)
...@@ -813,7 +834,13 @@ QVector <qreal> KisVisualColorSelectorShape::getHSX(QVector<qreal> hsx, bool wra ...@@ -813,7 +834,13 @@ QVector <qreal> KisVisualColorSelectorShape::getHSX(QVector<qreal> hsx, bool wra
{ {
QVector <qreal> ihsx = hsx; QVector <qreal> ihsx = hsx;
if (!wrangler){ if (!wrangler){
if (hsx[2]>m_d->tone-0.01 && hsx[2]<m_d->tone+0.01) { //Ok, so this docker will not update luminosity if there's not at the least 3% more variation.
//This is necessary for 8bit.
if (m_d->cs->colorDepthId()==Integer8BitsColorDepthID){
if (hsx[2]>m_d->tone-0.03 && hsx[2]<m_d->tone+0.03) {
ihsx[2] = m_d->tone;
}
} else {
ihsx[2] = m_d->tone; ihsx[2] = m_d->tone;
} }
if (m_d->model==HSV){ if (m_d->model==HSV){
......
...@@ -95,6 +95,15 @@ public: ...@@ -95,6 +95,15 @@ public:
explicit KisVisualColorSelector(QWidget *parent = 0); explicit KisVisualColorSelector(QWidget *parent = 0);
~KisVisualColorSelector(); ~KisVisualColorSelector();
/**
* @brief setConfig
* @param forceCircular
* Force circular is for space where you only have room for a circular selector.
* @param forceSelfUpdate
* force self-update is for making it update itself when using a modal dialog.
*/
void setConfig(bool forceCircular, bool forceSelfUpdate);
Q_SIGNALS: Q_SIGNALS:
void sigNewColor(KoColor c); void sigNewColor(KoColor c);
...@@ -115,7 +124,7 @@ private: ...@@ -115,7 +124,7 @@ private:
struct Private; struct Private;
const QScopedPointer<Private> m_d; const QScopedPointer<Private> m_d;
void updateSelectorElements(); void updateSelectorElements(QObject *source);
void drawGradients(); void drawGradients();
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment