[krita/krita/4.0] /: Make color pick tools pick from a special device
Dmitry Kazakov
null at kde.org
Sat Apr 7 13:44:41 UTC 2018
Git commit 0a4a1f88cc2be3d7a395b9cd3d1eab6f1d5a42e6 by Dmitry Kazakov.
Committed on 07/04/2018 at 13:28.
Pushed by dkazakov into branch 'krita/4.0'.
Make color pick tools pick from a special device
(which is coloring device for colorize masks)
It means that from now on, "Pick from layer" color picker mode will pick
from the filled area, not from the key strokes
BUG:392241
CC:kimageshop at kde.org
M +5 -0 libs/image/kis_base_node.cpp
M +7 -0 libs/image/kis_base_node.h
M +7 -0 libs/image/lazybrush/kis_colorize_mask.cpp
M +2 -0 libs/image/lazybrush/kis_colorize_mask.h
M +1 -1 libs/ui/tool/kis_tool_paint.cc
M +2 -2 plugins/tools/basictools/kis_tool_colorpicker.cc
https://commits.kde.org/krita/0a4a1f88cc2be3d7a395b9cd3d1eab6f1d5a42e6
diff --git a/libs/image/kis_base_node.cpp b/libs/image/kis_base_node.cpp
index 34ba7b2d797..7c3a70103d6 100644
--- a/libs/image/kis_base_node.cpp
+++ b/libs/image/kis_base_node.cpp
@@ -107,6 +107,11 @@ KisBaseNode::~KisBaseNode()
delete m_d;
}
+KisPaintDeviceSP KisBaseNode::colorPickSourceDevice() const
+{
+ return projection();
+}
+
quint8 KisBaseNode::opacity() const
{
if (m_d->opacityChannel) {
diff --git a/libs/image/kis_base_node.h b/libs/image/kis_base_node.h
index 18ae3b62f5e..991d8c14bb1 100644
--- a/libs/image/kis_base_node.h
+++ b/libs/image/kis_base_node.h
@@ -156,6 +156,13 @@ public:
*/
virtual KisPaintDeviceSP projection() const = 0;
+ /**
+ * @return a special device from where the color picker tool should pick
+ * color when in layer-only mode. For most of the nodes just shortcuts
+ * to projection() device. TODO: can it be null?
+ */
+ virtual KisPaintDeviceSP colorPickSourceDevice() const;
+
virtual const KoColorSpace *colorSpace() const = 0;
/**
diff --git a/libs/image/lazybrush/kis_colorize_mask.cpp b/libs/image/lazybrush/kis_colorize_mask.cpp
index c28b6b14ce9..2572e4ea1ea 100644
--- a/libs/image/lazybrush/kis_colorize_mask.cpp
+++ b/libs/image/lazybrush/kis_colorize_mask.cpp
@@ -462,6 +462,13 @@ KisPaintDeviceSP KisColorizeMask::coloringProjection() const
return m_d->coloringProjection;
}
+KisPaintDeviceSP KisColorizeMask::colorPickSourceDevice() const
+{
+ return
+ m_d->shouldShowColoring() && !m_d->coloringProjection->extent().isEmpty() ?
+ m_d->coloringProjection : projection();
+}
+
QIcon KisColorizeMask::icon() const
{
return KisIconUtils::loadIcon("colorizeMask");
diff --git a/libs/image/lazybrush/kis_colorize_mask.h b/libs/image/lazybrush/kis_colorize_mask.h
index e56995a02a9..5bc4dd2f4ce 100644
--- a/libs/image/lazybrush/kis_colorize_mask.h
+++ b/libs/image/lazybrush/kis_colorize_mask.h
@@ -62,6 +62,8 @@ public:
KisPaintDeviceSP paintDevice() const override;
KisPaintDeviceSP coloringProjection() const;
+ KisPaintDeviceSP colorPickSourceDevice() const override;
+
KisNodeSP clone() const override {
return KisNodeSP(new KisColorizeMask(*this));
}
diff --git a/libs/ui/tool/kis_tool_paint.cc b/libs/ui/tool/kis_tool_paint.cc
index 69c1ecf937b..f7e8bc8539a 100644
--- a/libs/ui/tool/kis_tool_paint.cc
+++ b/libs/ui/tool/kis_tool_paint.cc
@@ -378,7 +378,7 @@ void KisToolPaint::addPickerJob(const PickingJob &pickingJob)
m_pickingResource = colorPreviewResourceId(pickingJob.action);
KisPaintDeviceSP device = fromCurrentNode ?
- currentNode()->projection() : image()->projection();
+ currentNode()->colorPickSourceDevice() : image()->projection();
image()->addJob(m_pickerStrokeId,
new KisColorPickerStrokeStrategy::Data(device, imagePoint));
diff --git a/plugins/tools/basictools/kis_tool_colorpicker.cc b/plugins/tools/basictools/kis_tool_colorpicker.cc
index f9de3b477b7..2be9d639dc4 100644
--- a/plugins/tools/basictools/kis_tool_colorpicker.cc
+++ b/plugins/tools/basictools/kis_tool_colorpicker.cc
@@ -119,8 +119,8 @@ void KisToolColorPicker::pickColor(const QPointF& pos)
KisPaintDeviceSP dev;
if (m_optionsWidget->cmbSources->currentIndex() != SAMPLE_MERGED &&
- currentNode() && currentNode()->projection()) {
- dev = currentNode()->projection();
+ currentNode() && currentNode()->colorPickSourceDevice()) {
+ dev = currentNode()->colorPickSourceDevice();
}
else {
imageLocker.reset(new boost::lock_guard<KisImage>(*currentImage()));
More information about the kimageshop
mailing list