Perceptual Color

wheelcolorpicker.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef WHEELCOLORPICKER_H
5#define WHEELCOLORPICKER_H
6
7#include "abstractdiagram.h"
8#include "constpropagatinguniquepointer.h"
9#include "importexport.h"
10#include "lchdouble.h"
11#include <qglobal.h>
12#include <qsharedpointer.h>
13#include <qsize.h>
14class QResizeEvent;
15class QWidget;
16
17#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
18#include <qtmetamacros.h>
19#else
20#include <qobjectdefs.h>
21#include <qstring.h>
22class QObject;
23#endif
24
25namespace PerceptualColor
26{
27class RgbColorSpace;
28
29class WheelColorPickerPrivate;
30
31/** @brief Complete wheel-based color picker widget
32 *
33 * It is composed of a @ref ColorWheel and, in the middle of the wheel,
34 * a chroma-lightness diagram.
35 *
36 * @image html WheelColorPicker.png "WheelColorPicker" width=200
37 *
38 * @internal
39 *
40 * @todo BUG: When the hue changes and the gamut gets smaller than the
41 * current chroma-lightness value, then the marker is not moved into the
42 * new gamut. But it should!
43 *
44 * @todo This class is a friend class of @ref ChromaLightnessDiagram
45 * and of @ref ColorWheel. Would it be possible to not rely on this
46 * friendship in the code of this class (or at least, to rely less
47 * on it)?
48 *
49 * @todo Is the (double) focus indicator actually good design? Are there
50 * better solutions?
51 *
52 * @todo Add <tt>QToolTip</tt> value explaining the accepted keys and mouse
53 * movements (and also to other widgets). */
55{
56 Q_OBJECT
57
58 /** @brief Currently selected color
59 *
60 * @sa READ @ref currentColor() const
61 * @sa WRITE @ref setCurrentColor()
62 * @sa NOTIFY @ref currentColorChanged() */
63 Q_PROPERTY(PerceptualColor::LchDouble currentColor READ currentColor WRITE setCurrentColor NOTIFY currentColorChanged USER true)
64
65public:
66 Q_INVOKABLE explicit WheelColorPicker(const QSharedPointer<PerceptualColor::RgbColorSpace> &colorSpace, QWidget *parent = nullptr);
67 virtual ~WheelColorPicker() noexcept override;
68 /** @brief Getter for property @ref currentColor
69 * @returns the property @ref currentColor */
70 [[nodiscard]] PerceptualColor::LchDouble currentColor() const;
71 [[nodiscard]] virtual QSize minimumSizeHint() const override;
72 void setCurrentColor(const PerceptualColor::LchDouble &newCurrentColor);
73 [[nodiscard]] virtual QSize sizeHint() const override;
74
75Q_SIGNALS:
76 /** @brief Notify signal for property @ref currentColor.
77 * @param newCurrentColor the new current color */
78 void currentColorChanged(const PerceptualColor::LchDouble &newCurrentColor);
79
80protected:
81 virtual void resizeEvent(QResizeEvent *event) override;
82
83private:
84 Q_DISABLE_COPY(WheelColorPicker)
85
86 /** @internal
87 *
88 * @brief Declare the private implementation as friend class.
89 *
90 * This allows the private class to access the protected members and
91 * functions of instances of <em>this</em> class. */
92 friend class WheelColorPickerPrivate;
93 /** @brief Pointer to implementation (pimpl) */
94 ConstPropagatingUniquePointer<WheelColorPickerPrivate> d_pointer;
95
96 /** @internal @brief Only for unit tests. */
97 friend class TestWheelColorPicker;
98};
99
100} // namespace PerceptualColor
101
102#endif // WHEELCOLORPICKER_H
Base class for LCH diagrams.
Complete wheel-based color picker widget.
This file provides support for C++ symbol import and export.
#define PERCEPTUALCOLOR_IMPORTEXPORT
A macro that either exports dynamic library symbols or imports dynamic library symbols or does nothin...
The namespace of this library.
A LCH color (Oklch, CielchD50, CielchD65…)
Definition lchdouble.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:48:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.