Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/artisticcolorselector/kis_color_selector.h
Show All 25 Lines | |||||
26 | 26 | | |||
27 | #include "kis_color.h" | 27 | #include "kis_color.h" | ||
28 | #include "kis_radian.h" | 28 | #include "kis_radian.h" | ||
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> | 32 | #include <resources/KoGamutMask.h> | ||
33 | #include <KisGamutMaskViewConverter.h> | 33 | #include <KisGamutMaskViewConverter.h> | ||
34 | #include <kis_canvas2.h> | ||||
34 | 35 | | |||
35 | class QPainter; | 36 | class QPainter; | ||
36 | class KisDisplayColorConverter; | 37 | class KisDisplayColorConverter; | ||
37 | 38 | | |||
38 | class KisColorSelector: public QWidget | 39 | class KisColorSelector: public QWidget | ||
39 | { | 40 | { | ||
40 | Q_OBJECT | 41 | Q_OBJECT | ||
41 | 42 | | |||
Show All 12 Lines | 46 | { | |||
54 | qreal innerRadius; | 55 | qreal innerRadius; | ||
55 | QVector<QPainterPath> pieced; | 56 | QVector<QPainterPath> pieced; | ||
56 | }; | 57 | }; | ||
57 | 58 | | |||
58 | public: | 59 | public: | ||
59 | KisColorSelector(QWidget* parent, KisColor::Type type=KisColor::HSL); | 60 | KisColorSelector(QWidget* parent, KisColor::Type type=KisColor::HSL); | ||
60 | 61 | | |||
61 | void setColorSpace(KisColor::Type type); | 62 | void setColorSpace(KisColor::Type type); | ||
62 | void setColorConverter(KisDisplayColorConverter* colorConverter); | 63 | // void setColorConverter(KisDisplayColorConverter* colorConverter); | ||
64 | void setCanvas(KisCanvas2* canvas); | ||||
63 | void setNumPieces(int num); | 65 | void setNumPieces(int num); | ||
64 | void setNumLightPieces(int num) __attribute__((optimize(0))); | 66 | void setNumLightPieces(int num) __attribute__((optimize(0))); | ||
65 | void setNumRings(int num); | 67 | void setNumRings(int num); | ||
66 | 68 | | |||
67 | void setLight(qreal light=0.0f); | 69 | void setLight(qreal light=0.0f); | ||
68 | 70 | | |||
69 | void setLumaCoefficients(qreal lR, qreal lG, qreal lB, qreal lGamma); | 71 | void setLumaCoefficients(qreal lR, qreal lG, qreal lB, qreal lGamma); | ||
70 | inline qreal lumaR() const { return m_lumaR; } | 72 | inline qreal lumaR() const { return m_lumaR; } | ||
71 | inline qreal lumaG() const { return m_lumaG; } | 73 | inline qreal lumaG() const { return m_lumaG; } | ||
72 | inline qreal lumaB() const { return m_lumaB; } | 74 | inline qreal lumaB() const { return m_lumaB; } | ||
73 | inline qreal lumaGamma() const { return m_lumaGamma; } | 75 | inline qreal lumaGamma() const { return m_lumaGamma; } | ||
74 | 76 | | |||
75 | void setInverseSaturation(bool inverse); | 77 | void setInverseSaturation(bool inverse); | ||
76 | void selectColor(const KisColor& color); | 78 | void selectColor(const KisColor& color); | ||
77 | void setFgColor(const KoColor& fgColor); | 79 | void setFgColor(const KoColor& fgColor); | ||
78 | void setBgColor(const KoColor& bgColor); | 80 | void setBgColor(const KoColor& bgColor); | ||
79 | 81 | | |||
80 | void setDefaultHueSteps(int num); | 82 | void setDefaultHueSteps(int num); | ||
81 | void setDefaultSaturationSteps(int num); | 83 | void setDefaultSaturationSteps(int num); | ||
82 | void setDefaultValueScaleSteps(int num); | 84 | void setDefaultValueScaleSteps(int num); | ||
83 | void setShowBgColor(bool value); | 85 | void setShowBgColor(bool value); | ||
84 | void setShowValueScaleNumbers(bool value); | 86 | void setShowValueScaleNumbers(bool value); | ||
85 | void setGamutMask(KoGamutMask* gamutMask); | 87 | void setGamutMask(KoGamutMask* gamutMask); | ||
88 | void setDirty(); | ||||
86 | bool gamutMaskOn(); | 89 | bool gamutMaskOn(); | ||
87 | void setGamutMaskOn(bool gamutMaskOn); | 90 | void setGamutMaskOn(bool gamutMaskOn); | ||
88 | void setEnforceGamutMask(bool enforce); | 91 | void setEnforceGamutMask(bool enforce); | ||
89 | KoGamutMask* gamutMask(); | 92 | KoGamutMask* gamutMask(); | ||
90 | 93 | | |||
91 | bool saturationIsInvertible(); | | |||
92 | | ||||
93 | void saveSettings(); | 94 | void saveSettings(); | ||
94 | void loadSettings(); | 95 | void loadSettings(); | ||
95 | 96 | | |||
96 | KisColor::Type getColorSpace () const { return m_colorSpace; } | 97 | KisColor::Type getColorSpace () const { return m_colorSpace; } | ||
97 | qint32 getNumRings () const { return m_colorRings.size(); } | 98 | qint32 getNumRings () const { return m_colorRings.size(); } | ||
98 | qint32 getNumPieces () const { return m_numPieces; } | 99 | qint32 getNumPieces () const { return m_numPieces; } | ||
99 | qint32 getNumLightPieces () const { return m_numLightPieces; } | 100 | qint32 getNumLightPieces () const { return m_numLightPieces; } | ||
100 | bool isSaturationInverted() const { return m_inverseSaturation; } | 101 | bool isSaturationInverted() const { return m_inverseSaturation; } | ||
Show All 25 Lines | 114 | private: | |||
126 | void recalculateRings(quint8 numRings, quint8 numPieces); | 127 | void recalculateRings(quint8 numRings, quint8 numPieces); | ||
127 | void createRing(ColorRing& wheel, quint8 numPieces, qreal innerRadius, qreal outerRadius); | 128 | void createRing(ColorRing& wheel, quint8 numPieces, qreal innerRadius, qreal outerRadius); | ||
128 | 129 | | |||
129 | void drawRing(QPainter& painter, ColorRing& wheel, const QRect& rect); | 130 | void drawRing(QPainter& painter, ColorRing& wheel, const QRect& rect); | ||
130 | void drawOutline(QPainter& painter, const QRect& rect); | 131 | void drawOutline(QPainter& painter, const QRect& rect); | ||
131 | void drawBlip(QPainter& painter, const QRect& rect); | 132 | void drawBlip(QPainter& painter, const QRect& rect); | ||
132 | void drawLightStrip(QPainter& painter, const QRect& rect); | 133 | void drawLightStrip(QPainter& painter, const QRect& rect); | ||
133 | void drawGamutMaskShape(QPainter& painter, const QRect& rect); | 134 | void drawGamutMaskShape(QPainter& painter, const QRect& rect); | ||
135 | void drawColorPreview(QPainter& painter, const QRect& rect); | ||||
134 | 136 | | |||
135 | qint8 getHueIndex(Radian hue) const; | 137 | qint8 getHueIndex(Radian hue) const; | ||
136 | qreal getHue(int hueIdx, Radian shift=0.0f) const; | 138 | qreal getHue(int hueIdx, Radian shift=0.0f) const; | ||
137 | qint8 getLightIndex(const QPointF& pt) const; | 139 | qint8 getLightIndex(const QPointF& pt) const; | ||
138 | qint8 getLightIndex(qreal light) const; | 140 | qint8 getLightIndex(qreal light) const; | ||
139 | qreal getLight(const QPointF& pt) const; | 141 | qreal getLight(const QPointF& pt) const; | ||
140 | qint8 getSaturationIndex(const QPointF& pt) const; | 142 | qint8 getSaturationIndex(const QPointF& pt) const; | ||
141 | qint8 getSaturationIndex(qreal saturation) const; | 143 | qint8 getSaturationIndex(qreal saturation) const; | ||
142 | qreal getSaturation(int saturationIdx) const; | 144 | qreal getSaturation(int saturationIdx) const; | ||
143 | 145 | | |||
144 | QPointF mapCoordToView(const QPointF& pt, const QRectF& viewRect) const; | 146 | QPointF mapCoordToView(const QPointF& pt, const QRectF& viewRect) const; | ||
145 | QPointF mapCoordToUnit(const QPointF& pt, const QRectF& viewRect) const; | 147 | QPointF mapCoordToUnit(const QPointF& pt, const QRectF& viewRect) const; | ||
146 | QPointF mapColorToUnit(const KisColor& color, bool invertSaturation = true) const; | 148 | QPointF mapColorToUnit(const KisColor& color, bool invertSaturation = true) const; | ||
147 | Radian mapCoordToAngle(qreal x, qreal y) const; | 149 | Radian mapCoordToAngle(qreal x, qreal y) const; | ||
148 | QPointF mapHueToAngle(qreal hue) const; | 150 | QPointF mapHueToAngle(qreal hue) const; | ||
149 | 151 | | |||
150 | public: | 152 | public: | ||
151 | // This is a private interface for signal compressor, don't use it. | 153 | // This is a private interface for signal compressor, don't use it. | ||
152 | // Use requestUpdateColorAndPreview() instead | 154 | // Use requestUpdateColorAndPreview() instead | ||
153 | void slotUpdateColorAndPreview(QPair<KisColor, Acs::ColorRole> color); | 155 | void slotUpdateColorAndPreview(QPair<KisColor, Acs::ColorRole> color); | ||
154 | 156 | | |||
155 | private: | 157 | private: | ||
156 | KisDisplayColorConverter* m_colorConverter; | 158 | KisCanvas2* m_canvas; | ||
157 | KisColor::Type m_colorSpace; | 159 | KisColor::Type m_colorSpace; | ||
158 | quint8 m_numPieces; | 160 | quint8 m_numPieces; | ||
159 | quint8 m_numLightPieces; | 161 | quint8 m_numLightPieces; | ||
160 | bool m_inverseSaturation; | 162 | bool m_inverseSaturation; | ||
161 | qint8 m_selectedRing; | 163 | qint8 m_selectedRing; | ||
162 | qint8 m_selectedPiece; | 164 | qint8 m_selectedPiece; | ||
163 | qint8 m_selectedLightPiece; | 165 | qint8 m_selectedLightPiece; | ||
164 | KisColor m_selectedColor; | 166 | KisColor m_selectedColor; | ||
165 | KisColor m_fgColor; | 167 | KisColor m_fgColor; | ||
166 | KisColor m_bgColor; | 168 | KisColor m_bgColor; | ||
167 | QImage m_renderBuffer; | 169 | QImage m_renderBuffer; | ||
168 | QImage m_maskBuffer; | 170 | QImage m_maskBuffer; | ||
171 | QImage m_lightStripBuffer; | ||||
172 | QImage m_colorPreviewBuffer; | ||||
173 | QRect m_widgetArea; | ||||
169 | QRect m_renderArea; | 174 | QRect m_renderArea; | ||
170 | QRect m_lightStripArea; | 175 | QRect m_lightStripArea; | ||
171 | bool m_mouseMoved; | 176 | bool m_mouseMoved; | ||
172 | QPointF m_clickPos; | 177 | QPointF m_clickPos; | ||
173 | qint8 m_clickedRing; | 178 | qint8 m_clickedRing; | ||
174 | QVector<ColorRing> m_colorRings; | 179 | QVector<ColorRing> m_colorRings; | ||
175 | Qt::MouseButtons m_pressedButtons; | 180 | Qt::MouseButtons m_pressedButtons; | ||
176 | 181 | | |||
177 | // docker settings | 182 | // docker settings | ||
178 | quint8 m_defaultHueSteps; | 183 | quint8 m_defaultHueSteps; | ||
179 | quint8 m_defaultSaturationSteps; | 184 | quint8 m_defaultSaturationSteps; | ||
180 | quint8 m_defaultValueScaleSteps; | 185 | quint8 m_defaultValueScaleSteps; | ||
181 | bool m_showValueScaleNumbers; | 186 | bool m_showValueScaleNumbers; | ||
182 | bool m_showBgColor; | 187 | bool m_showBgColor; | ||
183 | 188 | | |||
184 | bool m_gamutMaskOn; | 189 | bool m_gamutMaskOn; | ||
185 | KoGamutMask* m_currentGamutMask; | 190 | KoGamutMask* m_currentGamutMask; | ||
186 | bool m_enforceGamutMask; | 191 | bool m_enforceGamutMask; | ||
187 | QSize m_renderAreaSize; | 192 | QSize m_renderAreaSize; | ||
188 | bool m_maskPreviewActive; | 193 | bool m_maskPreviewActive; | ||
189 | KisGamutMaskViewConverter* m_viewConverter; | 194 | KisGamutMaskViewConverter* m_viewConverter; | ||
190 | 195 | | |||
191 | bool m_widgetUpdatesSelf; | 196 | bool m_widgetUpdatesSelf; | ||
197 | bool m_isDirtyWheel; | ||||
198 | bool m_isDirtyLightStrip; | ||||
199 | bool m_isDirtyGamutMask; | ||||
200 | bool m_isDirtyColorPreview; | ||||
192 | 201 | | |||
193 | qreal m_lumaR; | 202 | qreal m_lumaR; | ||
194 | qreal m_lumaG; | 203 | qreal m_lumaG; | ||
195 | qreal m_lumaB; | 204 | qreal m_lumaB; | ||
196 | qreal m_lumaGamma; | 205 | qreal m_lumaGamma; | ||
197 | 206 | | |||
198 | typedef KisSignalCompressorWithParam<QPair<KisColor, Acs::ColorRole>> ColorCompressorType; | 207 | typedef KisSignalCompressorWithParam<QPair<KisColor, Acs::ColorRole>> ColorCompressorType; | ||
199 | QScopedPointer<ColorCompressorType> m_updateColorCompressor; | 208 | QScopedPointer<ColorCompressorType> m_updateColorCompressor; | ||
200 | }; | 209 | }; | ||
201 | 210 | | |||
202 | #endif // H_KIS_COLOR_SELECTOR_H | 211 | #endif // H_KIS_COLOR_SELECTOR_H |