Debian Codegraph @

plugins/dockers/widegamutcolorselector/WGShadeSlider.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2020 Mathias Wein <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7 #ifndef WGSHADESLIDER_H
8 #define WGSHADESLIDER_H
9
10 #include "WGSelectorWidgetBase.h"
11
12 #include <KisVisualColorModel.h>
13
14 #include <QWidget>
15 #include <QScopedPointer>
16 #include <QVector4D>
17
18 class QImage;
19
20 class WGShadeSlider : public QWidget
21 {
22 Q_OBJECT
23 public:
24 explicit WGShadeSlider(WGSelectorDisplayConfigSP config, QWidget *parent = nullptr, KisVisualColorModelSP model = nullptr);
25 ~WGShadeSlider() override;
26
27 void setGradient(const QVector4D &range, const QVector4D &offset);
28 void setDisplayMode(bool slider, int numPatches = -1);
29 void setModel(KisVisualColorModelSP model);
30 QVector4D channelValues() const;
31 const QImage* background();
32
33 public Q_SLOTS:
34 void slotSetChannelValues(const QVector4D &values);
35 void resetHandle();
36
37 protected Q_SLOTS:
38 void slotDisplayConfigurationChanged();
39
40 protected:
41 QSize minimumSizeHint() const override;
42 void mousePressEvent(QMouseEvent *event) override;
43 void mouseMoveEvent(QMouseEvent *event) override;
44 void mouseReleaseEvent(QMouseEvent *event) override;
45 //void tabletEvent(QTabletEvent *event) override;
46 void paintEvent(QPaintEvent*) override;
47 void resizeEvent(QResizeEvent *) override;
48
49 bool adjustHandleValue(const QPointF &widgetPos);
50 QPointF convertSliderValueToWidgetCoordinate(qreal value);
51 qreal convertWidgetCoordinateToSliderValue(QPointF coordinate);
52 QVector4D calculateChannelValues(qreal sliderPos) const;
53 int getPatch(const QPointF pos) const;
54 QRectF patchRect(int index) const;
55 void recalculateParameters();
56 bool sizeRequirementsMet() const;
57 QImage renderBackground();
58 /*!
59 * \brief strokeRect
60 * \param painter shall already be scaled so that 1 unit == 1 real Pixel
61 * \param rect the rectangle to stroke in (logical) widget coordinates
62 * \param pixelSize devicePixelRatioF() that was used to determine the real dimensions
63 * \param shrinkX shrinks the rect by a multiple of the line width used to stroke
64 */
65 void strokeRect(QPainter &painter, const QRectF &rect, qreal pixelSize, qreal shrinkX);
66
67 Q_SIGNALS:
68 void sigChannelValuesChanged(const QVector4D &values);
69 void sigInteraction(bool active);
70 private:
71 struct Private;
72 const QScopedPointer<Private> m_d;
73 };
74
75 #endif // WGSHADESLIDER_H