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 PerceptualColor::Swatches &swatchGrid, 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 cornerRadius() const;
52 [[nodiscard]] int horizontalPatchSpacing() const;
53 void initStyleOption(QStyleOptionFrame *option) const;
54 [[nodiscard]] int normalPatchSpacing() const;
55 [[nodiscard]] QPoint offset(const QStyleOptionFrame &styleOptionFrame) const;
56 [[nodiscard]] QSize patchSizeInner() const;
57 [[nodiscard]] QSize patchSizeOuter() const;
58 void retranslateUi();
59 void selectSwatch(QListSizeType newCurrentColomn, QListSizeType newCurrentRow);
60 void selectSwatchFromCurrentColor();
61 [[nodiscard]] int verticalPatchSpacing() const;
62 [[nodiscard]] int widePatchSpacing() const;
63
64 /** @brief Internal storage for property @ref SwatchBook::currentColor
65 *
66 * QColor automatically initializes with an invalid color, just like it
67 * should be for the property @ref SwatchBook::currentColor, so no
68 * need to initialize here explicitly. */
69 QColor m_currentColor;
70 /** @brief Pointer to the RgbColorSpace object. */
71 QSharedPointer<PerceptualColor::RgbColorSpace> m_rgbColorSpace;
72 /** @brief Selected column.
73 *
74 * If one of the swatches in the book is selected, this is
75 * the index of the column.
76 * Otherwise, its <tt>-1</tt>. */
77 QListSizeType m_selectedColumn = -1;
78 /** @brief Selected row.
79 *
80 * If one of the swatches in the book is selected, this is
81 * the index of the row.
82 * Otherwise, its <tt>-1</tt>. */
83 QListSizeType m_selectedRow = -1;
84 /** @brief The selection mark to use, or an empty string if no
85 * selection mark is available.
86 *
87 * The selection mark is drawn above the patch that is currently selected.
88 *
89 * This variable contains the localized selection mark string (if all its
90 * characters are) available in the default font of this widget. An
91 * empty string otherwise.
92 *
93 * The value is set by @ref retranslateUi(). */
94 QString m_selectionMark;
95 /** @brief Internal storage for property @ref SwatchBook::swatchGrid */
96 Swatches m_swatchGrid;
97 /** @brief List of axis where @ref widePatchSpacing should be used. */
98 const Qt::Orientations m_wideSpacing;
99
100private:
101 Q_DISABLE_COPY(SwatchBookPrivate)
102
103 /** @brief Pointer to the object from which <em>this</em> object
104 * is the private implementation. */
105 ConstPropagatingRawPointer<SwatchBook> q_pointer;
106};
107
108} // namespace PerceptualColor
109
110#endif // SWATCHBOOK_P_H
The namespace of this library.
Array2D< QColor > Swatches
Swatches organized in a grid.
Definition helper.h:242
Q_OBJECTQ_OBJECT
typedef Orientations
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.