Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/artisticcolorselector/kis_color_selector.h
Context not available. | |||||
29 | #include "kis_acs_types.h" | 29 | #include "kis_acs_types.h" | ||
---|---|---|---|---|---|
30 | #include "kis_signal_compressor_with_param.h" | 30 | #include "kis_signal_compressor_with_param.h" | ||
31 | 31 | | |||
32 | #include <resources/KoGamutMask.h> | ||||
33 | #include <KisGamutMaskViewConverter.h> | ||||
34 | | ||||
32 | class QPainter; | 35 | class QPainter; | ||
33 | class QPainter; | 36 | class QPainter; | ||
34 | 37 | | |||
35 | class KisColorSelector: public QWidget | 38 | class KisColorSelector: public QWidget | ||
36 | { | 39 | { | ||
37 | Q_OBJECT | 40 | Q_OBJECT | ||
38 | 41 | | |||
39 | typedef KisRadian<float> Radian; | 42 | typedef KisRadian<float> Radian; | ||
40 | 43 | | |||
41 | struct ColorRing | 44 | struct ColorRing | ||
42 | { | 45 | { | ||
43 | ColorRing(): angle(0) { } | 46 | ColorRing(): angle(0) { } | ||
44 | 47 | | |||
45 | Radian getPieceAngle() const { return RAD_360 / float(pieced.size()); } | 48 | Radian getPieceAngle() const { return RAD_360 / float(pieced.size()); } | ||
46 | Radian getShift () const { return angle % getPieceAngle(); } | 49 | Radian getShift () const { return angle % getPieceAngle(); } | ||
47 | Radian getMovedAngel() const { return angle - tmpAngle; } | 50 | Radian getMovedAngel() const { return angle - tmpAngle; } | ||
48 | 51 | | |||
49 | void setTemporaries(const KisColor& color) { | 52 | void setTemporaries(const KisColor& color) { | ||
50 | tmpAngle = angle; | 53 | tmpAngle = angle; | ||
51 | tmpColor = color; | 54 | tmpColor = color; | ||
52 | } | 55 | } | ||
53 | 56 | | |||
54 | KisColor tmpColor; | 57 | KisColor tmpColor; | ||
55 | Radian tmpAngle; | 58 | Radian tmpAngle; | ||
56 | Radian angle; | 59 | Radian angle; | ||
Context not available. | |||||
59 | float innerRadius; | 62 | float innerRadius; | ||
60 | QVector<QPainterPath> pieced; | 63 | QVector<QPainterPath> pieced; | ||
61 | }; | 64 | }; | ||
62 | 65 | | |||
63 | public: | 66 | public: | ||
64 | KisColorSelector(QWidget* parent, KisColor::Type type=KisColor::HSL); | 67 | KisColorSelector(QWidget* parent, KisColor::Type type=KisColor::HSL); | ||
65 | 68 | | |||
66 | void setColorSpace(KisColor::Type type); | 69 | void setColorSpace(KisColor::Type type); | ||
67 | void setNumPieces(int num); | 70 | void setNumPieces(int num); | ||
68 | void setNumLightPieces(int num); | 71 | void setNumLightPieces(int num) __attribute__((optimize(0))); | ||
69 | void setNumRings(int num); | 72 | void setNumRings(int num); | ||
70 | void resetRings(); | 73 | void resetRings(); | ||
71 | void resetSelectedRing(); | 74 | void resetSelectedRing(); | ||
Context not available. | |||||
75 | void selectColor(const KisColor& color); | 78 | void selectColor(const KisColor& color); | ||
76 | void setFgColor(const KisColor& fgColor); | 79 | void setFgColor(const KisColor& fgColor); | ||
77 | void setBgColor(const KisColor& bgColor); | 80 | void setBgColor(const KisColor& bgColor); | ||
78 | 81 | | |||
82 | void setDefaultHueSteps(int num); | ||||
83 | void setDefaultSaturationSteps(int num); | ||||
84 | void setDefaultValueScaleSteps(int num); | ||||
85 | void setShowColorBlip(bool value); | ||||
86 | void setShowBgColor(bool value); | ||||
87 | void setShowValueScaleNumbers(bool value); | ||||
88 | void setGamutMask(KoGamutMask* gamutMask); | ||||
89 | bool gamutMaskOn(); | ||||
90 | void setGamutMaskOn(bool gamutMaskOn); | ||||
91 | void setEnforceGamutMask(bool enforce); | ||||
92 | KoGamutMask* gamutMask(); | ||||
93 | | ||||
94 | bool saturationIsInvertible(); | ||||
95 | | ||||
79 | void saveSettings(); | 96 | void saveSettings(); | ||
80 | void loadSettings(); | 97 | void loadSettings(); | ||
81 | 98 | | |||
82 | KisColor::Type getColorSpace () const { return m_colorSpace; } | 99 | KisColor::Type getColorSpace () const { return m_colorSpace; } | ||
83 | qint32 getNumRings () const { return m_colorRings.size(); } | 100 | qint32 getNumRings () const { return m_colorRings.size(); } | ||
84 | qint32 getNumPieces () const { return m_numPieces; } | 101 | qint32 getNumPieces () const { return m_numPieces; } | ||
Context not available. | |||||
87 | bool isSaturationInverted() const { return m_inverseSaturation; } | 104 | bool isSaturationInverted() const { return m_inverseSaturation; } | ||
88 | bool islightRelative () const { return m_relativeLight; } | 105 | bool islightRelative () const { return m_relativeLight; } | ||
89 | 106 | | |||
107 | quint32 getDefaultHueSteps () const { return m_defaultHueSteps; } | ||||
108 | quint32 getDefaultSaturationSteps () const { return m_defaultSaturationSteps; } | ||||
109 | quint32 getDefaultValueScaleSteps () const { return m_defaultValueScaleSteps; } | ||||
110 | bool getShowColorBlip () const { return m_showColorBlip; } | ||||
111 | bool getShowBgColor () const { return m_showBgColor; } | ||||
112 | bool getShowValueScaleNumbers () const { return m_showValueScaleNumbers; } | ||||
113 | bool enforceGamutMask () const { return m_enforceGamutMask; } | ||||
114 | | ||||
90 | Q_SIGNALS: | 115 | Q_SIGNALS: | ||
91 | void sigFgColorChanged(const KisColor& color); | 116 | void sigFgColorChanged(const KisColor& color); | ||
92 | void sigBgColorChanged(const KisColor& color); | 117 | void sigBgColorChanged(const KisColor& color); | ||
93 | 118 | | |||
94 | private: | 119 | private: | ||
95 | void mousePressEvent(QMouseEvent* event) override; | 120 | void mousePressEvent(QMouseEvent* event) override; | ||
96 | void mouseMoveEvent(QMouseEvent* event) override; | 121 | void mouseMoveEvent(QMouseEvent* event) override; | ||
97 | void mouseReleaseEvent(QMouseEvent* event) override; | 122 | void mouseReleaseEvent(QMouseEvent* event) override; | ||
98 | void resizeEvent(QResizeEvent* event) override; | 123 | void resizeEvent(QResizeEvent* event) override; | ||
99 | void paintEvent(QPaintEvent* event) override; | 124 | void paintEvent(QPaintEvent* event) override; | ||
125 | void leaveEvent(QEvent* e) override; | ||||
100 | 126 | | |||
127 | bool colorIsClear(const KisColor &color); | ||||
128 | bool colorIsClear(const QPointF &colorPoint); | ||||
101 | void requestUpdateColorAndPreview(const KisColor &color, Acs::ColorRole role); | 129 | void requestUpdateColorAndPreview(const KisColor &color, Acs::ColorRole role); | ||
102 | 130 | | |||
103 | void recalculateAreas(quint8 numLightPieces); | 131 | void recalculateAreas(quint8 numLightPieces); | ||
104 | void recalculateRings(quint8 numRings, quint8 numPieces); | 132 | void recalculateRings(quint8 numRings, quint8 numPieces); | ||
105 | void createRing(ColorRing& wheel, quint8 numPieces, qreal innerRadius, qreal outerRadius); | 133 | void createRing(ColorRing& wheel, quint8 numPieces, qreal innerRadius, qreal outerRadius); | ||
106 | 134 | | |||
107 | void drawRing(QPainter& painter, ColorRing& wheel, const QRect& rect); | 135 | void drawRing(QPainter& painter, int ringIndex, ColorRing& wheel, const QRect& rect); | ||
108 | void drawOutline(QPainter& painter, const QRect& rect); | 136 | void drawOutline(QPainter& painter, const QRect& rect); | ||
137 | void drawBlip(QPainter& painter, const QRect& rect); | ||||
109 | void drawLightStrip(QPainter& painter, const QRect& rect); | 138 | void drawLightStrip(QPainter& painter, const QRect& rect); | ||
139 | void drawGamutMaskShape(QPainter& painter, const QRect& rect); | ||||
110 | 140 | | |||
111 | qint8 getHueIndex(Radian hue, Radian shift=0.0f) const; | 141 | qint8 getHueIndex(Radian hue, Radian shift=0.0f) const; | ||
112 | qreal getHue(int hueIdx, Radian shift=0.0f) const; | 142 | qreal getHue(int hueIdx, Radian shift=0.0f) const; | ||
Context not available. | |||||
117 | qint8 getSaturationIndex(const QPointF& pt) const; | 147 | qint8 getSaturationIndex(const QPointF& pt) const; | ||
118 | qint8 getSaturationIndex(qreal saturation) const; | 148 | qint8 getSaturationIndex(qreal saturation) const; | ||
119 | qreal getSaturation(int saturationIdx) const; | 149 | qreal getSaturation(int saturationIdx) const; | ||
120 | 150 | | |||
121 | QPointF mapCoord(const QPointF& pt, const QRectF& rect) const; | 151 | // QPointF mapCoord(const QPointF& pt, const QRectF& rect) const; | ||
152 | | ||||
153 | QPointF mapCoordToView(const QPointF& pt, const QRectF& viewRect) const; | ||||
154 | QPointF mapCoordToUnit(const QPointF& pt, const QRectF& viewRect) const; | ||||
155 | QPointF mapColorToUnit(const KisColor& color, bool invertSaturation = true) const; | ||||
122 | 156 | | |||
123 | public: | 157 | public: | ||
124 | // This is a private interface for signal compressor, don't use it. | 158 | // This is a private interface for signal compressor, don't use it. | ||
Context not available. | |||||
139 | KisColor m_fgColor; | 173 | KisColor m_fgColor; | ||
140 | KisColor m_bgColor; | 174 | KisColor m_bgColor; | ||
141 | QImage m_renderBuffer; | 175 | QImage m_renderBuffer; | ||
176 | QImage m_maskBuffer; | ||||
142 | QRect m_renderArea; | 177 | QRect m_renderArea; | ||
143 | QRect m_lightStripArea; | 178 | QRect m_lightStripArea; | ||
144 | bool m_mouseMoved; | 179 | bool m_mouseMoved; | ||
Context not available. | |||||
147 | qint8 m_clickedRing; | 182 | qint8 m_clickedRing; | ||
148 | QVector<ColorRing> m_colorRings; | 183 | QVector<ColorRing> m_colorRings; | ||
149 | Qt::MouseButtons m_pressedButtons; | 184 | Qt::MouseButtons m_pressedButtons; | ||
185 | const QColor m_grayColor; | ||||
186 | const QColor m_gamutMaskColor; | ||||
187 | | ||||
188 | // docker settings | ||||
189 | quint8 m_defaultHueSteps; | ||||
190 | quint8 m_defaultSaturationSteps; | ||||
191 | quint8 m_defaultValueScaleSteps; | ||||
192 | bool m_showColorBlip; | ||||
193 | bool m_showValueScaleNumbers; | ||||
194 | bool m_showBgColor; | ||||
195 | int m_renderAreaSize; | ||||
196 | | ||||
197 | bool m_gamutMaskOn; | ||||
198 | KoGamutMask* m_currentGamutMask; | ||||
199 | bool m_enforceGamutMask; | ||||
200 | | ||||
201 | bool m_widgetUpdatesSelf; | ||||
150 | 202 | | |||
151 | typedef KisSignalCompressorWithParam<QPair<KisColor, Acs::ColorRole>> ColorCompressorType; | 203 | typedef KisSignalCompressorWithParam<QPair<KisColor, Acs::ColorRole>> ColorCompressorType; | ||
152 | QScopedPointer<ColorCompressorType> m_updateColorCompressor; | 204 | QScopedPointer<ColorCompressorType> m_updateColorCompressor; | ||
Context not available. |