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 HELPERCONSTANTS_H 0005 #define HELPERCONSTANTS_H 0006 0007 #include <qglobal.h> 0008 #include <qstring.h> 0009 0010 /** @internal 0011 * 0012 * @file 0013 * 0014 * Provides global constant values. */ 0015 0016 namespace PerceptualColor 0017 { 0018 0019 /** @internal 0020 * 0021 * @brief Precision for gamut boundary search 0022 * 0023 * We have to search sometimes for the gamut boundary. This value defines 0024 * the precision of the search: Smaller values mean better precision and 0025 * slower processing. */ 0026 constexpr qreal gamutPrecisionCielab = 0.001; 0027 0028 /** @internal 0029 * 0030 * @brief Precision for gamut boundary search 0031 * 0032 * We have to search sometimes for the gamut boundary. This value defines 0033 * the precision of the search: Smaller values mean better precision and 0034 * slower processing. */ 0035 constexpr qreal gamutPrecisionOklab = gamutPrecisionCielab / 100; 0036 0037 /** @internal 0038 * 0039 * @brief The overlap is a recommended tolerance value, measured in physical 0040 * pixels. 0041 * 0042 * It can be used during the painting process to paint “a little bit more 0043 * surface than requested”, just to be sure no pixel is missing. We 0044 * choose <tt>2</tt> because this value might also be used for radius 0045 * values, and at 45°, going from one edge of a pixel to the opposite edge 0046 * yet has a distance of √2 ≈ 1,41, which we round up to <tt>2</tt> just 0047 * to be sure. */ 0048 constexpr int overlap = 2; 0049 0050 /** @internal 0051 * 0052 * @brief Proposed scale factor for gradients 0053 * 0054 * Widgets provide a <tt>minimumSizeHint</tt> and a <tt>sizeHint</tt>. 0055 * This value provides a scale factor that is multiplied with 0056 * <tt>minimumSizeHint</tt> to get an appropriate <tt>sizeHint</tt>. 0057 * This scale factor is meant for gradient-based widgets. */ 0058 // This value is somewhat arbitrary… 0059 constexpr qreal scaleFromMinumumSizeHintToSizeHint = 1.2; 0060 0061 /** @internal 0062 * 0063 * @brief Amount of single step for alpha. 0064 * 0065 * Measured for an alpha range from 0 (transparent) to 1 (opaque). 0066 * 0067 * The smaller of two natural steps that a widget provides and 0068 * typically corresponds to the user pressing a key or using the mouse 0069 * wheel: The value will be incremented/decremented by the amount of this 0070 * value. 0071 * 0072 * @sa @ref pageStepAlpha */ 0073 constexpr qreal singleStepAlpha = 0.01; 0074 0075 /** @internal 0076 * 0077 * @brief Amount of single step for chroma. 0078 * 0079 * Measured in LCH chroma units. 0080 * 0081 * The smaller of two natural steps that a widget provides and 0082 * typically corresponds to the user pressing a key or using the mouse 0083 * wheel: The value will be incremented/decremented by the amount of this 0084 * value. 0085 * 0086 * @sa @ref pageStepChroma */ 0087 constexpr int singleStepChroma = 1; 0088 0089 /** @internal 0090 * 0091 * @brief Amount of single step for hue. 0092 * 0093 * Measured in degree. 0094 * 0095 * The smaller of two natural steps that a widget provides and 0096 * typically corresponds to the user pressing a key or using the mouse 0097 * wheel: The value will be incremented/decremented by the amount of this 0098 * value. 0099 * 0100 * @sa @ref pageStepHue 0101 * 0102 * @todo What would be a good value for this? Its effect depends on 0103 * chroma: On higher chroma, the same step in hue means a bigger visual 0104 * color difference. We could even calculate that, but it does not seem to 0105 * be very intuitive if the reaction on mouse wheel events are different 0106 * depending on chroma - that would not be easy to understand for the 0107 * user. And it might be better that the user this way also notices 0108 * intuitively that hue changes are not linear across chroma. Anyway: 0109 * What would be a sensible default step? */ 0110 constexpr int singleStepHue = 360 / 100; 0111 0112 /** @internal 0113 * 0114 * @brief Amount of single step for lightness. 0115 * 0116 * Measured in LCH lightness units. 0117 * 0118 * The smaller of two natural steps that a widget provides and 0119 * typically corresponds to the user pressing a key or using the mouse 0120 * wheel: The value will be incremented/decremented by the amount of this 0121 * value. 0122 * 0123 * @sa @ref pageStepLightness */ 0124 constexpr int singleStepLightness = 1; 0125 0126 /** @internal 0127 * 0128 * @brief Amount of single step for Ok lightness, a, b, chroma (but 0129 * <em>not</em> hue). 0130 * 0131 * Measured in Ok units. 0132 * 0133 * The smaller of two natural steps that a widget provides and 0134 * typically corresponds to the user pressing a key or using the mouse 0135 * wheel: The value will be incremented/decremented by the amount of this 0136 * value. */ 0137 constexpr double singleStepOklabc = 0.01; 0138 0139 /** @internal 0140 * 0141 * @brief Amount of page step for alpha. 0142 * 0143 * Measured for an alpha range from 0 (transparent) to 1 (opaque). 0144 * 0145 * The larger of two natural steps that a widget provides and 0146 * typically corresponds to the user pressing a key or using the mouse 0147 * wheel: The value will be incremented/decremented by the amount of this 0148 * value. 0149 * 0150 * The value is 10 times @ref singleStepChroma. This behavior 0151 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than 0152 * its single step. */ 0153 constexpr qreal pageStepAlpha = 10 * singleStepAlpha; 0154 0155 /** @internal 0156 * 0157 * @brief Amount of page step for chroma. 0158 * 0159 * Measured in LCH chroma units. 0160 * 0161 * The larger of two natural steps that a widget provides and 0162 * typically corresponds to the user pressing a key or using the mouse 0163 * wheel: The value will be incremented/decremented by the amount of this 0164 * value. 0165 * 0166 * The value is 10 times @ref singleStepChroma. This behavior 0167 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than 0168 * its single step. */ 0169 constexpr int pageStepChroma = 10 * singleStepChroma; 0170 0171 /** @internal 0172 * 0173 * @brief Amount of page step for hue. 0174 * 0175 * Measured in degree. 0176 * 0177 * The larger of two natural steps that a widget provides and 0178 * typically corresponds to the user pressing a key or using the mouse 0179 * wheel: The value will be incremented/decremented by the amount of this 0180 * value. 0181 * 0182 * The value is 10 times @ref singleStepHue. This behavior 0183 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than 0184 * its single step. */ 0185 constexpr int pageStepHue = 10 * singleStepHue; 0186 0187 /** @internal 0188 * 0189 * @brief Amount of page step for lightness. 0190 * 0191 * Measured in LCH lightness units. 0192 * 0193 * The larger of two natural steps that a widget provides and 0194 * typically corresponds to the user pressing a key or using the mouse 0195 * wheel: The value will be incremented/decremented by the amount of this 0196 * value. 0197 * 0198 * The value is 10 times @ref singleStepLightness. This behavior 0199 * corresponds to QAbstractSlider, who’s page step is also 10 times bigger than 0200 * its single step. */ 0201 constexpr int pageStepLightness = 10 * singleStepLightness; 0202 0203 /** @internal 0204 * 0205 * @brief Invisible marker for rich text 0206 * 0207 * Some parts of Qt accept both, plain text and rich text, within the same 0208 * property. Example: <tt>QToolTip</tt> uses <tt>Qt::mightBeRichText()</tt> 0209 * to decide if a text is treated as rich text or as plain text. But 0210 * <tt>Qt::mightBeRichText()</tt> is only a raw guess. This situation 0211 * is not comfortable: You never really know in advance if text will be 0212 * treated as rich text or as plain text. 0213 * 0214 * This function provides a solution. It provides a rich text marker. If 0215 * your text starts with this marker, it will always be treated 0216 * as rich text. The marker itself will not be visible in the rendered 0217 * rich text. 0218 * 0219 * Usage example: 0220 * @snippet testhelperconstants.cpp richTextMarkerExample */ 0221 inline const QString richTextMarker = QStringLiteral(u"<a/>"); 0222 0223 } // namespace PerceptualColor 0224 0225 #endif // HELPERCONSTANTS_H