Perceptual Color

swatchbook_p.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef SWATCHBOOK_P_H
5#define SWATCHBOOK_P_H
6
7// Include the header of the public class of this private implementation.
8// #include "swatchbook.h"
9
10#include "constpropagatingrawpointer.h"
11#include "helper.h"
12#include "helperqttypes.h"
13#include <qcolor.h>
14#include <qglobal.h>
15#include <qnamespace.h>
16#include <qobject.h>
17#include <qpoint.h>
18#include <qsharedpointer.h>
19#include <qsize.h>
20#include <qstring.h>
21#include <qstyleoption.h>
22
23#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
24#include <qtmetamacros.h>
25#else
26#include <qobjectdefs.h>
27#endif
28
29namespace PerceptualColor
30{
31class SwatchBook;
32class RgbColorSpace;
33
34/** @internal
35 *
36 * @brief Private implementation within the <em>Pointer to
37 * implementation</em> idiom */
38class SwatchBookPrivate final : public QObject
39{
41
42public:
43 explicit SwatchBookPrivate(SwatchBook *backLink, const Array2D<QColor> &swatches, Qt::Orientations wideSpacing);
44 /** @brief Default destructor
45 *
46 * The destructor is non-<tt>virtual</tt> because
47 * the class as a whole is <tt>final</tt>. */
48 ~SwatchBookPrivate() noexcept override = default;
49
50 [[nodiscard]] QSize colorPatchesSizeWithMargin() const;
51 [[nodiscard]] int horizontalPatchSpacing() const;
52 void initStyleOption(QStyleOptionFrame *option) const;
53 [[nodiscard]] int normalPatchSpacing() const;
54 [[nodiscard]] QPoint offset(const QStyleOptionFrame &styleOptionFrame) const;
55 [[nodiscard]] QSize patchSizeInner() const;
56 [[nodiscard]] QSize patchSizeOuter() const;
57 void retranslateUi();
58 void selectSwatch(QListSizeType newCurrentColomn, QListSizeType newCurrentRow);
59 [[nodiscard]] int verticalPatchSpacing() const;
60 [[nodiscard]] int widePatchSpacing() const;
61
62 /** @brief Internal storage for property @ref SwatchBook::currentColor
63 *
64 * QColor automatically initializes with an invalid color, just like it
65 * should be for the property @ref SwatchBook::currentColor, so no
66 * need to initialize here explicitly. */
67 QColor m_currentColor;
68 /** @brief Pointer to the RgbColorSpace object. */
69 QSharedPointer<PerceptualColor::RgbColorSpace> m_rgbColorSpace;
70 /** @brief Selected column.
71 *
72 * If one of the swatches in the book is selected, this is
73 * the index of the column.
74 * Otherwise, its <tt>-1</tt>. */
75 QListSizeType m_selectedColumn = -1;
76 /** @brief Selected row.
77 *
78 * If one of the swatches in the book is selected, this is
79 * the index of the row.
80 * Otherwise, its <tt>-1</tt>. */
81 QListSizeType m_selectedRow = -1;
82 /** @brief The selection mark to use, or an empty string if no
83 * selection mark is available.
84 *
85 * The selection mark is drawn above the patch that is currently selected.
86 *
87 * This variable contains the localized selection mark string (if all its
88 * characters are) available in the default font of this widget. An
89 * empty string otherwise.
90 *
91 * The value is set by @ref retranslateUi(). */
92 QString m_selectionMark;
93 /** @brief The colors of the swatches.
94 *
95 * This is a two-dimensional array. At the first level the
96 * basic color (red, green…). At the second level, a particular
97 * tint/shade of this basic color.
98 *
99 * @sa @ref m_selectedColumn
100 * @sa @ref m_selectedRow */
101 const Array2D<QColor> m_swatches;
102 /** @brief List of axis where @ref widePatchSpacing should be used. */
103 const Qt::Orientations m_wideSpacing;
104
105private:
106 Q_DISABLE_COPY(SwatchBookPrivate)
107
108 /** @brief Pointer to the object from which <em>this</em> object
109 * is the private implementation. */
110 ConstPropagatingRawPointer<SwatchBook> q_pointer;
111};
112
113} // namespace PerceptualColor
114
115#endif // SWATCHBOOK_P_H
The namespace of this library.
Q_OBJECTQ_OBJECT
typedef Orientations
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.