Perceptual Color

helperconstants.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef HELPERCONSTANTS_H
5#define HELPERCONSTANTS_H
6
7#include <qglobal.h>
8#include <qstring.h>
9
10/** @internal
11 *
12 * @file
13 *
14 * Provides global constant values. */
15
16namespace PerceptualColor
17{
18
19/** @internal
20 *
21 * @brief Precision for gamut boundary search
22 *
23 * We have to search sometimes for the gamut boundary. This value defines
24 * the precision of the search: Smaller values mean better precision and
25 * slower processing. */
26constexpr qreal gamutPrecisionCielab = 0.001;
27
28/** @internal
29 *
30 * @brief Precision for gamut boundary search
31 *
32 * We have to search sometimes for the gamut boundary. This value defines
33 * the precision of the search: Smaller values mean better precision and
34 * slower processing. */
35constexpr qreal gamutPrecisionOklab = gamutPrecisionCielab / 100;
36
37/** @internal
38 *
39 * @brief The overlap is a recommended tolerance value, measured in physical
40 * pixels.
41 *
42 * It can be used during the painting process to paint “a little bit more
43 * surface than requested”, just to be sure no pixel is missing. We
44 * choose <tt>2</tt> because this value might also be used for radius
45 * values, and at 45°, going from one edge of a pixel to the opposite edge
46 * yet has a distance of √2 ≈ 1,41, which we round up to <tt>2</tt> just
47 * to be sure. */
48constexpr int overlap = 2;
49
50/** @internal
51 *
52 * @brief Proposed scale factor for gradients
53 *
54 * Widgets provide a <tt>minimumSizeHint</tt> and a <tt>sizeHint</tt>.
55 * This value provides a scale factor that is multiplied with
56 * <tt>minimumSizeHint</tt> to get an appropriate <tt>sizeHint</tt>.
57 * This scale factor is meant for gradient-based widgets. */
58// This value is somewhat arbitrary…
59constexpr qreal scaleFromMinumumSizeHintToSizeHint = 1.2;
60
61/** @internal
62 *
63 * @brief Amount of single step for alpha.
64 *
65 * Measured for an alpha range from 0 (transparent) to 1 (opaque).
66 *
67 * The smaller of two natural steps that a widget provides and
68 * typically corresponds to the user pressing a key or using the mouse
69 * wheel: The value will be incremented/decremented by the amount of this
70 * value.
71 *
72 * @sa @ref pageStepAlpha */
73constexpr qreal singleStepAlpha = 0.01;
74
75/** @internal
76 *
77 * @brief Amount of single step for chroma.
78 *
79 * Measured in LCH chroma units.
80 *
81 * The smaller of two natural steps that a widget provides and
82 * typically corresponds to the user pressing a key or using the mouse
83 * wheel: The value will be incremented/decremented by the amount of this
84 * value.
85 *
86 * @sa @ref pageStepChroma */
87constexpr int singleStepChroma = 1;
88
89/** @internal
90 *
91 * @brief Amount of single step for hue.
92 *
93 * Measured in degree.
94 *
95 * The smaller of two natural steps that a widget provides and
96 * typically corresponds to the user pressing a key or using the mouse
97 * wheel: The value will be incremented/decremented by the amount of this
98 * value.
99 *
100 * @sa @ref pageStepHue
101 *
102 * @todo What would be a good value for this? Its effect depends on
103 * chroma: On higher chroma, the same step in hue means a bigger visual
104 * color difference. We could even calculate that, but it does not seem to
105 * be very intuitive if the reaction on mouse wheel events are different
106 * depending on chroma - that would not be easy to understand for the
107 * user. And it might be better that the user this way also notices
108 * intuitively that hue changes are not linear across chroma. Anyway:
109 * What would be a sensible default step? */
110constexpr int singleStepHue = 360 / 100;
111
112/** @internal
113 *
114 * @brief Amount of single step for lightness.
115 *
116 * Measured in LCH lightness units.
117 *
118 * The smaller of two natural steps that a widget provides and
119 * typically corresponds to the user pressing a key or using the mouse
120 * wheel: The value will be incremented/decremented by the amount of this
121 * value.
122 *
123 * @sa @ref pageStepLightness */
124constexpr int singleStepLightness = 1;
125
126/** @internal
127 *
128 * @brief Amount of single step for Ok lightness, a, b, chroma (but
129 * <em>not</em> hue).
130 *
131 * Measured in Ok units.
132 *
133 * The smaller of two natural steps that a widget provides and
134 * typically corresponds to the user pressing a key or using the mouse
135 * wheel: The value will be incremented/decremented by the amount of this
136 * value. */
137constexpr double singleStepOklabc = 0.01;
138
139/** @internal
140 *
141 * @brief Amount of page step for alpha.
142 *
143 * Measured for an alpha range from 0 (transparent) to 1 (opaque).
144 *
145 * The larger of two natural steps that a widget provides and
146 * typically corresponds to the user pressing a key or using the mouse
147 * wheel: The value will be incremented/decremented by the amount of this
148 * value.
149 *
150 * The value is 10 times @ref singleStepChroma. This behavior
151 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than
152 * its single step. */
153constexpr qreal pageStepAlpha = 10 * singleStepAlpha;
154
155/** @internal
156 *
157 * @brief Amount of page step for chroma.
158 *
159 * Measured in LCH chroma units.
160 *
161 * The larger of two natural steps that a widget provides and
162 * typically corresponds to the user pressing a key or using the mouse
163 * wheel: The value will be incremented/decremented by the amount of this
164 * value.
165 *
166 * The value is 10 times @ref singleStepChroma. This behavior
167 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than
168 * its single step. */
169constexpr int pageStepChroma = 10 * singleStepChroma;
170
171/** @internal
172 *
173 * @brief Amount of page step for hue.
174 *
175 * Measured in degree.
176 *
177 * The larger of two natural steps that a widget provides and
178 * typically corresponds to the user pressing a key or using the mouse
179 * wheel: The value will be incremented/decremented by the amount of this
180 * value.
181 *
182 * The value is 10 times @ref singleStepHue. This behavior
183 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than
184 * its single step. */
185constexpr int pageStepHue = 10 * singleStepHue;
186
187/** @internal
188 *
189 * @brief Amount of page step for lightness.
190 *
191 * Measured in LCH lightness units.
192 *
193 * The larger of two natural steps that a widget provides and
194 * typically corresponds to the user pressing a key or using the mouse
195 * wheel: The value will be incremented/decremented by the amount of this
196 * value.
197 *
198 * The value is 10 times @ref singleStepLightness. This behavior
199 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than
200 * its single step. */
201constexpr int pageStepLightness = 10 * singleStepLightness;
202
203/** @internal
204 *
205 * @brief Invisible marker for rich text
206 *
207 * Some parts of Qt accept both, plain text and rich text, within the same
208 * property. Example: <tt>QToolTip</tt> uses <tt>Qt::mightBeRichText()</tt>
209 * to decide if a text is treated as rich text or as plain text. But
210 * <tt>Qt::mightBeRichText()</tt> is only a raw guess. This situation
211 * is not comfortable: You never really know in advance if text will be
212 * treated as rich text or as plain text.
213 *
214 * This function provides a solution. It provides a rich text marker. If
215 * your text starts with this marker, it will always be treated
216 * as rich text. The marker itself will not be visible in the rendered
217 * rich text.
218 *
219 * Usage example:
220 * @snippet testhelperconstants.cpp richTextMarkerExample */
221inline const QString richTextMarker = QStringLiteral(u"<a/>");
222
223} // namespace PerceptualColor
224
225#endif // HELPERCONSTANTS_H
The namespace of this library.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:48:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.