Commit 0c201bc0 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🐛

Initial implementation displayrenderer

Will need to change it now...
parent 9c39f81c
...@@ -20,13 +20,14 @@ ...@@ -20,13 +20,14 @@
#include <QAbstractSpinBox> #include <QAbstractSpinBox>
#include <QSpinBox> #include <QSpinBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QPointer>
#include "KoColorSpaceRegistry.h" #include "KoColorSpaceRegistry.h"
#include "kis_signal_compressor.h" #include "kis_signal_compressor.h"
#include "KisViewManager.h" #include "KisViewManager.h"
#include "KoColorDisplayRendererInterface.h" #include "KoColorDisplayRendererInterface.h"
#include "kis_display_color_converter.h"
#include "kis_spinbox_color_selector.h" #include "kis_spinbox_color_selector.h"
#include "kis_internal_color_selector.h" #include "kis_internal_color_selector.h"
...@@ -39,9 +40,10 @@ struct KisInternalColorSelector::Private ...@@ -39,9 +40,10 @@ struct KisInternalColorSelector::Private
const KoColorSpace *currentColorSpace; const KoColorSpace *currentColorSpace;
bool chooseAlpha = false; bool chooseAlpha = false;
KisSignalCompressor *compressColorChanges; KisSignalCompressor *compressColorChanges;
QPointer<KoColorDisplayRendererInterface> displayRenderer;
}; };
KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor color, bool modal, const QString &caption) KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor color, bool modal, const QString &caption, KoColorDisplayRendererInterface *displayRenderer)
: QDialog(parent) : QDialog(parent)
,m_d(new Private) ,m_d(new Private)
{ {
...@@ -56,11 +58,13 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo ...@@ -56,11 +58,13 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo
m_d->currentColor = color; m_d->currentColor = color;
m_d->currentColorSpace = m_d->currentColor.colorSpace(); m_d->currentColorSpace = m_d->currentColor.colorSpace();
m_d->displayRenderer = displayRenderer;
m_ui->spinboxselector->slotSetColor(color); m_ui->spinboxselector->slotSetColor(color);
connect(m_ui->spinboxselector, SIGNAL(sigNewColor(KoColor)), this, SLOT(slotColorUpdated(KoColor))); connect(m_ui->spinboxselector, SIGNAL(sigNewColor(KoColor)), this, SLOT(slotColorUpdated(KoColor)));
m_ui->visualSelector->slotSetColor(color); m_ui->visualSelector->slotSetColor(color);
m_ui->visualSelector->setDisplayRenderer(displayRenderer);
connect(m_ui->visualSelector, SIGNAL(sigNewColor(KoColor)), this, SLOT(slotColorUpdated(KoColor))); connect(m_ui->visualSelector, SIGNAL(sigNewColor(KoColor)), this, SLOT(slotColorUpdated(KoColor)));
connect(m_ui->screenColorPicker, SIGNAL(sigNewColorPicked(KoColor)),this, SLOT(slotColorUpdated(KoColor))); connect(m_ui->screenColorPicker, SIGNAL(sigNewColorPicked(KoColor)),this, SLOT(slotColorUpdated(KoColor)));
//TODO: Add disable signal as well. Might be not necessary...? //TODO: Add disable signal as well. Might be not necessary...?
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "kritaui_export.h" #include "kritaui_export.h"
#include "KoColor.h" #include "KoColor.h"
#include "KoColorSpace.h" #include "KoColorSpace.h"
#include "KoColorDisplayRendererInterface.h"
#include <QScopedPointer> #include <QScopedPointer>
#include "ui_wdgdlginternalcolorselector.h" #include "ui_wdgdlginternalcolorselector.h"
...@@ -35,7 +37,7 @@ class KRITAUI_EXPORT KisInternalColorSelector : public QDialog ...@@ -35,7 +37,7 @@ class KRITAUI_EXPORT KisInternalColorSelector : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
KisInternalColorSelector(QWidget* parent, KoColor color, bool modal, const QString &caption); KisInternalColorSelector(QWidget* parent, KoColor color, bool modal, const QString &caption, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
~KisInternalColorSelector(); ~KisInternalColorSelector();
/** /**
......
...@@ -97,7 +97,7 @@ void KoDualColorButton::Private::init(KoDualColorButton *q) ...@@ -97,7 +97,7 @@ void KoDualColorButton::Private::init(KoDualColorButton *q)
q->setAcceptDrops( true ); q->setAcceptDrops( true );
QString caption = "Select a color"; QString caption = "Select a color";
colorSelectorDialog = new KisInternalColorSelector(q, foregroundColor, false, caption); colorSelectorDialog = new KisInternalColorSelector(q, foregroundColor, false, caption, KoDumbColorDisplayRenderer::instance());
connect(colorSelectorDialog, SIGNAL(signalForegroundColorChosen(KoColor)), q, SLOT(slotSetForeGroundColorFromDialog(KoColor))); connect(colorSelectorDialog, SIGNAL(signalForegroundColorChosen(KoColor)), q, SLOT(slotSetForeGroundColorFromDialog(KoColor)));
connect(q, SIGNAL(foregroundColorChanged(KoColor)), colorSelectorDialog, SLOT(slotColorUpdated(KoColor))); connect(q, SIGNAL(foregroundColorChanged(KoColor)), colorSelectorDialog, SLOT(slotColorUpdated(KoColor)));
} }
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <QList> #include <QList>
#include "KoColorConversions.h" #include "KoColorConversions.h"
#include "KoColorDisplayRendererInterface.h"
#include <QPointer>
#include "kis_signal_compressor.h" #include "kis_signal_compressor.h"
struct KisVisualColorSelector::Private struct KisVisualColorSelector::Private
...@@ -35,7 +37,7 @@ struct KisVisualColorSelector::Private ...@@ -35,7 +37,7 @@ struct KisVisualColorSelector::Private
const KoColorSpace *currentCS; const KoColorSpace *currentCS;
QList <KisVisualColorSelectorShape*> widgetlist; QList <KisVisualColorSelectorShape*> widgetlist;
bool updateSelf = false; bool updateSelf = false;
QPointer<KoColorDisplayRendererInterface> displayRenderer;
//Current coordinates. //Current coordinates.
QVector <float> currentCoordinates; QVector <float> currentCoordinates;
}; };
...@@ -118,6 +120,16 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs) ...@@ -118,6 +120,16 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs)
} }
void KisVisualColorSelector::setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer) {
m_d->displayRenderer = displayRenderer;
if (m_d->widgetlist.size()>0) {
Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) {
shape->setDisplayRenderer(displayRenderer);
}
}
}
void KisVisualColorSelector::updateSelectorElements() void KisVisualColorSelector::updateSelectorElements()
{ {
//first lock all elements from sending updates, then update all elements. //first lock all elements from sending updates, then update all elements.
...@@ -165,6 +177,7 @@ struct KisVisualColorSelectorShape::Private ...@@ -165,6 +177,7 @@ struct KisVisualColorSelectorShape::Private
int channel2; int channel2;
KisSignalCompressor *updateTimer; KisSignalCompressor *updateTimer;
bool mousePressActive = false; bool mousePressActive = false;
QPointer<KoColorDisplayRendererInterface> displayRenderer;
}; };
KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent, KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
...@@ -172,8 +185,11 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent, ...@@ -172,8 +185,11 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
KisVisualColorSelectorShape::ColorModel model, KisVisualColorSelectorShape::ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel1,
int channel2): QWidget(parent), m_d(new Private) int channel2,
KoColorDisplayRendererInterface *displayRenderer): QWidget(parent), m_d(new Private)
{ {
m_d->displayRenderer = displayRenderer;
connect(m_d->displayRenderer, SIGNAL(displayConfigurationChanged()), SLOT(update()));
m_d->dimension = dimension; m_d->dimension = dimension;
m_d->model = model; m_d->model = model;
m_d->cs = cs; m_d->cs = cs;
...@@ -226,6 +242,20 @@ void KisVisualColorSelectorShape::setColorFromSibling(KoColor c) ...@@ -226,6 +242,20 @@ void KisVisualColorSelectorShape::setColorFromSibling(KoColor c)
update(); update();
} }
void KisVisualColorSelectorShape::setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer) {
m_d->displayRenderer = displayRenderer;
}
QColor KisVisualColorSelectorShape::getColorFromConverter(KoColor c){
QColor col;
if (m_d->displayRenderer) {
col = m_d->displayRenderer->toQColor(c);
} else {
col = c.toQColor();
}
return col;
}
void KisVisualColorSelectorShape::slotSetActiveChannels(int channel1, int channel2) void KisVisualColorSelectorShape::slotSetActiveChannels(int channel1, int channel2)
{ {
int maxchannel = m_d->cs->colorChannelCount()-1; int maxchannel = m_d->cs->colorChannelCount()-1;
...@@ -249,8 +279,7 @@ QPixmap KisVisualColorSelectorShape::getPixmap() ...@@ -249,8 +279,7 @@ QPixmap KisVisualColorSelectorShape::getPixmap()
QPoint widgetPoint(x,y); QPoint widgetPoint(x,y);
QPointF newcoordinate = convertWidgetCoordinateToShapeCoordinate(widgetPoint); QPointF newcoordinate = convertWidgetCoordinateToShapeCoordinate(widgetPoint);
KoColor c = convertShapeCoordinateToKoColor(newcoordinate); KoColor c = convertShapeCoordinateToKoColor(newcoordinate);
//put displayconverter here QColor col = getColorFromConverter(c);
QColor col = c.toQColor();
img.setPixel(widgetPoint, col.rgb()); img.setPixel(widgetPoint, col.rgb());
} }
} }
...@@ -413,8 +442,8 @@ KisVisualRectangleSelectorShape::KisVisualRectangleSelectorShape(QWidget *parent ...@@ -413,8 +442,8 @@ KisVisualRectangleSelectorShape::KisVisualRectangleSelectorShape(QWidget *parent
ColorModel model, ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel2, int channel1, int channel2,
singelDTypes d) singelDTypes d, KoColorDisplayRendererInterface *displayRenderer)
: KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, channel2) : KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, channel2, displayRenderer)
{ {
m_type = d; m_type = d;
} }
...@@ -467,7 +496,7 @@ void KisVisualRectangleSelectorShape::drawCursor() ...@@ -467,7 +496,7 @@ void KisVisualRectangleSelectorShape::drawCursor()
{ {
QPointF cursorPoint = convertShapeCoordinateToWidgetCoordinate(getCursorPosition()); QPointF cursorPoint = convertShapeCoordinateToWidgetCoordinate(getCursorPosition());
QPixmap fullSelector = getPixmap(); QPixmap fullSelector = getPixmap();
QColor col = getColorFromConverter(getCurrentColor());
QPainter painter; QPainter painter;
painter.begin(&fullSelector); painter.begin(&fullSelector);
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
...@@ -494,7 +523,7 @@ void KisVisualRectangleSelectorShape::drawCursor() ...@@ -494,7 +523,7 @@ void KisVisualRectangleSelectorShape::drawCursor()
painter.setBrush(fill); painter.setBrush(fill);
painter.drawRect(rect); painter.drawRect(rect);
//set filter conversion! //set filter conversion!
fill.setColor(getCurrentColor().toQColor()); fill.setColor(col);
painter.setPen(Qt::black); painter.setPen(Qt::black);
painter.setBrush(fill); painter.setBrush(fill);
rect.setCoords(rect.topLeft().x()+1, rect.topLeft().y()+1, rect.setCoords(rect.topLeft().x()+1, rect.topLeft().y()+1,
...@@ -506,8 +535,7 @@ void KisVisualRectangleSelectorShape::drawCursor() ...@@ -506,8 +535,7 @@ void KisVisualRectangleSelectorShape::drawCursor()
fill.setColor(Qt::white); fill.setColor(Qt::white);
painter.setBrush(fill); painter.setBrush(fill);
painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth); painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
//set filter conversion! fill.setColor(col);
fill.setColor(getCurrentColor().toQColor());
painter.setPen(Qt::black); painter.setPen(Qt::black);
painter.setBrush(fill); painter.setBrush(fill);
painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0); painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0);
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <KoColor.h> #include <KoColor.h>
#include <KoColorSpace.h> #include <KoColorSpace.h>
#include "KoColorDisplayRendererInterface.h"
#include "kritaui_export.h" #include "kritaui_export.h"
...@@ -48,6 +50,7 @@ public Q_SLOTS: ...@@ -48,6 +50,7 @@ public Q_SLOTS:
void slotSetColor(KoColor c); void slotSetColor(KoColor c);
void slotsetColorSpace(const KoColorSpace *cs); void slotsetColorSpace(const KoColorSpace *cs);
void setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer);
private Q_SLOTS: private Q_SLOTS:
void updateFromWidgets(KoColor c); void updateFromWidgets(KoColor c);
protected: protected:
...@@ -78,7 +81,8 @@ public: ...@@ -78,7 +81,8 @@ public:
KisVisualColorSelectorShape::Dimensions dimension, KisVisualColorSelectorShape::Dimensions dimension,
KisVisualColorSelectorShape::ColorModel model, KisVisualColorSelectorShape::ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel2); int channel1, int channel2,
KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
~KisVisualColorSelectorShape(); ~KisVisualColorSelectorShape();
QPointF getCursorPosition(); QPointF getCursorPosition();
...@@ -88,6 +92,8 @@ public: ...@@ -88,6 +92,8 @@ public:
QPixmap getPixmap(); QPixmap getPixmap();
void setFullImage(QPixmap full); void setFullImage(QPixmap full);
KoColor getCurrentColor(); KoColor getCurrentColor();
void setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer);
QColor getColorFromConverter(KoColor c);
Q_SIGNALS: Q_SIGNALS:
void sigNewColor(KoColor col); void sigNewColor(KoColor col);
...@@ -145,7 +151,8 @@ public: ...@@ -145,7 +151,8 @@ public:
ColorModel model, ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel2, int channel1, int channel2,
KisVisualRectangleSelectorShape::singelDTypes d = KisVisualRectangleSelectorShape::vertical); KisVisualRectangleSelectorShape::singelDTypes d = KisVisualRectangleSelectorShape::vertical,
KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
~KisVisualRectangleSelectorShape(); ~KisVisualRectangleSelectorShape();
void setBarWidth(); void setBarWidth();
......
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