File: KisAsyncColorSamplerHelper.h

package info (click to toggle)
krita 1%3A5.2.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 535,928 kB
  • sloc: cpp: 644,668; python: 15,986; ansic: 10,315; xml: 8,488; perl: 622; sh: 214; sql: 129; lisp: 110; makefile: 8
file content (82 lines) | stat: -rw-r--r-- 2,172 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 *  SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef KISASYNCCOLORSAMPLERHELPER_H
#define KISASYNCCOLORSAMPLERHELPER_H

#include "kritaui_export.h"

#include <QScopedPointer>
#include <QObject>

#include "kis_types.h"

class QPainter;
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(bool sampleCurrentLayer, 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(bool sampleCurrentLayer, 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);

private:
    struct Private;
    QScopedPointer<Private> m_d;
};

#endif // KISASYNCCOLORSAMPLERHELPER_H