digiKam
dhuesaturationselect.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 1997-02-20
7  * Description : color chooser widgets
8  *
9  * Copyright (C) 1997 by Martin Jones (mjones at kde dot org)
10  * Copyright (C) 2015-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_DHUE_SATURATION_SELECT_H
26 #define DIGIKAM_DHUE_SATURATION_SELECT_H
27 
28 // Qt includes
29 
30 #include <QWidget>
31 #include <QPixmap>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 #include "dcolorchoosermode.h"
37 
38 namespace Digikam
39 {
40 
41 class DIGIKAM_EXPORT DPointSelect : public QWidget
42 {
43  Q_OBJECT
44  Q_PROPERTY(int xValue READ xValue WRITE setXValue)
45  Q_PROPERTY(int yValue READ yValue WRITE setYValue)
46 
47 public:
48 
53  explicit DPointSelect(QWidget* const parent);
54  ~DPointSelect() override;
55 
62  void setValues(int xPos, int yPos);
63 
68  void setXValue(int xPos);
69 
74  void setYValue(int yPos);
75 
79  void setRange(int minX, int minY, int maxX, int maxY);
80 
85  void setMarkerColor(const QColor& col);
86 
90  int xValue() const;
91 
95  int yValue() const;
96 
100  QRect contentsRect() const;
101 
105  QSize minimumSizeHint() const override;
106 
107 Q_SIGNALS:
108 
113  void valueChanged(int x, int y);
114 
115 protected:
116 
123  virtual void drawContents(QPainter*) {};
124 
129  virtual void drawMarker(QPainter* p, int xp, int yp);
130 
131  void paintEvent(QPaintEvent* e) override;
132  void mousePressEvent(QMouseEvent* e) override;
133  void mouseMoveEvent(QMouseEvent* e) override;
134  void wheelEvent(QWheelEvent*) override;
135 
139  void valuesFromPosition(int x, int y, int& xVal, int& yVal) const;
140 
141 private:
142 
143  void setPosition(int xp, int yp);
144 
145 private:
146 
147  DPointSelect(); // Disable default constructor.
148  Q_DISABLE_COPY(DPointSelect)
149 
150  class Private;
151  friend class Private;
152  Private* const d;
153 };
154 
155 // --------------------------------------------------------------------------------
156 
157 class DIGIKAM_EXPORT DHueSaturationSelector : public DPointSelect
158 {
159  Q_OBJECT
160 
161 public:
162 
166  explicit DHueSaturationSelector(QWidget* const parent = nullptr);
167 
171  ~DHueSaturationSelector() override;
172 
179  void setChooserMode(DColorChooserMode chooserMode);
180 
186  DColorChooserMode chooserMode() const;
187 
188 
194  int hue() const;
195 
201  void setHue(int hue);
202 
208  int saturation() const;
209 
215  void setSaturation(int saturation);
216 
222  int colorValue() const;
223 
229  void setColorValue(int color);
230 
234  void updateContents();
235 
236 protected:
237 
242  virtual void drawPalette(QPixmap* pixmap);
243  void resizeEvent(QResizeEvent*) override;
244 
250  void drawContents(QPainter* painter) override;
251 
252 private:
253 
254  Q_DISABLE_COPY(DHueSaturationSelector)
255 
256  class Private;
257  friend class Private;
258  Private* const d;
259 };
260 
261 } // namespace Digikam
262 
263 #endif // DIGIKAM_DHUE_SATURATION_SELECT_H
Definition: dhuesaturationselect.h:158
Definition: dhuesaturationselect.h:42
void valueChanged(int x, int y)
virtual void drawContents(QPainter *)
Definition: dhuesaturationselect.h:123
Definition: datefolderview.cpp:43
DColorChooserMode
Definition: dcolorchoosermode.h:32