File indexing completed on 2024-05-12 04:44:33

0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT
0003 
0004 #ifndef GRADIENTSLIDER_P_H
0005 #define GRADIENTSLIDER_P_H
0006 
0007 // Include the header of the public class of this private implementation.
0008 // #include "gradientslider.h"
0009 
0010 #include "asyncimageprovider.h"
0011 #include "constpropagatingrawpointer.h"
0012 #include "gradientimageparameters.h"
0013 #include "lchadouble.h"
0014 #include <qglobal.h>
0015 #include <qnamespace.h>
0016 #include <qsharedpointer.h>
0017 class QPoint;
0018 
0019 namespace PerceptualColor
0020 {
0021 class GradientSlider;
0022 class RgbColorSpace;
0023 /** @internal
0024  *
0025  *  @brief Private implementation within the <em>Pointer to
0026  *  implementation</em> idiom */
0027 class GradientSliderPrivate final
0028 {
0029 public:
0030     explicit GradientSliderPrivate(GradientSlider *backLink);
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     ~GradientSliderPrivate() noexcept = default;
0036 
0037     // Methods
0038     [[nodiscard]] qreal fromWidgetPixelPositionToValue(QPoint pixelPosition);
0039     void initialize(const QSharedPointer<RgbColorSpace> &colorSpace, Qt::Orientation orientation);
0040     void setOrientationWithoutSignalAndForceNewSizePolicy(Qt::Orientation newOrientation);
0041     [[nodiscard]] int physicalPixelLength() const;
0042     [[nodiscard]] int physicalPixelThickness() const;
0043 
0044     // Data members
0045     /** @brief Internal storage for property @ref GradientSlider::firstColor */
0046     LchaDouble m_firstColor;
0047     /** @brief The gradient image (without the handle).
0048      *
0049      * Always at the left is the first color, always at the right
0050      * is the second color. This is independent from the actual
0051      * @ref GradientSlider::orientation and the actual LTR or RTL
0052      * layout. So when painting, it might be necessary to rotate
0053      * and/or mirror the image. */
0054     AsyncImageProvider<GradientImageParameters> m_gradientImage;
0055     /** @brief Properties for @ref m_gradientImage. */
0056     GradientImageParameters m_gradientImageParameters;
0057     /** @brief Internal storage for property
0058      * @ref GradientSlider::orientation */
0059     Qt::Orientation m_orientation;
0060     /** @brief Internal storage for property
0061      * @ref GradientSlider::pageStep */
0062     qreal m_pageStep = 0.1;
0063     /** @brief Internal storage for property
0064      * @ref GradientSlider::secondColor */
0065     LchaDouble m_secondColor;
0066     /** @brief Internal storage for property
0067      * @ref GradientSlider::singleStep */
0068     qreal m_singleStep = 0.01;
0069     /** @brief Internal storage for property
0070      * @ref GradientSlider::value */
0071     qreal m_value = 0.5;
0072 
0073 private:
0074     Q_DISABLE_COPY(GradientSliderPrivate)
0075     /** @brief Pointer to the object from which <em>this</em> object
0076      *  is the private implementation. */
0077     ConstPropagatingRawPointer<GradientSlider> q_pointer;
0078 };
0079 
0080 } // namespace PerceptualColor
0081 
0082 #endif // GRADIENTSLIDER_P_H