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 "genericcolor.h"
10#include "importexport.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 currentColorCielchD50() const
61 * @sa WRITE @ref setCurrentColorCielchD50()
62 * @sa NOTIFY @ref currentColorCielchD50Changed() */
63 // The Q_PROPERTY macro must be on a single line for correct compilation.
64 // clang-format is disabled here to prevent automatic line breaks.
65 // clang-format off
66 Q_PROPERTY(PerceptualColor::GenericColor currentColorCielchD50 READ currentColorCielchD50 WRITE setCurrentColorCielchD50 NOTIFY currentColorCielchD50Changed USER true)
67 // clang-format on
68
69public:
70 Q_INVOKABLE explicit WheelColorPicker(const QSharedPointer<PerceptualColor::RgbColorSpace> &colorSpace, QWidget *parent = nullptr);
71 virtual ~WheelColorPicker() noexcept override;
72 /** @brief Getter for property @ref currentColorCielchD50
73 * @returns the property @ref currentColorCielchD50 */
74 [[nodiscard]] PerceptualColor::GenericColor currentColorCielchD50() const;
75 [[nodiscard]] virtual QSize minimumSizeHint() const override;
76 void setCurrentColorCielchD50(const PerceptualColor::GenericColor &newCurrentColorCielchD50);
77 [[nodiscard]] virtual QSize sizeHint() const override;
78
79Q_SIGNALS:
80 /** @brief Notify signal for property @ref currentColorCielchD50.
81 * @param newCurrentColorCielchD50 the new current color */
82 void currentColorCielchD50Changed(const PerceptualColor::GenericColor &newCurrentColorCielchD50);
83
84protected:
85 virtual void resizeEvent(QResizeEvent *event) override;
86
87private:
88 Q_DISABLE_COPY(WheelColorPicker)
89
90 /** @internal
91 *
92 * @brief Declare the private implementation as friend class.
93 *
94 * This allows the private class to access the protected members and
95 * functions of instances of <em>this</em> class. */
96 friend class WheelColorPickerPrivate;
97 /** @brief Pointer to implementation (pimpl) */
98 ConstPropagatingUniquePointer<WheelColorPickerPrivate> d_pointer;
99
100 /** @internal @brief Only for unit tests. */
101 friend class TestWheelColorPicker;
102};
103
104} // namespace PerceptualColor
105
106#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.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.