[krita] /: Make color pick tools pick from a special device
Dmitry Kazakov
null at kde.org
Thu Apr 5 12:52:31 UTC 2018
Git commit eebaf3891d4514c30987de4593ae85d0205ba3be by Dmitry Kazakov.
Committed on 05/04/2018 at 12:52.
Pushed by dkazakov into branch 'master'.
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/eebaf3891d4514c30987de4593ae85d0205ba3be
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 cbbe224e004..7d683588c7c 100644
--- a/libs/ui/tool/kis_tool_paint.cc
+++ b/libs/ui/tool/kis_tool_paint.cc
@@ -397,7 +397,7 @@ void KisToolPaint::addPickerJob(const PickingJob &pickingJob)
}
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 117fc5e49da..0d1259682b4 100644
--- a/plugins/tools/basictools/kis_tool_colorpicker.cc
+++ b/plugins/tools/basictools/kis_tool_colorpicker.cc
@@ -139,8 +139,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