Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 0c2489c6 authored by Mathias Wein's avatar Mathias Wein

Adjust the popup palette selector on display renderer changes

When the color space of a document or current layer changes,
the color selector did not react to this.

After a lot of brain racking I came to the conclusion that the
most sane solution is to make color space changes explicit
for KisVisualColorSelector, and pass it the original
foreground color again.
Changing color space was added to KisColorSelectorInterface too.

More implicit behavior and assumptions about expected outcome
seem counterproductive at this point.

(cherry picked from commit 7c897c282e3524db8e75ec9f276852c8583e3c1b)
parent 733afddd
......@@ -159,6 +159,7 @@ KisPopupPalette::KisPopupPalette(KisViewManager* viewManager, KisCoordinatesConv
SLOT(slotEmitColorChanged()));
connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), m_triangleColorSelector, SLOT(configurationChanged()));
connect(m_displayRenderer, SIGNAL(displayConfigurationChanged()), this, SLOT(slotDisplayConfigurationChanged()));
m_acyclicConnector->connectForwardKoColor(m_resourceManager, SIGNAL(sigChangeFGColorSelector(KoColor)),
this, SLOT(slotExternalFgColorChanged(KoColor)));
......@@ -274,16 +275,22 @@ KisPopupPalette::KisPopupPalette(KisViewManager* viewManager, KisCoordinatesConv
setAttribute(Qt::WA_NoMousePropagation, true);
}
void KisPopupPalette::slotExternalFgColorChanged(const KoColor &color)
void KisPopupPalette::slotDisplayConfigurationChanged()
{
// Visual Color Selector picks up color space from input
KoColor col = m_viewManager->canvasResourceProvider()->fgColor();
const KoColorSpace *paintingCS = m_displayRenderer->getPaintingColorSpace();
//hack to get around cmyk for now.
if (color.colorSpace()->colorChannelCount()>3) {
KoColor c(KoColorSpaceRegistry::instance()->rgb8());
c.fromKoColor(color);
m_triangleColorSelector->slotSetColor(c);
} else {
m_triangleColorSelector->slotSetColor(color);
if (paintingCS->colorChannelCount()>3) {
paintingCS = KoColorSpaceRegistry::instance()->rgb8();
}
m_triangleColorSelector->slotSetColorSpace(paintingCS);
m_triangleColorSelector->slotSetColor(col);
}
void KisPopupPalette::slotExternalFgColorChanged(const KoColor &color)
{
m_triangleColorSelector->slotSetColor(color);
}
void KisPopupPalette::slotEmitColorChanged()
......
......@@ -170,6 +170,7 @@ public Q_SLOTS:
void slotUpdateIcons();
private Q_SLOTS:
void slotDisplayConfigurationChanged();
void slotExternalFgColorChanged(const KoColor &color);
void slotEmitColorChanged();
void slotSetSelectedColor(int x) { setSelectedColor(x); update(); }
......
......@@ -18,3 +18,8 @@
*/
#include <KisColorSelectorInterface.h>
void KisColorSelectorInterface::slotSetColorSpace(const KoColorSpace *cs)
{
Q_UNUSED(cs)
}
......@@ -26,6 +26,7 @@
#include <KoColor.h>
class KoColorDisplayRendererInterface;
class KoColorSpace;
class KRITAWIDGETS_EXPORT KisColorSelectorInterface : public QWidget {
Q_OBJECT
......@@ -51,6 +52,16 @@ Q_SIGNALS:
public Q_SLOTS:
virtual void slotSetColor(const KoColor &c) = 0;
/**
* @brief slotSetColorSpace
* Set the color space the selector should cover
*
* This is mostly a hint to decide visual presentation.
* Internal processing may be in a different color space and
* input conversion shall be handled by the selector itself.
* Calling this voids the currently selected color.
*/
virtual void slotSetColorSpace(const KoColorSpace *cs);
};
#endif // KISCOLORSELECTORINTERFACE_H
......@@ -197,10 +197,10 @@ void KisDlgInternalColorSelector::slotColorUpdated(KoColor newColor)
if (m_d->lockUsedCS){
newColor.convertTo(m_d->currentColorSpace);
m_d->currentColor = newColor;
} else {
m_d->currentColor = newColor;
colorSpaceChanged(newColor.colorSpace());
}
m_d->currentColor = newColor;
updateAllElements(QObject::sender());
}
}
......@@ -218,7 +218,7 @@ void KisDlgInternalColorSelector::colorSpaceChanged(const KoColorSpace *cs)
m_d->currentColorSpace = KoColorSpaceRegistry::instance()->colorSpace(cs->colorModelId().id(), cs->colorDepthId().id(), cs->profile());
m_ui->spinboxselector->slotSetColorSpace(m_d->currentColorSpace);
m_ui->visualSelector->slotsetColorSpace(m_d->currentColorSpace);
m_ui->visualSelector->slotSetColorSpace(m_d->currentColorSpace);
}
......@@ -228,6 +228,7 @@ void KisDlgInternalColorSelector::lockUsedColorSpace(const KoColorSpace *cs)
if (m_d->currentColor.colorSpace() != m_d->currentColorSpace) {
m_d->currentColor.convertTo(m_d->currentColorSpace);
m_ui->spinboxselector->slotSetColor(m_d->currentColor);
m_ui->visualSelector->slotSetColor(m_d->currentColor);
}
m_d->lockUsedCS = true;
}
......
......@@ -89,11 +89,12 @@ KisVisualColorSelector::~KisVisualColorSelector()
void KisVisualColorSelector::slotSetColor(const KoColor &c)
{
m_d->currentcolor = c;
if (m_d->currentCS != c.colorSpace()) {
slotsetColorSpace(c.colorSpace());
if (!m_d->currentCS) {
m_d->currentcolor = c;
slotSetColorSpace(c.colorSpace());
}
else {
m_d->currentcolor = c.convertedTo(m_d->currentCS);
m_d->channelValues = convertKoColorToShapeCoordinates(m_d->currentcolor);
Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) {
shape->setChannelValues(m_d->channelValues, true);
......@@ -104,10 +105,11 @@ void KisVisualColorSelector::slotSetColor(const KoColor &c)
}
}
void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs)
void KisVisualColorSelector::slotSetColorSpace(const KoColorSpace *cs)
{
if (m_d->currentCS != cs) {
m_d->currentCS = cs;
m_d->currentcolor = KoColor(cs);
slotRebuildSelectors();
}
}
......@@ -612,7 +614,7 @@ void KisVisualColorSelector::resizeEvent(QResizeEvent *) {
int borderWidth = qMax(sizeValue*0.1, 20.0);
QRect newrect(0,0, this->geometry().width(), this->geometry().height());
if (!m_d->currentCS) {
slotsetColorSpace(m_d->currentcolor.colorSpace());
slotSetColorSpace(m_d->currentcolor.colorSpace());
}
if (m_d->currentCS->colorChannelCount()==3) {
// set border width first, else the resized painting may have happened already, and we'd have to re-render
......
......@@ -68,7 +68,7 @@ public:
public Q_SLOTS:
void slotSetColor(const KoColor &c) override;
void slotsetColorSpace(const KoColorSpace *cs);
void slotSetColorSpace(const KoColorSpace *cs) override;
void slotSetHSX(const QVector3D &hsx);
void configurationChanged();
void setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer) override;
......
......@@ -37,6 +37,10 @@ KisASCCDLConfigWidget::KisASCCDLConfigWidget(QWidget *parent, const KoColorSpace
m_page->btnOffset->setColor(black);
m_page->btnPower->setColor(black);
m_page->slopeSelector->slotSetColorSpace(m_cs);
m_page->offsetSelector->slotSetColorSpace(m_cs);
m_page->powerSelector->slotSetColorSpace(m_cs);
connect(m_page->btnSlope , SIGNAL(changed(KoColor)), this, SLOT(slopeColorChanged(KoColor)));
connect(m_page->btnOffset, SIGNAL(changed(KoColor)), this, SLOT(offsetColorChanged(KoColor)));
connect(m_page->btnPower , SIGNAL(changed(KoColor)), this, SLOT(powerColorChanged(KoColor)));
......
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