Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Enable access to KoColorDisplayRendererInterface from KoCanvasBase to colormanage the KoTools.

Wolthera van Hövell tot Westerflier1d2a821de3db
diff --git a/libs/basicflakes/tools/KoCreatePathTool.cpp b/libs/basicflakes/tools/KoCreatePathTool.cpp
index a214463932..8da272aae6 100644
--- a/libs/basicflakes/tools/KoCreatePathTool.cpp
+++ b/libs/basicflakes/tools/KoCreatePathTool.cpp
@@ -18,6 +18,7 @@
#include "KoCanvasBase.h"
#include "kis_int_parse_spin_box.h"
#include <KoColor.h>
+#include <KoColorDisplayRendererInterface.h>
#include "kis_canvas_resource_provider.h"
#include <KisHandlePainterHelper.h>
#include "KoPathPointTypeCommand.h"
@@ -78,6 +79,8 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
{
Q_D(KoCreatePathTool);
+ KisHandlePalette palette = canvas()->displayRendererInterface()->handlePaletteForDisplayColorSpace();
+
if (pathStarted()) {
painter.save();
@@ -97,13 +100,13 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
paintFlags |= KoPathPoint::ControlPoint1;
}
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles(palette));
d->activePoint->paint(helper, paintFlags, onlyPaintActivePoints);
}
if (!firstPointActive) {
helper.setHandleStyle(d->mouseOverFirstPoint ?
- KisHandleStyle::highlightedPrimaryHandles() :
+ KisHandleStyle::highlightedPrimaryHandles(palette) :
KisHandleStyle::primarySelection());
d->firstPoint->paint(helper, KoPathPoint::Node);
}
@@ -111,7 +114,7 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
if (d->hoveredPoint) {
KisHandlePainterHelper helper = KoShape::createHandlePainterHelperView(&painter, d->hoveredPoint->parent(), converter, d->handleRadius, d->decorationThickness);
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles(palette));
d->hoveredPoint->paint(helper, KoPathPoint::Node);
}
diff --git a/libs/basicflakes/tools/KoPencilTool.cpp b/libs/basicflakes/tools/KoPencilTool.cpp
index 9012f937f9..969f588067 100644
--- a/libs/basicflakes/tools/KoPencilTool.cpp
+++ b/libs/basicflakes/tools/KoPencilTool.cpp
@@ -17,6 +17,7 @@
#include <KoSelection.h>
#include <KoCanvasResourceProvider.h>
#include <KoColor.h>
+#include <KoColorDisplayRendererInterface.h>
#include <KoPathPoint.h>
#include <KoPathPointData.h>
#include <KoPathPointMergeCommand.h>
@@ -75,7 +76,7 @@ void KoPencilTool::paint(QPainter &painter, const KoViewConverter &converter)
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, m_hoveredPoint->parent(), converter, handleRadius(), decorationThickness());
- helper.setHandleStyle(KisHandleStyle::primarySelection());
+ helper.setHandleStyle(KisHandleStyle::primarySelection(canvas()->displayRendererInterface()->handlePaletteForDisplayColorSpace()));
m_hoveredPoint->paint(helper, KoPathPoint::Node);
}
}
diff --git a/libs/flake/KoCanvasBase.cpp b/libs/flake/KoCanvasBase.cpp
index ec2b72139f..a86964f999 100644
--- a/libs/flake/KoCanvasBase.cpp
+++ b/libs/flake/KoCanvasBase.cpp
@@ -19,6 +19,7 @@
#include "KoToolProxy.h"
#include "KoSelection.h"
#include "KoSelectedShapesProxy.h"
+#include <KoColorDisplayRendererInterface.h>
class Q_DECL_HIDDEN KoCanvasBase::Private
{
@@ -63,6 +64,11 @@ KoCanvasBase::~KoCanvasBase()
delete d;
}
+KoColorDisplayRendererInterface *KoCanvasBase::displayRendererInterface() const
+{
+ return KoDumbColorDisplayRenderer::instance();
+}
+
QPointF KoCanvasBase::viewToDocument(const QPointF &viewPoint) const
{
return viewConverter()->viewToDocument(viewPoint - documentOrigin());
diff --git a/libs/flake/KoCanvasBase.h b/libs/flake/KoCanvasBase.h
index 3139943f1d..146e918612 100644
--- a/libs/flake/KoCanvasBase.h
+++ b/libs/flake/KoCanvasBase.h
@@ -27,6 +27,7 @@ class KoCanvasController;
class KoShape;
class KoSnapGuide;
class KoSelectedShapesProxy;
+class KoColorDisplayRendererInterface;
class QWidget;
class QCursor;
@@ -172,6 +173,14 @@ public:
virtual const KoViewConverter *viewConverter() const = 0;
virtual KoViewConverter *viewConverter() = 0;
+ /**
+ * @brief displayRendererInterface
+ * The display renderer interface has a number of color conversion
+ * functions which are useful to convert a KoColor to a QColor.
+ * @return The display renderer interface for this canvas.
+ */
+ virtual KoColorDisplayRendererInterface* displayRendererInterface() const;
+
/**
* Convert a coordinate in pixels to pt.
* @param viewPoint the point in the coordinate system of the widget, or window.
diff --git a/libs/flake/tools/KoInteractionStrategy.cpp b/libs/flake/tools/KoInteractionStrategy.cpp
index 58222d131e..b031930ee6 100644
--- a/libs/flake/tools/KoInteractionStrategy.cpp
+++ b/libs/flake/tools/KoInteractionStrategy.cpp
@@ -39,7 +39,7 @@ KoInteractionStrategy::~KoInteractionStrategy()
delete d_ptr;
}
-void KoInteractionStrategy::paint(QPainter &, const KoViewConverter &)
+void KoInteractionStrategy::paint(QPainter &, const KoViewConverter &, const KoColorDisplayRendererInterface *displayRendererInterface)
{
}
diff --git a/libs/flake/tools/KoInteractionStrategy.h b/libs/flake/tools/KoInteractionStrategy.h
index 8123282f50..40bba04c3b 100644
--- a/libs/flake/tools/KoInteractionStrategy.h
+++ b/libs/flake/tools/KoInteractionStrategy.h
@@ -21,6 +21,7 @@ class KoToolBase;
class KUndo2Command;
class QPointF;
class QPainter;
+class KoColorDisplayRendererInterface;
/**
* Abstract interface to define what actions a KoInteractionTool can do based on
@@ -46,7 +47,7 @@ public:
* Reimplement this if the action needs to draw a "blob" on the canvas;
* that is, a transient decoration like a rubber band.
*/
- virtual void paint(QPainter &painter, const KoViewConverter &converter);
+ virtual void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface);
/**
* Extending classes should implement this method to update the selectedShapes
* based on the new mouse position.
diff --git a/libs/flake/tools/KoInteractionStrategyFactory.h b/libs/flake/tools/KoInteractionStrategyFactory.h
index c86faeb958..04d7b8c8c3 100644
--- a/libs/flake/tools/KoInteractionStrategyFactory.h
+++ b/libs/flake/tools/KoInteractionStrategyFactory.h
@@ -16,6 +16,7 @@ class QPainter;
class KoInteractionStrategy;
class KoPointerEvent;
class KoViewConverter;
+class KoColorDisplayRendererInterface;
class KoInteractionStrategyFactory;
typedef QSharedPointer<KoInteractionStrategyFactory> KoInteractionStrategyFactorySP;
@@ -31,7 +32,7 @@ public:
virtual KoInteractionStrategy* createStrategy(KoPointerEvent *ev) = 0;
virtual bool hoverEvent(KoPointerEvent *ev) = 0;
- virtual bool paintOnHover(QPainter &painter, const KoViewConverter &converter) = 0;
+ virtual bool paintOnHover(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) = 0;
virtual bool tryUseCustomCursor() = 0;
static bool compareLess(KoInteractionStrategyFactorySP f1, KoInteractionStrategyFactorySP f2);
diff --git a/libs/flake/tools/KoInteractionTool.cpp b/libs/flake/tools/KoInteractionTool.cpp
index ec31850694..9fff3b79ea 100644
--- a/libs/flake/tools/KoInteractionTool.cpp
+++ b/libs/flake/tools/KoInteractionTool.cpp
@@ -31,11 +31,11 @@ void KoInteractionTool::paint(QPainter &painter, const KoViewConverter &converte
Q_D(KoInteractionTool);
if (d->currentStrategy) {
- d->currentStrategy->paint(painter, converter);
+ d->currentStrategy->paint(painter, converter, canvas()->displayRendererInterface());
} else {
Q_FOREACH (KoInteractionStrategyFactorySP factory, d->interactionFactories) {
// skip the rest of rendering if the factory asks for it
- if (factory->paintOnHover(painter, converter)) break;
+ if (factory->paintOnHover(painter, converter, canvas()->displayRendererInterface())) break;
}
}
}
diff --git a/libs/flake/tools/KoPathTool.cpp b/libs/flake/tools/KoPathTool.cpp
index d019094b7e..2fc3a9aea3 100644
--- a/libs/flake/tools/KoPathTool.cpp
+++ b/libs/flake/tools/KoPathTool.cpp
@@ -41,6 +41,7 @@
#include "kis_pointer_utils.h"
#include <KisHandlePainterHelper.h>
#include <KoShapeStrokeModel.h>
+#include <KoColorDisplayRendererInterface.h>
#include <commands/KoKeepShapesSelectedCommand.h>
#include <commands/KoMultiPathPointJoinCommand.h>
#include <commands/KoMultiPathPointMergeCommand.h>
@@ -444,10 +445,12 @@ void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
m_textOutlineHelper->setHandleRadius(handleRadius());
m_textOutlineHelper->paint(&painter, converter);
+ const KisHandlePalette palette = canvas()->displayRendererInterface()->handlePaletteForDisplayColorSpace();
+
Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, shape, converter, handleRadius(), decorationThickness());
- helper.setHandleStyle(KisHandleStyle::primarySelection());
+ helper.setHandleStyle(KisHandleStyle::primarySelection(palette));
KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
if (parameterShape && parameterShape->isParametricShape()) {
@@ -457,22 +460,22 @@ void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
}
if (!shape->stroke() || !shape->stroke()->isVisible()) {
- helper.setHandleStyle(KisHandleStyle::secondarySelection());
+ helper.setHandleStyle(KisHandleStyle::secondarySelection(palette));
helper.drawPath(shape->outline());
}
}
if (m_currentStrategy) {
painter.save();
- m_currentStrategy->paint(painter, converter);
+ m_currentStrategy->paint(painter, converter, canvas()->displayRendererInterface());
painter.restore();
}
- m_pointSelection.paint(painter, converter, handleRadius());
+ m_pointSelection.paint(painter, converter, handleRadius(), canvas()->displayRendererInterface());
if (m_activeHandle) {
if (m_activeHandle->check(m_pointSelection.selectedShapes())) {
- m_activeHandle->paint(painter, converter, handleRadius(), decorationThickness());
+ m_activeHandle->paint(painter, converter, handleRadius(), decorationThickness(), canvas()->displayRendererInterface());
} else {
m_activeHandle.reset();
}
@@ -489,7 +492,7 @@ void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, shape, converter, handleRadius(), decorationThickness());
- helper.setHandleStyle(KisHandleStyle::secondarySelection());
+ helper.setHandleStyle(KisHandleStyle::secondarySelection(palette));
QPainterPath path;
path.moveTo(segment.first()->point());
diff --git a/libs/flake/tools/KoPathToolHandle.cpp b/libs/flake/tools/KoPathToolHandle.cpp
index 13b434f289..6e04c210ac 100644
--- a/libs/flake/tools/KoPathToolHandle.cpp
+++ b/libs/flake/tools/KoPathToolHandle.cpp
@@ -21,6 +21,7 @@
#include "KoShapeController.h"
#include <QPainter>
#include <KisHandlePainterHelper.h>
+#include <KoColorDisplayRendererInterface.h>
KoPathToolHandle::KoPathToolHandle(KoPathTool *tool)
@@ -40,7 +41,7 @@ PointHandle::PointHandle(KoPathTool *tool, KoPathPoint *activePoint, KoPathPoint
{
}
-void PointHandle::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness)
+void PointHandle::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface)
{
KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
@@ -49,7 +50,7 @@ void PointHandle::paint(QPainter &painter, const KoViewConverter &converter, qre
allPaintedTypes = KoPathPoint::All;
}
-
+ const KisHandlePalette palette = renderInterface->handlePaletteForDisplayColorSpace();
KisHandlePainterHelper helper = KoShape::createHandlePainterHelperView(&painter, m_activePoint->parent(), converter, handleRadius, decorationThickness);
@@ -58,17 +59,17 @@ void PointHandle::paint(QPainter &painter, const KoViewConverter &converter, qre
KoPathPoint::PointTypes nonNodeType = nonHighlightedType & ~KoPathPoint::Node;
if (nonNodeType != KoPathPoint::None) {
- helper.setHandleStyle(KisHandleStyle::selectedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::selectedPrimaryHandles(palette));
m_activePoint->paint(helper, nonHighlightedType);
}
if (nonHighlightedType & KoPathPoint::Node) {
- helper.setHandleStyle(KisHandleStyle::partiallyHighlightedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::partiallyHighlightedPrimaryHandles(palette));
m_activePoint->paint(helper, KoPathPoint::Node);
}
}
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles(palette));
m_activePoint->paint(helper, m_activePointType);
}
@@ -166,10 +167,11 @@ ParameterHandle::ParameterHandle(KoPathTool *tool, KoParameterShape *parameterSh
{
}
-void ParameterHandle::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness)
+void ParameterHandle::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface)
{
KisHandlePainterHelper helper = KoShape::createHandlePainterHelperView(&painter, m_parameterShape, converter, handleRadius, decorationThickness);
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
+ const KisHandlePalette palette = renderInterface->handlePaletteForDisplayColorSpace();
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles(palette));
m_parameterShape->paintHandle(helper, m_handleId);
}
diff --git a/libs/flake/tools/KoPathToolHandle.h b/libs/flake/tools/KoPathToolHandle.h
index 95967e5d59..92805726fd 100644
--- a/libs/flake/tools/KoPathToolHandle.h
+++ b/libs/flake/tools/KoPathToolHandle.h
@@ -23,6 +23,7 @@ class KoPointerEvent;
class QPainter;
class KoPathShape;
class KisHandlePainterHelper;
+class KoColorDisplayRendererInterface;
class KoPathToolHandle
@@ -30,7 +31,7 @@ class KoPathToolHandle
public:
explicit KoPathToolHandle(KoPathTool *tool);
virtual ~KoPathToolHandle();
- virtual void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness) = 0;
+ virtual void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface) = 0;
virtual QRectF boundingRect() const = 0;
virtual KoInteractionStrategy * handleMousePress(KoPointerEvent *event) = 0;
// test if handle is still valid
@@ -46,7 +47,7 @@ class PointHandle : public KoPathToolHandle
{
public:
PointHandle(KoPathTool *tool, KoPathPoint *activePoint, KoPathPoint::PointType activePointType);
- void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface) override;
QRectF boundingRect() const override;
KoInteractionStrategy *handleMousePress(KoPointerEvent *event) override;
bool check(const QList<KoPathShape*> &selectedShapes) override;
@@ -63,7 +64,7 @@ class ParameterHandle : public KoPathToolHandle
{
public:
ParameterHandle(KoPathTool *tool, KoParameterShape *parameterShape, int handleId);
- void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, int decorationThickness, KoColorDisplayRendererInterface *renderInterface) override;
QRectF boundingRect() const override;
KoInteractionStrategy *handleMousePress(KoPointerEvent *event) override;
bool check(const QList<KoPathShape*> &selectedShapes) override;
diff --git a/libs/flake/tools/KoPathToolSelection.cpp b/libs/flake/tools/KoPathToolSelection.cpp
index ffc3e97b5f..c23c9fc4ff 100644
--- a/libs/flake/tools/KoPathToolSelection.cpp
+++ b/libs/flake/tools/KoPathToolSelection.cpp
@@ -16,6 +16,7 @@
#include <KoCanvasBase.h>
#include <KoDocumentResourceManager.h>
#include <KoShapeController.h>
+#include <KoColorDisplayRendererInterface.h>
#include <QPainter>
#include <KisHandlePainterHelper.h>
@@ -28,14 +29,15 @@ KoPathToolSelection::~KoPathToolSelection()
{
}
-void KoPathToolSelection::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius)
+void KoPathToolSelection::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, KoColorDisplayRendererInterface *renderInterface)
{
int decorationThickness = m_tool? m_tool->decorationThickness(): 1;
+ const KisHandlePalette palette = renderInterface->handlePaletteForDisplayColorSpace();
PathShapePointMap::iterator it(m_shapePointMap.begin());
for (; it != m_shapePointMap.end(); ++it) {
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, it.key(), converter, handleRadius, decorationThickness);
- helper.setHandleStyle(KisHandleStyle::selectedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::selectedPrimaryHandles(palette));
Q_FOREACH (KoPathPoint *p, it.value()) {
p->paint(helper, KoPathPoint::All);
diff --git a/libs/flake/tools/KoPathToolSelection.h b/libs/flake/tools/KoPathToolSelection.h
index c976b2fcad..fd5f93f605 100644
--- a/libs/flake/tools/KoPathToolSelection.h
+++ b/libs/flake/tools/KoPathToolSelection.h
@@ -17,6 +17,7 @@ class KoPathTool;
class KoPathPoint;
class KoPathPointData;
class KoViewConverter;
+class KoColorDisplayRendererInterface;
class QPainter;
/**
@@ -35,7 +36,7 @@ public:
~KoPathToolSelection() override;
/// @brief Draw the selected points
- void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius);
+ void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius, KoColorDisplayRendererInterface *renderInterface);
/**
* @brief Add a point to the selection
diff --git a/libs/flake/tools/KoShapeRubberSelectStrategy.cpp b/libs/flake/tools/KoShapeRubberSelectStrategy.cpp
index 7785211b2c..7584fac667 100644
--- a/libs/flake/tools/KoShapeRubberSelectStrategy.cpp
+++ b/libs/flake/tools/KoShapeRubberSelectStrategy.cpp
@@ -15,6 +15,8 @@
#include "KoShapeManager.h"
#include "KoSelection.h"
#include "KoCanvasBase.h"
+#include <KoColor.h>
+#include <KoColorDisplayRendererInterface.h>
KoShapeRubberSelectStrategy::KoShapeRubberSelectStrategy(KoToolBase *tool, const QPointF &clicked, bool useSnapToGrid)
: KoInteractionStrategy(*(new KoShapeRubberSelectStrategyPrivate(tool)))
@@ -26,13 +28,16 @@ KoShapeRubberSelectStrategy::KoShapeRubberSelectStrategy(KoToolBase *tool, const
d->selectRect = QRectF(d->snapGuide->snap(clicked, QFlags<Qt::KeyboardModifier>()), QSizeF(0, 0));
}
-void KoShapeRubberSelectStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void KoShapeRubberSelectStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
Q_D(KoShapeRubberSelectStrategy);
painter.setRenderHint(QPainter::Antialiasing, false);
- const QColor crossingColor(80,130,8);
- const QColor coveringColor(8,60,167);
+ KoColor c;
+ c.fromQColor(QColor(80,130,8));
+ const QColor crossingColor(displayRendererInterface->convertColorToDisplayColorSpace(c));
+ c.fromQColor(QColor(8,60,167));
+ const QColor coveringColor(displayRendererInterface->convertColorToDisplayColorSpace(c));
QColor selectColor(
currentMode() == CrossingSelection ?
diff --git a/libs/flake/tools/KoShapeRubberSelectStrategy.h b/libs/flake/tools/KoShapeRubberSelectStrategy.h
index fad7dd103f..ee25741399 100644
--- a/libs/flake/tools/KoShapeRubberSelectStrategy.h
+++ b/libs/flake/tools/KoShapeRubberSelectStrategy.h
@@ -39,7 +39,7 @@ public:
*/
KoShapeRubberSelectStrategy(KoToolBase *tool, const QPointF &clicked, bool useSnapToGrid = false);
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
diff --git a/libs/pigment/KoColorDisplayRendererInterface.cpp b/libs/pigment/KoColorDisplayRendererInterface.cpp
index f7e97733aa..5c70fd8ab2 100644
--- a/libs/pigment/KoColorDisplayRendererInterface.cpp
+++ b/libs/pigment/KoColorDisplayRendererInterface.cpp
@@ -12,6 +12,8 @@
#include <KoChannelInfo.h>
#include <KoColorConversionTransformation.h>
#include <KoColorSpace.h>
+#include <KisHandleStyle.h>
+#include <QPalette>
Q_GLOBAL_STATIC(KoDumbColorDisplayRenderer, s_instance)
@@ -81,3 +83,18 @@ const KoColorSpace* KoDumbColorDisplayRenderer::getPaintingColorSpace() const
{
return KoColorSpaceRegistry::instance()->rgb8();
}
+
+QColor KoDumbColorDisplayRenderer::convertColorToDisplayColorSpace(KoColor c) const
+{
+ return c.toQColor();
+}
+
+KisHandlePalette KoDumbColorDisplayRenderer::handlePaletteForDisplayColorSpace() const
+{
+ return KisHandlePalette();
+}
+
+QPalette KoDumbColorDisplayRenderer::systemPaletteForDisplayColorSpace() const
+{
+ return QPalette();
+}
diff --git a/libs/pigment/KoColorDisplayRendererInterface.h b/libs/pigment/KoColorDisplayRendererInterface.h
index 7cc142b04c..3bcb90899c 100644
--- a/libs/pigment/KoColorDisplayRendererInterface.h
+++ b/libs/pigment/KoColorDisplayRendererInterface.h
@@ -14,6 +14,8 @@
class KoChannelInfo;
class KoColorSpace;
+struct KisHandlePalette;
+class QPalette;
/**
* A special interface class provided by pigment to let widgets render
@@ -84,6 +86,25 @@ public:
*/
virtual const KoColorSpace* getPaintingColorSpace() const = 0;
+ /**
+ * @brief convertColorToDisplayColorSpace
+ * @param color -- base color.
+ * @return get a QColor version of the KoColor that is suited for canvas decorations.
+ */
+ virtual QColor convertColorToDisplayColorSpace(const KoColor color) const = 0;
+
+ /**
+ * @brief handlePaletteForDisplayColorSpace
+ * @return get a version of KisHandlePalette suited for canvas decorations
+ */
+ virtual KisHandlePalette handlePaletteForDisplayColorSpace() const = 0;
+
+ /**
+ * @brief systemPaletteForDisplayColorSpace
+ * @return get a version of the system palette that is suited for canvas decorations.
+ */
+ virtual QPalette systemPaletteForDisplayColorSpace() const = 0;
+
Q_SIGNALS:
void displayConfigurationChanged();
@@ -110,6 +131,10 @@ public:
const KoColorSpace* getPaintingColorSpace() const override;
+ QColor convertColorToDisplayColorSpace(KoColor c) const override;
+ KisHandlePalette handlePaletteForDisplayColorSpace() const override;
+ QPalette systemPaletteForDisplayColorSpace() const override;
+
static KoColorDisplayRendererInterface* instance();
};
diff --git a/libs/ui/canvas/kis_canvas2.cpp b/libs/ui/canvas/kis_canvas2.cpp
index 0d108e2923..5dafab754b 100644
--- a/libs/ui/canvas/kis_canvas2.cpp
+++ b/libs/ui/canvas/kis_canvas2.cpp
@@ -683,6 +683,11 @@ KoViewConverter *KisCanvas2::viewConverter()
return m_d->coordinatesConverter;
}
+KoColorDisplayRendererInterface* KisCanvas2::displayRendererInterface() const
+{
+ return m_d->displayColorConverter.displayRendererInterface();
+}
+
KisInputManager* KisCanvas2::globalInputManager() const
{
return m_d->view->globalInputManager();
diff --git a/libs/ui/canvas/kis_canvas2.h b/libs/ui/canvas/kis_canvas2.h
index f4df18a262..12bb9c0bd2 100644
--- a/libs/ui/canvas/kis_canvas2.h
+++ b/libs/ui/canvas/kis_canvas2.h
@@ -125,6 +125,8 @@ public: // KoCanvasBase implementation
const KoViewConverter *viewConverter() const override;
KoViewConverter *viewConverter() override;
+ KoColorDisplayRendererInterface* displayRendererInterface() const override;
+
QWidget* canvasWidget() override;
const QWidget* canvasWidget() const override;
diff --git a/libs/ui/canvas/kis_display_color_converter.cpp b/libs/ui/canvas/kis_display_color_converter.cpp
index 238087dc27..1bc3732916 100644
--- a/libs/ui/canvas/kis_display_color_converter.cpp
+++ b/libs/ui/canvas/kis_display_color_converter.cpp
@@ -223,6 +223,18 @@ struct KisDisplayColorConverter::Private
return m_displayColorConverter->paintingColorSpace();
}
+ QColor convertColorToDisplayColorSpace(KoColor c) const override {
+ return m_displayColorConverter->convertColorToDisplayColorSpace(c);
+ }
+
+ KisHandlePalette handlePaletteForDisplayColorSpace() const override {
+ return m_displayColorConverter->handlePaletteForDisplayColorSpace();
+ }
+
+ QPalette systemPaletteForDisplayColorSpace() const override {
+ return m_displayColorConverter->systemPaletteForDisplayColorSpace();
+ }
+
private:
KisDisplayColorConverter *m_displayColorConverter;
QPointer<KoCanvasResourceProvider> m_resourceManager;
diff --git a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
index 251f97716c..a6016b52f7 100644
--- a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
+++ b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
@@ -128,9 +128,10 @@ public:
void handleMouseMove(const QPointF & /*mouseLocation*/, Qt::KeyboardModifiers /*modifiers*/) override {}
void finishInteraction(Qt::KeyboardModifiers /*modifiers*/) override {}
- void paint(QPainter &painter, const KoViewConverter &converter) override {
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override {
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface)
}
};
@@ -142,8 +143,8 @@ public:
{
}
- void paint(QPainter &painter, const KoViewConverter &converter) override {
- KoShapeRubberSelectStrategy::paint(painter, converter);
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override {
+ KoShapeRubberSelectStrategy::paint(painter, converter, displayRendererInterface);
}
void cancelInteraction() override
@@ -209,10 +210,11 @@ public:
return false;
}
- bool paintOnHover(QPainter &painter, const KoViewConverter &converter) override
+ bool paintOnHover(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override
{
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface)
return false;
}
@@ -328,10 +330,11 @@ public:
return false;
}
- bool paintOnHover(QPainter &painter, const KoViewConverter &converter) override
+ bool paintOnHover(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override
{
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface);
return false;
}
@@ -1108,7 +1111,7 @@ void DefaultTool::paint(QPainter &painter, const KoViewConverter &converter)
{
KoSelection *selection = koSelection();
if (selection) {
- m_decorator.reset(new SelectionDecorator(canvas()->resourceManager()));
+ m_decorator.reset(new SelectionDecorator(canvas()->resourceManager(), canvas()->displayRendererInterface()));
{
/**
diff --git a/plugins/tools/defaulttool/defaulttool/SelectionDecorator.cpp b/plugins/tools/defaulttool/defaulttool/SelectionDecorator.cpp
index 58bf467c1d..9288df07c5 100644
--- a/plugins/tools/defaulttool/defaulttool/SelectionDecorator.cpp
+++ b/plugins/tools/defaulttool/defaulttool/SelectionDecorator.cpp
@@ -22,6 +22,7 @@
#include "KoShapeGradientHandles.h"
#include <KoCanvasBase.h>
#include <KoSvgTextShape.h>
+#include <KoColorDisplayRendererInterface.h>
#include "kis_painting_tweaks.h"
#include "kis_coordinates_converter.h"
@@ -31,8 +32,9 @@
#define HANDLE_DISTANCE 10
-SelectionDecorator::SelectionDecorator(KoCanvasResourceProvider *resourceManager)
+SelectionDecorator::SelectionDecorator(KoCanvasResourceProvider *resourceManager, KoColorDisplayRendererInterface *displayInterface)
: m_hotPosition(KoFlake::Center)
+ , m_rendererInterface(displayInterface)
, m_handleRadius(7)
, m_decorationThickness(1)
, m_showFillGradientHandles(false)
@@ -83,10 +85,11 @@ void SelectionDecorator::setCurrentMeshGradientHandles(const KoShapeMeshGradient
void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &converter)
{
- KisHandlePalette palette;
QList<KoShape*> selectedShapes = m_selection->selectedVisibleShapes();
if (selectedShapes.isEmpty()) return;
+ const KisHandlePalette palette = m_rendererInterface->handlePaletteForDisplayColorSpace();
+
const bool haveOnlyOneEditableShape =
m_selection->selectedEditableShapes().size() == 1 &&
selectedShapes.size() == 1;
@@ -99,7 +102,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, shape, converter, m_handleRadius, m_decorationThickness);
- helper.setHandleStyle(KisHandleStyle::secondarySelection());
+ helper.setHandleStyle(KisHandleStyle::secondarySelection(palette));
if (!m_forceShapeOutlines) {
helper.drawRubberLine(shape->outlineRect());
@@ -132,7 +135,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, m_selection, converter, m_handleRadius, m_decorationThickness);
- helper.setHandleStyle(KisHandleStyle::primarySelection());
+ helper.setHandleStyle(KisHandleStyle::primarySelection(palette));
helper.drawRubberLine(handleArea);
}
@@ -141,7 +144,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
if (editable) {
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, m_selection, converter, m_handleRadius, m_decorationThickness);
- helper.setHandleStyle(KisHandleStyle::primarySelection());
+ helper.setHandleStyle(KisHandleStyle::primarySelection(palette));
QPolygonF outline = handleArea;
@@ -156,7 +159,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
helper.drawHandleRect(0.5 * (outline.value(3) + outline.value(0)));
QPointF hotPos = KoFlake::anchorToPoint(m_hotPosition, handleArea);
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles(palette));
helper.drawHandleRect(hotPos);
}
}
@@ -182,6 +185,7 @@ void SelectionDecorator::paintGradientHandles(KoShape *shape, KoFlake::FillVaria
{
KoShapeGradientHandles gradientHandles(fillVariant, shape);
QVector<KoShapeGradientHandles::Handle> handles = gradientHandles.handles();
+ const KisHandlePalette palette = m_rendererInterface->handlePaletteForDisplayColorSpace();
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, shape, converter, m_handleRadius, m_decorationThickness);
@@ -192,12 +196,12 @@ void SelectionDecorator::paintGradientHandles(KoShape *shape, KoFlake::FillVaria
KIS_SAFE_ASSERT_RECOVER_NOOP(handles.size() == 2);
if (handles.size() == 2) {
- helper.setHandleStyle(KisHandleStyle::gradientArrows());
+ helper.setHandleStyle(KisHandleStyle::gradientArrows(palette));
helper.drawGradientArrow(t.map(handles[0].pos), t.map(handles[1].pos), 1.5 * m_handleRadius);
}
}
- helper.setHandleStyle(KisHandleStyle::gradientHandles());
+ helper.setHandleStyle(KisHandleStyle::gradientHandles(palette));
Q_FOREACH (const KoShapeGradientHandles::Handle &h, handles) {
if (h.type == KoShapeGradientHandles::Handle::RadialCenter) {
@@ -214,10 +218,11 @@ void SelectionDecorator::paintMeshGradientHandles(KoShape *shape,
const KoViewConverter &converter)
{
KoShapeMeshGradientHandles gradientHandles(fillVariant, shape);
+ const KisHandlePalette palette = m_rendererInterface->handlePaletteForDisplayColorSpace();
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelperView(&painter, shape, converter, m_handleRadius, m_decorationThickness);
- helper.setHandleStyle(KisHandleStyle::secondarySelection());
+ helper.setHandleStyle(KisHandleStyle::secondarySelection(palette));
helper.drawPath(gradientHandles.path());
@@ -234,7 +239,7 @@ void SelectionDecorator::paintMeshGradientHandles(KoShape *shape,
}
}
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandlesWithSolidOutline());
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandlesWithSolidOutline(palette));
// highlight the selected handle (only corner)
if (m_selectedMeshHandle.type == KoShapeMeshGradientHandles::Handle::Corner) {
diff --git a/plugins/tools/defaulttool/defaulttool/SelectionDecorator.h b/plugins/tools/defaulttool/defaulttool/SelectionDecorator.h
index 76f5563184..9c97573e28 100644
--- a/plugins/tools/defaulttool/defaulttool/SelectionDecorator.h
+++ b/plugins/tools/defaulttool/defaulttool/SelectionDecorator.h
@@ -18,6 +18,7 @@
class KoSelection;
class KoCanvasResourceProvider;
+class KoColorDisplayRendererInterface;
static const struct DecoratorIconPositions {
QPoint uiOffset = QPoint(0, 40);
@@ -35,7 +36,7 @@ public:
* @param rotationHandles if true; the rotation handles will be drawn
* @param shearHandles if true; the shearhandles will be drawn
*/
- SelectionDecorator(KoCanvasResourceProvider *resourceManager);
+ SelectionDecorator(KoCanvasResourceProvider *resourceManager, KoColorDisplayRendererInterface *displayInterface);
~SelectionDecorator() {}
/**
@@ -89,6 +90,7 @@ private:
private:
KoFlake::AnchorPosition m_hotPosition;
KoSelection *m_selection {nullptr};
+ KoColorDisplayRendererInterface *m_rendererInterface {nullptr};
KoShapeMeshGradientHandles::Handle m_currentHoveredMeshHandle;
KoShapeMeshGradientHandles::Handle m_selectedMeshHandle;
int m_handleRadius {7};
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.cpp b/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.cpp
index 9a0e56c909..9d9b020b4a 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.cpp
+++ b/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.cpp
@@ -89,9 +89,10 @@ void ShapeGradientEditStrategy::finishInteraction(Qt::KeyboardModifiers modifier
tool()->canvas()->snapGuide()->reset();
}
-void ShapeGradientEditStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void ShapeGradientEditStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface);
}
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.h b/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.h
index 009a2ab741..278714fe98 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.h
+++ b/plugins/tools/defaulttool/defaulttool/ShapeGradientEditStrategy.h
@@ -24,7 +24,7 @@ public:
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
void finishInteraction(Qt::KeyboardModifiers modifiers) override;
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
struct Private;
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.cpp b/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.cpp
index d2dabdfdac..79e1153ebd 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.cpp
+++ b/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.cpp
@@ -105,8 +105,9 @@ void ShapeMoveStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
Q_UNUSED(modifiers);
}
-void ShapeMoveStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void ShapeMoveStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface);
}
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.h b/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.h
index 82e58aee86..2f766f50ae 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.h
+++ b/plugins/tools/defaulttool/defaulttool/ShapeMoveStrategy.h
@@ -39,7 +39,7 @@ public:
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
void finishInteraction(Qt::KeyboardModifiers modifiers) override;
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
void moveSelection(const QPointF &diff);
QList<QPointF> m_previousPositions;
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp b/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
index 7f6f3672f9..f65ca623e1 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
+++ b/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
@@ -223,8 +223,9 @@ void ShapeResizeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
Q_UNUSED(modifiers);
}
-void ShapeResizeStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void ShapeResizeStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface);
}
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.h b/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.h
index 92278a2454..136876524a 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.h
+++ b/plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.h
@@ -39,7 +39,7 @@ public:
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
void finishInteraction(Qt::KeyboardModifiers modifiers) override;
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
void resizeBy(const QPointF &stillPoint, qreal zoomX, qreal zoomY);
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.cpp b/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.cpp
index 62dc0ebbaf..03dd85cc14 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.cpp
+++ b/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.cpp
@@ -16,6 +16,7 @@
#include <KoCanvasResourceProvider.h>
#include <commands/KoShapeTransformCommand.h>
#include <KoShapeBulkActionLock.h>
+#include <KoColorDisplayRendererInterface.h>
#include <QPointF>
#include <math.h>
@@ -84,11 +85,14 @@ void ShapeRotateStrategy::rotateBy(qreal angle)
KoShapeBulkActionLock::bulkShapesUpdate(lock.unlock());
}
-void ShapeRotateStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void ShapeRotateStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
// paint the rotation center
- painter.setPen(QPen(Qt::red));
- painter.setBrush(QBrush(Qt::red));
+ KoColor c;
+ c.fromQColor(Qt::red);
+ QColor red = displayRendererInterface->convertColorToDisplayColorSpace(c);
+ painter.setPen(QPen(red));
+ painter.setBrush(QBrush(red));
painter.setRenderHint(QPainter::Antialiasing, true);
QRectF circle(0, 0, handleRadius(), handleRadius());
circle.moveCenter(converter.documentToView(m_rotationCenter));
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.h b/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.h
index 41b30a7d78..cd930de06f 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.h
+++ b/plugins/tools/defaulttool/defaulttool/ShapeRotateStrategy.h
@@ -40,7 +40,7 @@ public:
{
Q_UNUSED(modifiers);
}
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
void rotateBy(qreal angle);
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.cpp b/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.cpp
index efc5faf7f1..c36d6bbb79 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.cpp
+++ b/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.cpp
@@ -159,10 +159,11 @@ void ShapeShearStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardModif
m_shearMatrix = matrix;
}
-void ShapeShearStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void ShapeShearStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
Q_UNUSED(painter);
Q_UNUSED(converter);
+ Q_UNUSED(displayRendererInterface);
}
KUndo2Command *ShapeShearStrategy::createCommand()
diff --git a/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.h b/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.h
index c3d25ceb55..e0f92c259a 100644
--- a/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.h
+++ b/plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.h
@@ -41,7 +41,7 @@ public:
{
Q_UNUSED(modifiers);
}
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
QPointF m_start;
diff --git a/plugins/tools/selectiontools/KisToolSelectMagnetic.cc b/plugins/tools/selectiontools/KisToolSelectMagnetic.cc
index a5c8249b7d..db57538436 100644
--- a/plugins/tools/selectiontools/KisToolSelectMagnetic.cc
+++ b/plugins/tools/selectiontools/KisToolSelectMagnetic.cc
@@ -20,6 +20,7 @@
#include <KoPathShape.h>
#include <KoColorSpace.h>
#include <KoCompositeOp.h>
+#include <KoColorDisplayRendererInterface.h>
#include <KoViewConverter.h>
#include <kis_layer.h>
@@ -629,15 +630,16 @@ void KisToolSelectMagnetic::paint(QPainter& gc, const KoViewConverter &converter
void KisToolSelectMagnetic::drawAnchors(QPainter &gc)
{
+ const KisHandlePalette palette = canvas()->displayRendererInterface()->handlePaletteForDisplayColorSpace();
int sides = updateInitialAnchorBounds(m_anchorPoints.first());
Q_FOREACH (const QPoint pt, m_anchorPoints) {
KisHandlePainterHelper helper(&gc, handleRadius(), decorationThickness());
QRect r(QPoint(0, 0), QSize(sides, sides));
r.moveCenter(pt);
if (r.contains(m_lastCursorPos.toPoint())) {
- helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
+ helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles(palette));
} else {
- helper.setHandleStyle(KisHandleStyle::primarySelection());
+ helper.setHandleStyle(KisHandleStyle::primarySelection(palette));
}
helper.drawHandleRect(pixelToView(pt), 4, QPoint(0, 0));
}
diff --git a/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.cpp b/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.cpp
index 6564056d33..d35458c364 100644
--- a/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.cpp
+++ b/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.cpp
@@ -8,6 +8,7 @@
#include "SvgTextTool.h"
#include <KoPathShape.h>
#include <KoPathSegment.h>
+#include <KoColorDisplayRendererInterface.h>
#include <KoSvgTextProperties.h>
#include <KisHandlePainterHelper.h>
@@ -134,13 +135,14 @@ KoSvgTextProperties getProperties(bool isPadding, QLineF line, KoSvgTextProperti
return previous;
}
-void SvgChangeTextPaddingMarginStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void SvgChangeTextPaddingMarginStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
if (!(m_referenceShape && m_shape)) return;
painter.save();
KisHandlePainterHelper handlePainter =
KoShape::createHandlePainterHelperView(&painter, m_shape, converter, handleRadius(), decorationThickness());
- handlePainter.setHandleStyle(KisHandleStyle::selectedPrimaryHandles());
+ handlePainter.setHandleStyle(KisHandleStyle::selectedPrimaryHandles(displayRendererInterface->handlePaletteForDisplayColorSpace()));
+
const QLineF line = getLine(m_lastMousePos, m_referenceShape, m_isPadding);
const QTransform lineTf = m_referenceShape->absoluteTransformation() * m_shape->absoluteTransformation().inverted();
diff --git a/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.h b/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.h
index 702fa3e4b1..405f7e8be6 100644
--- a/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.h
+++ b/plugins/tools/svgtexttool/SvgChangeTextPaddingMarginStrategy.h
@@ -39,7 +39,7 @@ private:
// KoInteractionStrategy interface
public:
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
void finishInteraction(Qt::KeyboardModifiers modifiers) override;
diff --git a/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp b/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp
index fd47732a80..5da1100957 100644
--- a/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp
+++ b/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp
@@ -27,16 +27,16 @@
#include "kis_global.h"
#include "kis_shape_layer.h"
#include "kundo2command.h"
+#include <KoColorDisplayRendererInterface.h>
#include <KoPathShape.h>
#include <KoPathSegment.h>
-SvgCreateTextStrategy::SvgCreateTextStrategy(SvgTextTool *tool, const QPointF &clicked, KisHandlePalette handlePalette, KoShape *shape)
+SvgCreateTextStrategy::SvgCreateTextStrategy(SvgTextTool *tool, const QPointF &clicked, KoShape *shape)
: KoInteractionStrategy(tool)
, m_dragStart(clicked)
, m_dragEnd(clicked)
, m_flowShape(shape)
- , m_handlePalette(handlePalette)
{
KoSvgTextProperties properties = tool->propertiesForNewText();
properties.inheritFrom(KoSvgTextProperties::defaultProperties(), true);
@@ -46,14 +46,14 @@ SvgCreateTextStrategy::SvgCreateTextStrategy(SvgTextTool *tool, const QPointF &c
m_minSizeInline = {lineHeight, lineHeight};
}
-void SvgCreateTextStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void SvgCreateTextStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
const QTransform originalPainterTransform = painter.transform();
painter.setTransform(converter.documentToView(), true);
KisHandlePainterHelper handlePainter(&painter, originalPainterTransform, 0.0, decorationThickness());
const QPolygonF poly(QRectF(m_dragStart, m_dragEnd));
- handlePainter.setHandleStyle(KisHandleStyle::primarySelection(m_handlePalette));
+ handlePainter.setHandleStyle(KisHandleStyle::primarySelection(displayRendererInterface->handlePaletteForDisplayColorSpace()));
handlePainter.drawRubberLine(poly);
}
diff --git a/plugins/tools/svgtexttool/SvgCreateTextStrategy.h b/plugins/tools/svgtexttool/SvgCreateTextStrategy.h
index 00502370e3..0f692272fd 100644
--- a/plugins/tools/svgtexttool/SvgCreateTextStrategy.h
+++ b/plugins/tools/svgtexttool/SvgCreateTextStrategy.h
@@ -21,10 +21,10 @@ class KoShape;
class SvgCreateTextStrategy : public KoInteractionStrategy
{
public:
- SvgCreateTextStrategy(SvgTextTool *tool, const QPointF &clicked, KisHandlePalette palette = KisHandlePalette(), KoShape *shape = nullptr);
+ SvgCreateTextStrategy(SvgTextTool *tool, const QPointF &clicked, KoShape *shape = nullptr);
~SvgCreateTextStrategy() override = default;
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
void cancelInteraction() override;
@@ -38,7 +38,6 @@ private:
QPointF m_dragEnd;
QSizeF m_minSizeInline;
KoShape *m_flowShape;
- KisHandlePalette m_handlePalette;
Qt::KeyboardModifiers m_modifiers;
};
diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cpp
index a024b0df2c..44df2b6e8f 100644
--- a/plugins/tools/svgtexttool/SvgTextTool.cpp
+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp
@@ -685,16 +685,11 @@ void SvgTextTool::paint(QPainter &gc, const KoViewConverter &converter)
{
if (!isActivated()) return;
- KisHandlePalette handlePalette;
- QPalette systemPalette = qApp->palette();
- KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
- if (kisCanvas) {
- handlePalette = kisCanvas->displayColorConverter()->handlePaletteForDisplayColorSpace();
- systemPalette = kisCanvas->displayColorConverter()->systemPaletteForDisplayColorSpace();
- }
+ KisHandlePalette handlePalette = canvas()->displayRendererInterface()->handlePaletteForDisplayColorSpace();
+ QPalette systemPalette = canvas()->displayRendererInterface()->systemPaletteForDisplayColorSpace();
if (m_dragging == DragMode::Create || m_dragging == DragMode::InShapeOffset) {
- m_interactionStrategy->paint(gc, converter);
+ m_interactionStrategy->paint(gc, converter, canvas()->displayRendererInterface());
}
KoSvgTextShape *shape = selectedShape();
@@ -864,7 +859,7 @@ void SvgTextTool::mousePressEvent(KoPointerEvent *event)
if (!selectedShape && !hoveredShape && !hoveredFlowShape && !crossLayerPossible) {
QPointF point = canvas()->snapGuide()->snap(event->point, event->modifiers());
- m_interactionStrategy.reset(new SvgCreateTextStrategy(this, point, handlePalette));
+ m_interactionStrategy.reset(new SvgCreateTextStrategy(this, point));
m_dragging = DragMode::Create;
event->accept();
} else if (hoveredShape) {
@@ -878,7 +873,7 @@ void SvgTextTool::mousePressEvent(KoPointerEvent *event)
event->accept();
} else if (hoveredFlowShape) {
QPointF point = canvas()->snapGuide()->snap(event->point, event->modifiers());
- m_interactionStrategy.reset(new SvgCreateTextStrategy(this, point, handlePalette, hoveredFlowShape));
+ m_interactionStrategy.reset(new SvgCreateTextStrategy(this, point, hoveredFlowShape));
m_dragging = DragMode::Create;
event->accept();
} else if (crossLayerPossible) {
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index 6cb2176283..16e6dc8d3f 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -25,6 +25,7 @@
#include <KoKeepShapesSelectedCommand.h>
#include <QtMath>
#include <KoSvgTextShape.h>
+#include <KoColorDisplayRendererInterface.h>
CutThroughShapeStrategy::CutThroughShapeStrategy(KoToolBase *tool, KoSelection *selection, const QList<KoShape *> &shapes, QPointF startPoint, const GutterWidthsConfig &width)
@@ -314,11 +315,13 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
}
-void CutThroughShapeStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void CutThroughShapeStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
painter.save();
- QColor semitransparentGray = QColor(Qt::darkGray);
+ KoColor c;
+ c.fromQColor(Qt::darkGray);
+ QColor semitransparentGray = displayRendererInterface->convertColorToDisplayColorSpace(c);
semitransparentGray.setAlphaF(0.6);
QPen pen = QPen(QBrush(semitransparentGray), 2);
painter.setPen(pen);
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.h b/plugins/tools/tool_knife/CutThroughShapeStrategy.h
index ff73828e97..e8640afe64 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.h
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.h
@@ -32,7 +32,7 @@ public:
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
void finishInteraction(Qt::KeyboardModifiers modifiers) override;
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
diff --git a/plugins/tools/tool_knife/RemoveGutterStrategy.cpp b/plugins/tools/tool_knife/RemoveGutterStrategy.cpp
index c37c2b27e8..fc75a2257e 100644
--- a/plugins/tools/tool_knife/RemoveGutterStrategy.cpp
+++ b/plugins/tools/tool_knife/RemoveGutterStrategy.cpp
@@ -23,6 +23,7 @@
#include <KoShapeController.h>
#include <kundo2command.h>
#include <KoKeepShapesSelectedCommand.h>
+#include <KoColorDisplayRendererInterface.h>
@@ -315,10 +316,12 @@ void RemoveGutterStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
}
-void RemoveGutterStrategy::paint(QPainter &painter, const KoViewConverter &converter)
+void RemoveGutterStrategy::paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface)
{
painter.save();
- painter.setPen(QPen(QBrush(Qt::darkGray), 2));
+ KoColor c;
+ c.fromQColor(Qt::darkGray);
+ painter.setPen(QPen(QBrush(displayRendererInterface->convertColorToDisplayColorSpace(c)), 2));
QLineF line = converter.documentToView().map(QLineF(m_startPoint, m_endPoint));
if (line.length() > 0) {
diff --git a/plugins/tools/tool_knife/RemoveGutterStrategy.h b/plugins/tools/tool_knife/RemoveGutterStrategy.h
index 0e4782b100..9b3bdebb80 100644
--- a/plugins/tools/tool_knife/RemoveGutterStrategy.h
+++ b/plugins/tools/tool_knife/RemoveGutterStrategy.h
@@ -25,7 +25,7 @@ public:
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
void finishInteraction(Qt::KeyboardModifiers modifiers) override;
- void paint(QPainter &painter, const KoViewConverter &converter) override;
+ void paint(QPainter &painter, const KoViewConverter &converter, const KoColorDisplayRendererInterface *displayRendererInterface) override;
private:
QPointF m_startPoint = QPointF();