File indexing completed on 2024-05-12 04:44:32
0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com> 0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT 0003 0004 #ifndef COLORWHEEL_P_H 0005 #define COLORWHEEL_P_H 0006 0007 // Include the header of the public class of this private implementation. 0008 // #include "colorwheel.h" 0009 0010 #include "colorwheelimage.h" 0011 #include "constpropagatingrawpointer.h" 0012 #include "polarpointf.h" 0013 #include <qglobal.h> 0014 #include <qpoint.h> 0015 #include <qsharedpointer.h> 0016 0017 namespace PerceptualColor 0018 { 0019 class ColorWheel; 0020 0021 class RgbColorSpace; 0022 0023 /** @internal 0024 * 0025 * @brief Private implementation within the <em>Pointer to 0026 * implementation</em> idiom */ 0027 class ColorWheelPrivate final 0028 { 0029 public: 0030 ColorWheelPrivate(ColorWheel *backLink, const QSharedPointer<PerceptualColor::RgbColorSpace> &colorSpace); 0031 /** @brief Default destructor 0032 * 0033 * The destructor is non-<tt>virtual</tt> because 0034 * the class as a whole is <tt>final</tt>. */ 0035 ~ColorWheelPrivate() noexcept = default; 0036 0037 /** @brief Internal storage of the @ref ColorWheel::hue() property */ 0038 qreal m_hue; 0039 /** @brief Holds if currently a mouse event is active or not. 0040 * 0041 * Default value is <tt>false</tt>. 0042 * - A mouse event gets typically activated on a 0043 * @ref ColorWheel::mousePressEvent() done within the gamut diagram. 0044 * The value is set to <tt>true</tt>. 0045 * - While active, all @ref ColorWheel::mouseMoveEvent() will move the 0046 * diagram’s color handle. 0047 * - Once a @ref ColorWheel::mouseReleaseEvent() occurs, the value is set 0048 * to <tt>false</tt>. Further mouse movements will not move the handle 0049 * anymore. 0050 * 0051 * This is done because Qt’s default mouse tracking reacts on all clicks 0052 * within the whole widget. However, <em>this</em> widget is meant as a 0053 * circular widget, only reacting on mouse events within the circle; 0054 * this requires this custom implementation. */ 0055 bool m_isMouseEventActive = false; 0056 /** @brief Pointer to @ref RgbColorSpace object used to describe the 0057 * color space. */ 0058 QSharedPointer<RgbColorSpace> m_rgbColorSpace; 0059 /** @brief The image of the wheel itself. */ 0060 ColorWheelImage m_wheelImage; 0061 0062 [[nodiscard]] int border() const; 0063 [[nodiscard]] QPointF fromWheelToWidgetCoordinates(const PolarPointF wheelCoordinates) const; 0064 [[nodiscard]] PolarPointF fromWidgetPixelPositionToWheelCoordinates(const QPoint position) const; 0065 [[nodiscard]] qreal innerDiameter() const; 0066 void setHueNormalized(const qreal newHue); 0067 0068 private: 0069 Q_DISABLE_COPY(ColorWheelPrivate) 0070 0071 /** @brief Pointer to the object from which <em>this</em> object 0072 * is the private implementation. */ 0073 ConstPropagatingRawPointer<ColorWheel> q_pointer; 0074 }; 0075 0076 } // namespace PerceptualColor 0077 0078 #endif // COLORWHEEL_P_H