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