File indexing completed on 2024-05-12 04:44:31
0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com> 0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT 0003 0004 #ifndef COLORPATCH_P_H 0005 #define COLORPATCH_P_H 0006 0007 // Include the header of the public class of this private implementation. 0008 // #include "colorpatch.h" 0009 0010 #include "constpropagatingrawpointer.h" 0011 #include <qcolor.h> 0012 #include <qglobal.h> 0013 #include <qimage.h> 0014 #include <qpixmap.h> 0015 #include <qpoint.h> 0016 class QLabel; 0017 0018 namespace PerceptualColor 0019 { 0020 0021 class ColorPatch; 0022 0023 /** @internal 0024 * 0025 * @brief Private implementation within the <em>Pointer to 0026 * implementation</em> idiom */ 0027 class ColorPatchPrivate final 0028 { 0029 public: 0030 /** @brief Constructor */ 0031 explicit ColorPatchPrivate(ColorPatch *backLink); 0032 /** @brief Default destructor 0033 * 0034 * The destructor is non-<tt>virtual</tt> because 0035 * the class as a whole is <tt>final</tt>. */ 0036 ~ColorPatchPrivate() noexcept = default; 0037 0038 /** @brief Initial cursor position (at the time of the left-click) 0039 * where a drag-and-drop action starts. 0040 * 0041 * @sa @ref ColorPatch::mousePressEvent 0042 * @sa @ref ColorPatch::mouseMoveEvent */ 0043 QPoint dragStartPosition; 0044 0045 /** @brief Internal storage for property @ref ColorPatch::color 0046 * 0047 * QColor automatically initializes with an invalid color, just like it 0048 * should be for the property @ref ColorPatch::color, so no need to 0049 * initialize here explicitly. */ 0050 QColor m_color; 0051 /** @brief The QLabel widget that is used to display the color. */ 0052 QLabel *m_label; 0053 0054 [[nodiscard]] QImage renderImage(const int width, const int height); 0055 [[nodiscard]] QPixmap renderPixmap(const int width, const int height); 0056 void updatePixmap(); 0057 0058 private: 0059 Q_DISABLE_COPY(ColorPatchPrivate) 0060 0061 /** @brief Pointer to the object from which <em>this</em> object 0062 * is the private implementation. */ 0063 ConstPropagatingRawPointer<ColorPatch> q_pointer; 0064 }; 0065 0066 } // namespace PerceptualColor 0067 0068 #endif // COLORPATCH_P_H