Perceptual Color

chromahuediagram_p.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef CHROMAHUEDIAGRAM_P_H
5#define CHROMAHUEDIAGRAM_P_H
6
7// Include the header of the public class of this private implementation.
8// #include "chromahuediagram.h"
9
10#include "asyncimageprovider.h"
11#include "chromahueimageparameters.h"
12#include "colorwheelimage.h"
13#include "constpropagatingrawpointer.h"
14#include "lchdouble.h"
15#include "lcms2.h"
16#include <qglobal.h>
17#include <qpoint.h>
18#include <qsharedpointer.h>
19
20namespace PerceptualColor
21{
22class ChromaHueDiagram;
23class RgbColorSpace;
24
25/** @internal
26 *
27 * @brief Private implementation within the <em>Pointer to
28 * implementation</em> idiom
29 *
30 * @anchor ChromaHueMeasurement <b>Measurement details:</b> The general
31 * @ref measurementdetails "notes about measurement" apply also to this widget.
32 * Furthermore, in this widget, when painting a pixel of the gamut, the color
33 * of the pixel will be the color of the coordinate point at the center of the
34 * pixel. So the pixel at position <tt>QPoint(x, y)</tt> gets the color that
35 * corresponds to the coordinate point <tt>QPoint(x+0.5, y+0.5)</tt>.
36 * Also, mouse events work with pixel position; so when reacting on mouse
37 * events than it’s the center of the given mouse event pixel position that is
38 * considered when processing the mouse event. */
39class ChromaHueDiagramPrivate final
40{
41public:
42 ChromaHueDiagramPrivate(ChromaHueDiagram *backLink, const QSharedPointer<PerceptualColor::RgbColorSpace> &colorSpace);
43 /** @brief Default destructor
44 *
45 * The destructor is non-<tt>virtual</tt> because
46 * the class as a whole is <tt>final</tt>. */
47 ~ChromaHueDiagramPrivate() noexcept = default;
48
49 // Member variables
50 /** @brief The image of the chroma-hue diagram itself. */
51 AsyncImageProvider<ChromaHueImageParameters> m_chromaHueImage;
52 /** @brief Properties for @ref m_chromaHueImage. */
53 ChromaHueImageParameters m_chromaHueImageParameters;
54 /** @brief Internal storage of the @ref ChromaHueDiagram::currentColor()
55 * property */
56 LchDouble m_currentColor;
57 /** @brief Holds if currently a mouse event is active or not.
58 *
59 * Default value is <tt>false</tt>.
60 * - A mouse event gets typically activated on
61 * a @ref ChromaHueDiagram::mousePressEvent()
62 * done within the gamut diagram. The value is set to <tt>true</tt>.
63 * - While active, all @ref ChromaHueDiagram::mouseMoveEvent() will
64 * move the diagram’s color handle.
65 * - Once a @ref ChromaHueDiagram::mouseReleaseEvent() occurs, the value
66 * is set to <tt>false</tt>. Further mouse movements will not move the
67 * handle anymore.
68 *
69 * This is done because Qt’s default mouse tracking reacts on all clicks
70 * within the whole widget. However, <em>this</em> widget is meant as a
71 * circular widget, only reacting on mouse events within the circle;
72 * this requires this custom implementation. */
73 bool m_isMouseEventActive = false;
74 /** @brief Pointer to @ref RgbColorSpace object used to describe the
75 * color space. */
76 QSharedPointer<PerceptualColor::RgbColorSpace> m_rgbColorSpace;
77 /** @brief The image of the color wheel. */
78 ColorWheelImage m_wheelImage;
79
80 // Member functions
81 [[nodiscard]] int diagramBorder() const;
82 [[nodiscard]] QPointF diagramCenter() const;
83 [[nodiscard]] qreal diagramOffset() const;
84 [[nodiscard]] cmsCIELab fromWidgetPixelPositionToLab(const QPoint position) const;
85 [[nodiscard]] bool isWidgetPixelPositionWithinMouseSensibleCircle(const QPoint widgetCoordinates) const;
86 void setColorFromWidgetPixelPosition(const QPoint position);
87 [[nodiscard]] QPointF widgetCoordinatesFromCurrentColor() const;
88
89private:
90 Q_DISABLE_COPY(ChromaHueDiagramPrivate)
91
92 /** @brief Pointer to the object from which <em>this</em> object
93 * is the private implementation. */
94 ConstPropagatingRawPointer<ChromaHueDiagram> q_pointer;
95};
96
97} // namespace PerceptualColor
98
99#endif // CHROMAHUEDIAGRAM_P_H
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:36 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.