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++
/*
* SPDX-FileCopyrightText: 2022 Dmitry Kazakov <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KISASYNCCOLORSAMPLERHELPER_H
#define KISASYNCCOLORSAMPLERHELPER_H
#include "kritaui_export.h"
#include <QScopedPointer>
#include <QObject>
#include <kis_tool_utils.h>
class QPainter;
class QPainterPath;
class KoViewConverter;
class KisStrokesFacade;
class KisCanvas2;
class KoColor;
class KRITAUI_EXPORT KisAsyncColorSamplerHelper : public QObject
{
Q_OBJECT
public:
KisAsyncColorSamplerHelper(KisCanvas2 *canvas);
~KisAsyncColorSamplerHelper() override;
bool isActive() const;
void activate(KisToolUtils::ColorSamplerSource sampleSource, bool pickFgColor);
void deactivate();
void startAction(const QPointF &docPoint, int radius, int blend);
void continueAction(const QPointF &docPoint);
void endAction();
QRectF colorPreviewDocRect(const QPointF &docPoint);
void paint(QPainter &gc, const KoViewConverter &converter);
void updateCursor(KisToolUtils::ColorSamplerSource sampleSource, bool pickFgColor);
void setUpdateGlobalColor(bool value);
bool updateGlobalColor() const;
Q_SIGNALS:
void sigRequestUpdateOutline();
void sigRequestCursor(const QCursor &cursor);
void sigRequestCursorReset();
/**
* Notifies about the raw color picked from the layer,
* including its alpha channel.
*/
void sigRawColorSelected(const KoColor &color);
/**
* Notifies about the "palette" color picked from the layer,
* that is, with the alpha channel set to OPACITY_OPAQUE.
*/
void sigColorSelected(const KoColor &color);
/**
* Notifies about the "palette" color picked from the layer,
* that is, with the alpha channel set to OPACITY_OPAQUE.
*
* This notification is emitted only once at the very end
* of the color picking stroke.
*/
void sigFinalColorSelected(const KoColor &color);
private Q_SLOTS:
void activateDelayedPreview();
void slotAddSamplingJob(const QPointF &docPoint);
void slotColorSamplingFinished(const KoColor &rawColor);
void slotUpdateBgColor();
void slotCanvasZoomPreviewUpdated(const QImage &canvasImage, QRect canvasRect);
private:
void activatePreview();
void paintRectangle(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor, const QColor &baseColor);
void paintCircle(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor, const QColor &baseColor);
void prepareZoomPreview(const QRectF &docRect);
void paintCircleCrosshair(QPainter &gc, const QRectF &viewRectF, const QColor ¤tColor);
void paintCircleCanvasPreview(QPainter &gc, const QRectF &viewRectF, const QPainterPath &clip);
void paintCircleReferenceImagePreview(QPainter &gc, const QRectF &viewRectF, const QPainterPath &clip);
struct Private;
QScopedPointer<Private> m_d;
};
#endif // KISASYNCCOLORSAMPLERHELPER_H