Krita Source Code Documentation
Loading...
Searching...
No Matches
KisVisualColorSelectorShape.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Wolthera van Hovell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KIS_VISUAL_COLOR_SELECTOR_SHAPE_H
7#define KIS_VISUAL_COLOR_SELECTOR_SHAPE_H
8
9#include <QWidget>
10#include <QScopedPointer>
11#include <QPixmap>
12#include <QRegion>
13#include <QMouseEvent>
14
15#include <KoColor.h>
17
20
33class KisVisualColorSelectorShape : public QWidget
34{
35 Q_OBJECT
36public:
44 int channel1, int channel2);
46
51 QPointF getCursorPosition() const;
63 const QImage& getImageMap();
75
81 virtual QRect getSpaceForSquare(QRect geom) = 0;
82 virtual QRect getSpaceForCircle(QRect geom) = 0;
83 virtual QRect getSpaceForTriangle(QRect geom) = 0;
84
85 bool isHueControl() const;
86 virtual bool supportsGamutMask() const;
87
92 void forceImageUpdate();
93
100 virtual void updateGamutMask();
101
107 virtual void setBorderWidth(int width) = 0;
108
115 int channel(int dimension) const;
116
117 quint32 channelMask() const;
118
125 void setCursorPosition(QPointF position, bool signal = false);
126
136 void setChannelValues(QVector4D channelValues, quint32 channelFlags);
137
138 void setAcceptTabletEvents(bool on);
139
140Q_SIGNALS:
141 void sigCursorMoved(QPointF pos);
142
143protected:
153 QImage convertImageMap(const quint8 *rawColor, quint32 bufferSize, QSize imgSize) const;
163 virtual QImage renderBackground(const QVector4D &channelValues, const QImage &alpha) const;
164 virtual QImage compositeBackground() const;
169 virtual QImage renderAlphaMask() const;
170 virtual QImage renderStaticAlphaMask() const;
174 virtual QPointF mousePositionToShapeCoordinate(const QPointF &pos, const QPointF &dragStart) const;
175
176 void mousePressEvent(QMouseEvent *e) override;
177 void mouseMoveEvent(QMouseEvent *e) override;
178 void mouseReleaseEvent(QMouseEvent *e) override;
179 void tabletEvent(QTabletEvent* event) override;
180 void paintEvent(QPaintEvent*) override;
181 void resizeEvent(QResizeEvent *) override;
182
183private:
184 struct Private;
185 const QScopedPointer<Private> m_d;
186
191 virtual QPointF convertShapeCoordinateToWidgetCoordinate(QPointF) const = 0;
192
198 virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPointF coordinate) const = 0;
199
204 virtual QRegion getMaskMap() = 0;
205 virtual void drawCursor(QPainter &painter) = 0;
206 virtual void drawGamutMask(QPainter &painter);
207};
208
209#endif
The KisVisualColorModel class allows manipulating a KoColor using various color models.
The KisVisualColorSelectorShape class A 2d widget can represent at maximum 2 coordinates....
KisVisualColorModel * selectorModel() const
void setCursorPosition(QPointF position, bool signal=false)
setCursorPosition Set the cursor to normalized shape coordinates. This will only repaint the cursor.
void setChannelValues(QVector4D channelValues, quint32 channelFlags)
setChannelValues Set the current channel values; Note that channel values controlled by the shape its...
void mouseReleaseEvent(QMouseEvent *e) override
KisVisualColorSelector * colorSelector() const
void mouseMoveEvent(QMouseEvent *e) override
void forceImageUpdate()
forceImageUpdate force the image to recache.
virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPointF coordinate) const =0
convertWidgetCoordinateToShapeCoordinate Convert a coordinate in the widget's height/width to a shape...
QPointF getCursorPosition() const
getCursorPosition
virtual void drawCursor(QPainter &painter)=0
int channel(int dimension) const
channel Get the channel index associated with a selector shape dimension
virtual QImage renderBackground(const QVector4D &channelValues, const QImage &alpha) const
renderBackground Render the widget background visible inside the widget's mask in current color space...
virtual QRect getSpaceForTriangle(QRect geom)=0
virtual QImage renderAlphaMask() const
render the alpha mask for the widget background the returned image is expected to be QImage::Format_A...
virtual QRect getSpaceForCircle(QRect geom)=0
void mousePressEvent(QMouseEvent *e) override
virtual void updateGamutMask()
Notify shape that the gamut mask changed.
QColor getColorFromConverter(KoColor c)
getColorFromConverter
virtual void drawGamutMask(QPainter &painter)
void tabletEvent(QTabletEvent *event) override
virtual QRegion getMaskMap()=0
getPixmap
void sigCursorMoved(QPointF pos)
const QScopedPointer< Private > m_d
void paintEvent(QPaintEvent *) override
virtual void setBorderWidth(int width)=0
setBorderWidth set the border of the single dimensional selector.
KisVisualColorSelectorShape(KisVisualColorSelector *parent, KisVisualColorSelectorShape::Dimensions dimension, int channel1, int channel2)
Dimensions getDimensions() const
getDimensions
virtual QPointF mousePositionToShapeCoordinate(const QPointF &pos, const QPointF &dragStart) const
default implementation just calls convertWidgetCoordinateToShapeCoordinate(pos)
QImage convertImageMap(const quint8 *rawColor, quint32 bufferSize, QSize imgSize) const
convertImageMap convert image data containing raw KoColor data into a QImage
Dimensions
The Dimensions enum Whether or not the shape is single or two dimensional.
const QImage & getImageMap()
getImageMap returns the updated base image
void resizeEvent(QResizeEvent *) override
virtual QPointF convertShapeCoordinateToWidgetCoordinate(QPointF) const =0
convertShapeCoordinateToWidgetCoordinate
virtual QRect getSpaceForSquare(QRect geom)=0
getSpaceForSquare
The KisVisualColorSelector class.