Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_color_selector_component.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_COMPONENT_H
8#define KIS_COLOR_SELECTOR_COMPONENT_H
9
10#include <QObject>
11#include <QColor>
12
14
15#include "kis_color_selector.h"
16
17class KoColorSpace;
18
19class QPainter;
20
21
22class KisColorSelectorComponent : public QObject
23{
24 Q_OBJECT
25public:
28
30 void setGeometry(int x, int y, int width, int height);
31 void paintEvent(QPainter*);
32
34 virtual void mouseEvent(int x, int y);
35
38
39 int width() const;
40 int height() const;
41
43 void setConfiguration(Parameter param, Type type);
44
46 virtual void setColor(const KoColor& color);
47
49 void setDirty();
50
52 bool wantsGrab(int x, int y) {return containsPointInComponentCoords(x-m_x, y-m_y);}
53
54 void setGamutMask(KoGamutMaskSP gamutMask);
55 void unsetGamutMask();
57 void toggleGamutMask(bool state);
58
59public Q_SLOTS:
62 void setParam(qreal hue, qreal hsvSaturation, qreal value, qreal hslSaturation, qreal lightness, qreal hsiSaturation, qreal intensity, qreal hsySaturation, qreal luma);
63Q_SIGNALS:
65 void update();
67 void paramChanged(qreal hue, qreal hsvSaturation, qreal value, qreal hslSaturation, qreal lightness, qreal hsiSaturation, qreal intensity, qreal hsySaturation, qreal luma);
68protected:
69 const KoColorSpace* colorSpace() const;
71 bool isDirty() const;
72
74 virtual KoColor selectColor(int x, int y) = 0;
75
79 virtual void paint(QPainter*) = 0;
80
83 virtual bool containsPointInComponentCoords(int x, int y) const;
84
88 virtual bool allowsColorSelectionAtPoint(const QPoint &) const;
89
90 // Workaround for Bug 287001
91 void setLastMousePosition(int x, int y);
92
93 qreal m_hue {0.0};
94 qreal m_hsvSaturation {0.0};
95 qreal m_value {0.0};
96 qreal m_hslSaturation {0.0};
97 qreal m_lightness {0.0};
98 qreal m_hsiSaturation {0.0};
99 qreal m_intensity {0.0};
100 qreal m_hsySaturation {0.0};
101 qreal m_luma {0.0};
105 bool m_gamutMaskOn {false};
108 qreal m_lastX {0.0};
109 qreal m_lastY {0.0};
110 int m_x {0};
111 int m_y {0};
112private:
113 int m_width {0};
114 int m_height {0};
115 bool m_dirty {false};
118};
119
120#endif // KIS_COLOR_SELECTOR_COMPONENT_H
float value(const T *src, size_t ch)
virtual bool containsPointInComponentCoords(int x, int y) const
const KoColorSpace * colorSpace() const
void update()
request for repaint, for instance, if the hue changes.
bool wantsGrab(int x, int y)
returns true, if this component wants to grab the mouse (normally true, if containsPoint returns true...
virtual void mouseEvent(int x, int y)
saves the mouse position, so that a blip can be created.
void setDirty()
force subsequent redraw of the component
void setParam(qreal hue, qreal hsvSaturation, qreal value, qreal hslSaturation, qreal lightness, qreal hsiSaturation, qreal intensity, qreal hsySaturation, qreal luma)
bool isDirty() const
returns true, if ether the color space, the size or the parameters have changed since the last paint ...
KisColorSelectorConfiguration::Parameters Parameter
KisColorSelectorComponent(KisColorSelector *parent)
virtual bool allowsColorSelectionAtPoint(const QPoint &) const
virtual void setColor(const KoColor &color)
set the color, blibs etc
void setConfiguration(Parameter param, Type type)
setConfiguration can be ignored (for instance ring and triangle, as they can have only one config)
virtual KoColor selectColor(int x, int y)=0
this method must be overloaded to return the color at position x/y and draw a marker on that position
void paramChanged(qreal hue, qreal hsvSaturation, qreal value, qreal hslSaturation, qreal lightness, qreal hsiSaturation, qreal intensity, qreal hsySaturation, qreal luma)
-1, if unaffected
void setGamutMask(KoGamutMaskSP gamutMask)
KisColorSelectorConfiguration::Type Type
virtual void paint(QPainter *)=0
KoColor currentColor()
return the color, that was selected by calling mouseEvent
void setGeometry(int x, int y, int width, int height)