Perceptual Color

colorwheel_p.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef COLORWHEEL_P_H
5#define COLORWHEEL_P_H
6
7// Include the header of the public class of this private implementation.
8// #include "colorwheel.h"
9
10#include "colorwheelimage.h"
11#include "constpropagatingrawpointer.h"
12#include "polarpointf.h"
13#include <qglobal.h>
14#include <qpoint.h>
15#include <qsharedpointer.h>
16
17namespace PerceptualColor
18{
19class ColorWheel;
20
21class RgbColorSpace;
22
23/** @internal
24 *
25 * @brief Private implementation within the <em>Pointer to
26 * implementation</em> idiom */
27class ColorWheelPrivate final
28{
29public:
30 ColorWheelPrivate(ColorWheel *backLink, const QSharedPointer<PerceptualColor::RgbColorSpace> &colorSpace);
31 /** @brief Default destructor
32 *
33 * The destructor is non-<tt>virtual</tt> because
34 * the class as a whole is <tt>final</tt>. */
35 ~ColorWheelPrivate() noexcept = default;
36
37 /** @brief Internal storage of the @ref ColorWheel::hue() property */
38 qreal m_hue;
39 /** @brief Holds if currently a mouse event is active or not.
40 *
41 * Default value is <tt>false</tt>.
42 * - A mouse event gets typically activated on a
43 * @ref ColorWheel::mousePressEvent() done within the gamut diagram.
44 * The value is set to <tt>true</tt>.
45 * - While active, all @ref ColorWheel::mouseMoveEvent() will move the
46 * diagram’s color handle.
47 * - Once a @ref ColorWheel::mouseReleaseEvent() occurs, the value is set
48 * to <tt>false</tt>. Further mouse movements will not move the handle
49 * anymore.
50 *
51 * This is done because Qt’s default mouse tracking reacts on all clicks
52 * within the whole widget. However, <em>this</em> widget is meant as a
53 * circular widget, only reacting on mouse events within the circle;
54 * this requires this custom implementation. */
55 bool m_isMouseEventActive = false;
56 /** @brief Pointer to @ref RgbColorSpace object used to describe the
57 * color space. */
58 QSharedPointer<RgbColorSpace> m_rgbColorSpace;
59 /** @brief The image of the wheel itself. */
60 ColorWheelImage m_wheelImage;
61
62 [[nodiscard]] int border() const;
63 [[nodiscard]] QPointF fromWheelToWidgetCoordinates(const PolarPointF wheelCoordinates) const;
64 [[nodiscard]] PolarPointF fromWidgetPixelPositionToWheelCoordinates(const QPoint position) const;
65 [[nodiscard]] qreal innerDiameter() const;
66 void setHueNormalized(const qreal newHue);
67
68private:
69 Q_DISABLE_COPY(ColorWheelPrivate)
70
71 /** @brief Pointer to the object from which <em>this</em> object
72 * is the private implementation. */
73 ConstPropagatingRawPointer<ColorWheel> q_pointer;
74};
75
76} // namespace PerceptualColor
77
78#endif // COLORWHEEL_P_H
The namespace of this library.
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.