Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_color_selector_base.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2010 Adam Celarek <kdedev at xibo dot at>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KIS_COLOR_SELECTOR_BASE_H
8#define KIS_COLOR_SELECTOR_BASE_H
9
10#include <QWidget>
11#include <QRgb>
12#include <QPointer>
13#include <kis_canvas2.h>
14#include "kis_acs_types.h"
16
17
18class KoColor;
19class QTimer;
20class KoColorSpace;
21class KisCanvas2;
24class KoGamutMask;
25
26
28class KisColorSelectorBase : public QWidget
29{
30Q_OBJECT
31public:
33 explicit KisColorSelectorBase(QWidget *parent = 0);
34 ~KisColorSelectorBase() override;
35
36 void setPopupBehaviour(bool onMouseOver, bool onMouseClick);
38 virtual void setCanvas(KisCanvas2* canvas);
39 virtual void unsetCanvas();
40 const KoColorSpace* colorSpace() const;
41
43
44 void tryHideAllPopups();
45
46public:
47 void updateColor(const KoColor &color, Acs::ColorRole role, bool needsExplicitColorReset);
48 void updateColorPreview(const KoColor &color);
49 void showColorPreview();
50 void updateBaseColorPreview(const KoColor &color);
52
53 virtual void setColor(const KoColor& color);
54
55public Q_SLOTS:
59 virtual void reset();
60
61 virtual void updateSettings();
62 virtual void showPopup(Move move=MoveToMousePosition);
63
64public:
65#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
66 void enterEvent(QEvent *e) override;
67#else
68 void enterEvent(QEnterEvent *e) override;
69#endif
70
71 void leaveEvent(QEvent *e) override;
72
73 void mousePressEvent(QMouseEvent *) override;
74 void mouseReleaseEvent(QMouseEvent *) override;
75
76protected:
77 void keyPressEvent(QKeyEvent *) override;
78 virtual KisColorSelectorBase* createPopup() const = 0;
79 void dragEnterEvent(QDragEnterEvent *) override;
80 void dropEvent(QDropEvent *) override;
81 void setHidingTime(int time);
82 bool isPopup() const { return m_isPopup; }
83 void mouseMoveEvent(QMouseEvent *event) override;
84 void changeEvent(QEvent *event) override;
85 void showEvent(QShowEvent *event) override;
87
88private:
89 void commitColor(const KoColor& koColor, Acs::ColorRole role);
90
91
92protected Q_SLOTS:
93 void hidePopup();
94
96 virtual void canvasResourceChanged(int key, const QVariant& v);
97
98 void updateLastUsedColorPreview(const KoColor &color);
99
100public:
101 // This is a private interface for signal compressor, don't use it.
102 // Use requestUpdateColorAndPreview() instead
103 void slotUpdateColorAndPreview(QPair<KoColor, Acs::ColorRole> color);
104
105private:
106 void lazyCreatePopup();
107
108protected:
111 QWidget* m_parent;
113
114 // This boolean here is to check if the color selector is updating the resource, so it won't update itself when the resource is updated.
116
117private:
118 QTimer* m_hideTimer;
122 bool m_isPopup; //this instance is a popup
125
127 QScopedPointer<ColorCompressorType> m_updateColorCompressor;
128};
129
130#endif
qreal v
Base class for all color selectors, that should support color management and zooming.
KisColorSelectorBase * m_popup
void requestUpdateColorAndPreview(const KoColor &color, Acs::ColorRole role)
const KoColorSpace * m_colorSpace
void dropEvent(QDropEvent *) override
void updateColorPreview(const KoColor &color)
virtual void canvasResourceChanged(int key, const QVariant &v)
if you overwrite this, keep in mind, that you should set the color only, if m_colorUpdateAllowed is t...
void dragEnterEvent(QDragEnterEvent *) override
void updateLastUsedColorPreview(const KoColor &color)
void slotUpdateColorAndPreview(QPair< KoColor, Acs::ColorRole > color)
void changeEvent(QEvent *event) override
virtual void setCanvas(KisCanvas2 *canvas)
KisDisplayColorConverter * converter() const
const KoColorSpace * colorSpace() const
virtual void setColor(const KoColor &color)
void mouseReleaseEvent(QMouseEvent *) override
KisColorSelectorBase(QWidget *parent=0)
void mousePressEvent(QMouseEvent *) override
void enterEvent(QEnterEvent *e) override
KisColorPreviewPopup * m_colorPreviewPopup
void showEvent(QShowEvent *event) override
void mouseMoveEvent(QMouseEvent *event) override
void commitColor(const KoColor &koColor, Acs::ColorRole role)
QScopedPointer< ColorCompressorType > m_updateColorCompressor
QPointer< KisCanvas2 > m_canvas
KisSignalCompressorWithParam< QPair< KoColor, Acs::ColorRole > > ColorCompressorType
void updateBaseColorPreview(const KoColor &color)
void setPopupBehaviour(bool onMouseOver, bool onMouseClick)
void setColorSpace(const KoColorSpace *colorSpace)
virtual void showPopup(Move move=MoveToMousePosition)
void leaveEvent(QEvent *e) override
virtual KisColorSelectorBase * createPopup() const =0
void updateColor(const KoColor &color, Acs::ColorRole role, bool needsExplicitColorReset)
void keyPressEvent(QKeyEvent *) override
The resource type for gamut masks used by the artistic color selector.
Definition KoGamutMask.h:44