Commit ac35d0e9 authored by Simon Repp's avatar Simon Repp Committed by Halla Rempt
Browse files

Consistently use "Color Sampler (Tool)" terminology in interface and code

parent 149de529
/* XPM */ /* XPM */
static char * color_picker_image_background_xpm[] = { static char * color_sampler_image_background_xpm[] = {
"33 31 3 1", "33 31 3 1",
" c None", " c None",
". c #FFFFFF", ". c #FFFFFF",
......
/* XPM */ /* XPM */
static char * color_picker_image_foreground_xpm[] = { static char * color_sampler_image_foreground_xpm[] = {
"33 31 3 1", "33 31 3 1",
" c None", " c None",
". c #FFFFFF", ". c #FFFFFF",
......
/* XPM */ /* XPM */
static char * color_picker_layer_background_xpm[] = { static char * color_sampler_layer_background_xpm[] = {
"33 31 3 1", "33 31 3 1",
" c None", " c None",
". c #FFFFFF", ". c #FFFFFF",
......
/* XPM */ /* XPM */
static char * color_picker_layer_foreground_xpm[] = { static char * color_sampler_layer_foreground_xpm[] = {
"33 31 3 1", "33 31 3 1",
" c None", " c None",
". c #FFFFFF", ". c #FFFFFF",
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
--> -->
<RCC version="1.0"> <RCC version="1.0">
<qresource> <qresource>
<file>color-picker_image_background.xpm</file> <file>color-sampler_image_background.xpm</file>
<file>color-picker_image_foreground.xpm</file> <file>color-sampler_image_foreground.xpm</file>
<file>color-picker_layer_background.xpm</file> <file>color-sampler_layer_background.xpm</file>
<file>color-picker_layer_foreground.xpm</file> <file>color-sampler_layer_foreground.xpm</file>
<file>cursor-cross.xpm</file> <file>cursor-cross.xpm</file>
<file>cursor-pixel-white.xpm</file> <file>cursor-pixel-white.xpm</file>
<file>cursor-pixel-black.xpm</file> <file>cursor-pixel-black.xpm</file>
...@@ -27,6 +27,6 @@ ...@@ -27,6 +27,6 @@
<file>zoom_discrete.xpm</file> <file>zoom_discrete.xpm</file>
<file>zoom_smooth.xpm</file> <file>zoom_smooth.xpm</file>
<file>tool_freehand_cursor.png</file> <file>tool_freehand_cursor.png</file>
<file>tool_color_picker_cursor.png</file> <file>tool_color_sampler_cursor.png</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -373,6 +373,6 @@ actionButtonDoubleClick=erase_action ...@@ -373,6 +373,6 @@ actionButtonDoubleClick=erase_action
actionGestureCircleCCW=shift_brush_color_counter_clockwise actionGestureCircleCCW=shift_brush_color_counter_clockwise
actionGestureCircleCW=shift_brush_color_clockwise actionGestureCircleCW=shift_brush_color_clockwise
actionGestureSwipeDown=make_brush_color_darker actionGestureSwipeDown=make_brush_color_darker
actionGestureSwipeRight=KritaSelected/KisToolColorPicker actionGestureSwipeRight=KritaSelected/KisToolColorSampler
actionGestureSwipeLeft=KritaShape/KisToolBrush actionGestureSwipeLeft=KritaShape/KisToolBrush
actionGestureSwipeUp=make_brush_color_lighter actionGestureSwipeUp=make_brush_color_lighter
...@@ -220,7 +220,7 @@ krita_filter_top edge detections=none ...@@ -220,7 +220,7 @@ krita_filter_top edge detections=none
krita_filter_unsharp=none krita_filter_unsharp=none
krita_filter_waveletnoisereducer=none krita_filter_waveletnoisereducer=none
krita_filter_wave=none krita_filter_wave=none
KritaSelected/KisToolColorPicker=none KritaSelected/KisToolColorSampler=none
KritaShape/KisToolBrush=B KritaShape/KisToolBrush=B
KritaShape/KisToolDyna=none KritaShape/KisToolDyna=none
KritaShape/KisToolEllipse=none KritaShape/KisToolEllipse=none
......
...@@ -220,7 +220,7 @@ krita_filter_top edge detections=none ...@@ -220,7 +220,7 @@ krita_filter_top edge detections=none
krita_filter_unsharp=none krita_filter_unsharp=none
krita_filter_waveletnoisereducer=none krita_filter_waveletnoisereducer=none
krita_filter_wave=none krita_filter_wave=none
KritaSelected/KisToolColorPicker=I KritaSelected/KisToolColorSampler=I
KritaShape/KisToolBrush=B KritaShape/KisToolBrush=B
KritaShape/KisToolDyna=none KritaShape/KisToolDyna=none
KritaShape/KisToolEllipse=none KritaShape/KisToolEllipse=none
......
...@@ -222,7 +222,7 @@ krita_filter_top edge detections=none ...@@ -222,7 +222,7 @@ krita_filter_top edge detections=none
krita_filter_unsharp=none krita_filter_unsharp=none
krita_filter_waveletnoisereducer=none krita_filter_waveletnoisereducer=none
krita_filter_wave=none krita_filter_wave=none
KritaSelected/KisToolColorPicker=I KritaSelected/KisToolColorSampler=I
KritaShape/KisToolBrush=B KritaShape/KisToolBrush=B
KritaShape/KisToolDyna=none KritaShape/KisToolDyna=none
KritaShape/KisToolEllipse=none KritaShape/KisToolEllipse=none
......
...@@ -1402,12 +1402,12 @@ ...@@ -1402,12 +1402,12 @@
<isCheckable>false</isCheckable> <isCheckable>false</isCheckable>
<statusTip></statusTip> <statusTip></statusTip>
</Action> </Action>
<Action name="KritaSelected/KisToolColorPicker">
<icon>krita_tool_color_picker</icon> <icon>krita_tool_color_sampler</icon>
<text>Color Picker</text> <text>Color Sampler</text>
<whatsThis></whatsThis> <whatsThis></whatsThis>
<toolTip>Select a color from the image or current layer</toolTip> <toolTip>Sample a color from the image or current layer</toolTip>
<iconText>Color Picker</iconText> <iconText>Color Sampler</iconText>
<shortcut>P</shortcut> <shortcut>P</shortcut>
<isCheckable>false</isCheckable> <isCheckable>false</isCheckable>
<statusTip></statusTip> <statusTip></statusTip>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<file>dark_format-fill-color.svg</file> <file>dark_format-fill-color.svg</file>
<file>dark_krita_draw_path.svg</file> <file>dark_krita_draw_path.svg</file>
<file>dark_krita_tool_color_fill.svg</file> <file>dark_krita_tool_color_fill.svg</file>
<file>dark_krita_tool_color_picker.svg</file> <file>dark_krita_tool_color_sampler.svg</file>
<file>dark_krita_tool_dyna.svg</file> <file>dark_krita_tool_dyna.svg</file>
<file>dark_krita_tool_ellipse.svg</file> <file>dark_krita_tool_ellipse.svg</file>
<file>dark_krita_tool_freehand.svg</file> <file>dark_krita_tool_freehand.svg</file>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<file>light_format-fill-color.svg</file> <file>light_format-fill-color.svg</file>
<file>light_krita_draw_path.svg</file> <file>light_krita_draw_path.svg</file>
<file>light_krita_tool_color_fill.svg</file> <file>light_krita_tool_color_fill.svg</file>
<file>light_krita_tool_color_picker.svg</file> <file>light_krita_tool_color_sampler.svg</file>
<file>light_krita_tool_dyna.svg</file> <file>light_krita_tool_dyna.svg</file>
<file>light_krita_tool_ellipse.svg</file> <file>light_krita_tool_ellipse.svg</file>
<file>light_krita_tool_freehand.svg</file> <file>light_krita_tool_freehand.svg</file>
......
...@@ -398,7 +398,7 @@ Q_SIGNALS: ...@@ -398,7 +398,7 @@ Q_SIGNALS:
* Emitted when this tool wants itself to temporarily be replaced by another tool. * Emitted when this tool wants itself to temporarily be replaced by another tool.
* For instance, a paint tool could desire to be * For instance, a paint tool could desire to be
* temporarily replaced by a pan tool which could be temporarily * temporarily replaced by a pan tool which could be temporarily
* replaced by a colorpicker. * replaced by a color sampler.
* @param id the identification of the desired tool * @param id the identification of the desired tool
*/ */
void activateTemporary(const QString &id); void activateTemporary(const QString &id);
......
...@@ -18,24 +18,24 @@ namespace Acs { ...@@ -18,24 +18,24 @@ namespace Acs {
class PixelCacheRenderer { class PixelCacheRenderer {
public: public:
/** /**
* \p Picker class must provide one method: * \p Sampler class must provide one method:
* - KoColor Picker::colorAt(float x, float y); * - KoColor Sampler::colorAt(float x, float y);
* *
* How to handle High DPI: * How to handle High DPI:
* - pickRect - is in device independent pixels coordinates space * - sampleRect - is in device independent pixels coordinates space
* (amount of space on the widget) * (amount of space on the widget)
* - devicePixelRatioF - the amount of UI scaling * - devicePixelRatioF - the amount of UI scaling
* - pixelCache and realPixelCache gets the size of * - pixelCache and realPixelCache gets the size of
* pickRect.size()*devicePixelRatioF * sampleRect.size()*devicePixelRatioF
* and sets the device pixel ratio, * and sets the device pixel ratio,
* and color pickers need to take it into account. * and color samplers need to take it into account.
* That way you can paint on the cache the same way you'd paint on a low dpi display * That way you can paint on the cache the same way you'd paint on a low dpi display
* and then just use painter->drawImage() and it works. * and then just use painter->drawImage() and it works.
*/ */
template <class Picker> template <class Sampler>
static void render(Picker *picker, static void render(Sampler *sampler,
const KisDisplayColorConverter *converter, const KisDisplayColorConverter *converter,
const QRect &pickRect, const QRect &sampleRect,
KisPaintDeviceSP &realPixelCache, KisPaintDeviceSP &realPixelCache,
QImage &pixelCache, QImage &pixelCache,
QPoint &pixelCacheOffset, QPoint &pixelCacheOffset,
...@@ -50,11 +50,11 @@ namespace Acs { ...@@ -50,11 +50,11 @@ namespace Acs {
KoColor color; KoColor color;
QRect pickRectHighDPI = QRect(pickRect.topLeft(), pickRect.size()*devicePixelRatioF); QRect sampleRectHighDPI = QRect(sampleRect.topLeft(), sampleRect.size()*devicePixelRatioF);
KisSequentialIterator it(realPixelCache, pickRectHighDPI); KisSequentialIterator it(realPixelCache, sampleRectHighDPI);
while (it.nextPixel()) { while (it.nextPixel()) {
color = picker->colorAt(it.x()/devicePixelRatioF, it.y()/devicePixelRatioF); color = sampler->colorAt(it.x()/devicePixelRatioF, it.y()/devicePixelRatioF);
memcpy(it.rawData(), color.data(), pixelSize); memcpy(it.rawData(), color.data(), pixelSize);
} }
...@@ -62,7 +62,7 @@ namespace Acs { ...@@ -62,7 +62,7 @@ namespace Acs {
// NOTE: toQImage() function of the converter copies exactBounds() only! // NOTE: toQImage() function of the converter copies exactBounds() only!
pixelCache = converter->toQImage(realPixelCache); pixelCache = converter->toQImage(realPixelCache);
pixelCache.setDevicePixelRatio(devicePixelRatioF); pixelCache.setDevicePixelRatio(devicePixelRatioF);
pixelCacheOffset = realPixelCache->exactBounds().topLeft()/devicePixelRatioF - pickRect.topLeft(); pixelCacheOffset = realPixelCache->exactBounds().topLeft()/devicePixelRatioF - sampleRect.topLeft();
} }
}; };
} }
......
...@@ -38,7 +38,7 @@ namespace Acs { ...@@ -38,7 +38,7 @@ namespace Acs {
} }
template <class PaintDeviceSP> template <class PaintDeviceSP>
KoColor pickColor(PaintDeviceSP device, const QPoint &pt) { KoColor sampleColor(PaintDeviceSP device, const QPoint &pt) {
KoColor color; KoColor color;
if (device) { if (device) {
(void) device->pixel(pt.x(), pt.y(), &color); (void) device->pixel(pt.x(), pt.y(), &color);
......
...@@ -111,7 +111,7 @@ KisBaseNode::~KisBaseNode() ...@@ -111,7 +111,7 @@ KisBaseNode::~KisBaseNode()
delete m_d; delete m_d;
} }
KisPaintDeviceSP KisBaseNode::colorPickSourceDevice() const KisPaintDeviceSP KisBaseNode::colorSampleSourceDevice() const
{ {
return projection(); return projection();
} }
......
...@@ -146,11 +146,11 @@ public: ...@@ -146,11 +146,11 @@ public:
virtual KisPaintDeviceSP projection() const = 0; virtual KisPaintDeviceSP projection() const = 0;
/** /**
* @return a special device from where the color picker tool should pick * @return a special device from where the color sampler tool should sample
* color when in layer-only mode. For most of the nodes just shortcuts * color when in layer-only mode. For most of the nodes just shortcuts
* to projection() device. TODO: can it be null? * to projection() device. TODO: can it be null?
*/ */
virtual KisPaintDeviceSP colorPickSourceDevice() const; virtual KisPaintDeviceSP colorSampleSourceDevice() const;
virtual const KoColorSpace *colorSpace() const = 0; virtual const KoColorSpace *colorSpace() const = 0;
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
* SPDX-License-Identifier: GPL-2.0-or-later * SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#ifndef __KIS_CROSS_DEVICE_COLOR_PICKER_H #ifndef __KIS_CROSS_DEVICE_COLOR_SAMPLER_H
#define __KIS_CROSS_DEVICE_COLOR_PICKER_H #define __KIS_CROSS_DEVICE_COLOR_SAMPLER_H
#include "KoColorSpace.h" #include "KoColorSpace.h"
#include "kis_random_sub_accessor.h" #include "kis_random_sub_accessor.h"
struct PickerTraitReal { struct SamplerTraitReal {
typedef qreal coord_type; typedef qreal coord_type;
typedef KisRandomSubAccessorSP accessor_type; typedef KisRandomSubAccessorSP accessor_type;
static inline accessor_type createAccessor(KisPaintDeviceSP dev) { static inline accessor_type createAccessor(KisPaintDeviceSP dev) {
...@@ -28,7 +28,7 @@ struct PickerTraitReal { ...@@ -28,7 +28,7 @@ struct PickerTraitReal {
} }
}; };
struct PickerTraitInt { struct SamplerTraitInt {
typedef int coord_type; typedef int coord_type;
typedef KisRandomConstAccessorSP accessor_type; typedef KisRandomConstAccessorSP accessor_type;
static inline accessor_type createAccessor(KisPaintDeviceSP dev) { static inline accessor_type createAccessor(KisPaintDeviceSP dev) {
...@@ -46,11 +46,11 @@ struct PickerTraitInt { ...@@ -46,11 +46,11 @@ struct PickerTraitInt {
}; };
/** /**
* The picker class is supposed to help to pick color from one device * The sampler class is supposed to help to sample color from one device
* and automatically convert it to the color space of another device * and automatically convert it to the color space of another device
* *
* WARNING: Please note, that if you want to access correct rawData(), * WARNING: Please note, that if you want to access correct rawData(),
* you shouldn't store the picker class (as well as any * you shouldn't store the sampler class (as well as any
* random accessor class) across different calls to * random accessor class) across different calls to
* paintAt. This is related to the fact that * paintAt. This is related to the fact that
* KisRandomAccessor has an internal cache of the tiles, but * KisRandomAccessor has an internal cache of the tiles, but
...@@ -59,35 +59,35 @@ struct PickerTraitInt { ...@@ -59,35 +59,35 @@ struct PickerTraitInt {
*/ */
template <class Traits> template <class Traits>
class KisCrossDeviceColorPickerImpl class KisCrossDeviceColorSamplerImpl
{ {
public: public:
KisCrossDeviceColorPickerImpl(KisPaintDeviceSP src, KisPaintDeviceSP dst) { KisCrossDeviceColorSamplerImpl(KisPaintDeviceSP src, KisPaintDeviceSP dst) {
init(src, dst); init(src, dst);
} }
KisCrossDeviceColorPickerImpl(KisPaintDeviceSP src, KisFixedPaintDeviceSP dst) { KisCrossDeviceColorSamplerImpl(KisPaintDeviceSP src, KisFixedPaintDeviceSP dst) {
init(src, dst); init(src, dst);
} }
KisCrossDeviceColorPickerImpl(KisPaintDeviceSP src, const KoColor &dst) { KisCrossDeviceColorSamplerImpl(KisPaintDeviceSP src, const KoColor &dst) {
init(src, &dst); init(src, &dst);
} }
~KisCrossDeviceColorPickerImpl() { ~KisCrossDeviceColorSamplerImpl() {
delete[] m_data; delete[] m_data;
} }
inline void pickColor(typename Traits::coord_type x, inline void sampleColor(typename Traits::coord_type x,
typename Traits::coord_type y, typename Traits::coord_type y,
quint8 *dst) { quint8 *dst) {
pickColorImpl<false>(x, y, dst); sampleColorImpl<false>(x, y, dst);
} }
inline void pickOldColor(typename Traits::coord_type x, inline void sampleOldColor(typename Traits::coord_type x,
typename Traits::coord_type y, typename Traits::coord_type y,
quint8 *dst) { quint8 *dst) {
pickColorImpl<true>(x, y, dst); sampleColorImpl<true>(x, y, dst);
} }
private: private:
...@@ -101,7 +101,7 @@ private: ...@@ -101,7 +101,7 @@ private:
} }
template <bool useOldData> template <bool useOldData>
inline void pickColorImpl(typename Traits::coord_type x, inline void sampleColorImpl(typename Traits::coord_type x,
typename Traits::coord_type y, typename Traits::coord_type y,
quint8 *dst) { quint8 *dst) {
m_accessor->moveTo(x, y); m_accessor->moveTo(x, y);
...@@ -120,7 +120,7 @@ private: ...@@ -120,7 +120,7 @@ private:
quint8 *m_data; quint8 *m_data;
}; };
typedef KisCrossDeviceColorPickerImpl<PickerTraitReal> KisCrossDeviceColorPicker; typedef KisCrossDeviceColorSamplerImpl<SamplerTraitReal> KisCrossDeviceColorSampler;
typedef KisCrossDeviceColorPickerImpl<PickerTraitInt> KisCrossDeviceColorPickerInt; typedef KisCrossDeviceColorSamplerImpl<SamplerTraitInt> KisCrossDeviceColorSamplerInt;
#endif /* __KIS_CROSS_DEVICE_COLOR_PICKER_H */ #endif /* __KIS_CROSS_DEVICE_COLOR_SAMPLER_H */
...@@ -665,13 +665,13 @@ public: ...@@ -665,13 +665,13 @@ public:
* 2) Do *not* expect that the color spaces of the destination and * 2) Do *not* expect that the color spaces of the destination and
* the temporary device would coincide. If you need to copy a * the temporary device would coincide. If you need to copy a
* single pixel from one device to another, you can use * single pixel from one device to another, you can use
* KisCrossDeviceColorPicker class, that will handle all the * KisCrossDeviceColorSampler class, that will handle all the
* necessary conversions for you. * necessary conversions for you.
* *
* \see createCompositionSourceDeviceFixed() * \see createCompositionSourceDeviceFixed()
* \see compositionSourceColorSpace() * \see compositionSourceColorSpace()
* \see KisCrossDeviceColorPicker * \see KisCrossDeviceColorSampler
* \see KisCrossDeviceColorPickerInt * \see KisCrossDeviceColorSamplerInt
*/ */
KisPaintDeviceSP createCompositionSourceDevice() const; KisPaintDeviceSP createCompositionSourceDevice() const;
......
...@@ -464,7 +464,7 @@ KisPaintDeviceSP KisColorizeMask::coloringProjection() const ...@@ -464,7 +464,7 @@ KisPaintDeviceSP KisColorizeMask::coloringProjection() const
return m_d->coloringProjection; return m_d->coloringProjection;
} }
KisPaintDeviceSP KisColorizeMask::colorPickSourceDevice() const KisPaintDeviceSP KisColorizeMask::colorSampleSourceDevice() const
{ {
return return
m_d->shouldShowColoring() && !m_d->coloringProjection->extent().isEmpty() ? m_d->shouldShowColoring() && !m_d->coloringProjection->extent().isEmpty() ?
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
KisPaintDeviceSP paintDevice() const override; KisPaintDeviceSP paintDevice() const override;
KisPaintDeviceSP coloringProjection() const; KisPaintDeviceSP coloringProjection() const;
KisPaintDeviceSP colorPickSourceDevice() const override; KisPaintDeviceSP colorSampleSourceDevice() const override;
KisNodeSP clone() const override { KisNodeSP clone() const override {
return KisNodeSP(new KisColorizeMask(*this)); return KisNodeSP(new KisColorizeMask(*this));
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
id="svg3531" id="svg3531"
version="1.1" version="1.1"
inkscape:version="0.48.3.1 r9886" inkscape:version="0.48.3.1 r9886"
sodipodi:docname="icon-colorpicker.svg"> sodipodi:docname="icon-colorsampler.svg">
<defs <defs
id="defs3533"> id="defs3533">
<linearGradient <linearGradient
......
...@@ -19,17 +19,17 @@ Panel { ...@@ -19,17 +19,17 @@ Panel {
height: parent.height; height: parent.height;
width: height; width: height;
onChooseBGChanged: { onChooseBGChanged: {
if (toolManager.currentTool !== null && toolManager.currentTool.toolId() === "KritaSelected/KisToolColorPicker") { if (toolManager.currentTool !== null && toolManager.currentTool.toolId() === "KritaSelected/KisToolColorSampler") {
toolManager.currentTool.toForeground = !swatch.chooseBG; toolManager.currentTool.toForeground = !swatch.chooseBG;
} }
} }
}, },
Button { Button {
id: colorPicker; id: colorSampler;
width: height; width: height;
height: Constants.ToolbarButtonSize; height: Constants.ToolbarButtonSize;
image: Settings.theme.icon("colorpicker"); image: Settings.theme.icon("colorsampler");
onClicked: toolManager.requestToolChange("KritaSelected/KisToolColorPicker"); onClicked: toolManager.requestToolChange("KritaSelected/KisToolColorSampler");
}, },