File indexing completed on 2025-01-26 04:11:30
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "KisStandardOptionData.h" 0008 0009 #include <KisPaintOpOptionWidgetUtils.h> 0010 #include <KisPaintopSettingsIds.h> 0011 0012 0013 namespace KisPaintOpOptionWidgetUtils { 0014 0015 namespace detail { 0016 KisCurveOptionWidget *createOpacityOptionWidgetImpl(KisPaintOpOption::PaintopCategory category, const QString &prefix) 0017 { 0018 return createCurveOptionWidget(KisOpacityOptionData(prefix), 0019 category, 0020 i18n("Transparent"), 0021 i18n("Opaque")); 0022 } 0023 KisCurveOptionWidget *createRotationOptionWidgetImpl(KisPaintOpOption::PaintopCategory category, const QString &prefix) 0024 { 0025 return createCurveOptionWidget(KisRotationOptionData(prefix), 0026 category, 0027 i18n("-180°"), 0028 i18n("180°")); 0029 } 0030 } 0031 0032 KisCurveOptionWidget *createOpacityOptionWidget() 0033 { 0034 return detail::createOpacityOptionWidgetImpl(KisPaintOpOption::GENERAL, ""); 0035 } 0036 0037 KisCurveOptionWidget *createFlowOptionWidget() 0038 { 0039 return createCurveOptionWidget(KisFlowOptionData(), 0040 KisPaintOpOption::GENERAL); 0041 } 0042 0043 KisCurveOptionWidget *createRatioOptionWidget() 0044 { 0045 return createCurveOptionWidget(KisRatioOptionData(), 0046 KisPaintOpOption::GENERAL); 0047 } 0048 0049 KisCurveOptionWidget *createSoftnessOptionWidget() 0050 { 0051 return createCurveOptionWidget(KisSoftnessOptionData(), 0052 KisPaintOpOption::GENERAL, 0053 i18n("Soft"), 0054 i18n("Hard")); 0055 } 0056 0057 KisCurveOptionWidget *createRotationOptionWidget() 0058 { 0059 return detail::createRotationOptionWidgetImpl(KisPaintOpOption::GENERAL, ""); 0060 } 0061 0062 KisCurveOptionWidget *createDarkenOptionWidget() 0063 { 0064 return createCurveOptionWidget(KisDarkenOptionData(), 0065 KisPaintOpOption::COLOR, 0066 i18n("0.0"), 0067 i18n("1.0")); 0068 } 0069 0070 KisCurveOptionWidget *createMixOptionWidget() 0071 { 0072 return createCurveOptionWidget(KisMixOptionData(), 0073 KisPaintOpOption::COLOR, 0074 i18nc("Background painting color", "Background"), 0075 i18nc("Foreground painting color", "Foreground")); 0076 } 0077 0078 namespace detail { 0079 QString hueMinLabel() 0080 { 0081 // xgettext: no-c-format 0082 QString activeColorMsg = i18n("(0° is active color)"); 0083 QString br("<br />"); 0084 QString fullPercent = i18n("+180°"); 0085 QString zeroPercent = i18n("-180°"); 0086 0087 return QString(zeroPercent + br + i18n("CCW hue") + br + activeColorMsg); 0088 } 0089 0090 QString hueMaxLabel() 0091 { 0092 // xgettext: no-c-format 0093 QString activeColorMsg = i18n("(0° is active color)"); 0094 QString br("<br />"); 0095 QString fullPercent = i18n("+180°"); 0096 QString zeroPercent = i18n("-180°"); 0097 0098 return QString(fullPercent + br + i18n("CW hue")); 0099 } 0100 0101 QString saturationMinLabel() 0102 { 0103 // xgettext: no-c-format 0104 QString activeColorMsg = i18n("(50% is active color)"); 0105 QString br("<br />"); 0106 QString fullPercent = i18n("+100%"); 0107 QString zeroPercent = i18n("-100%"); 0108 0109 return QString(zeroPercent + br + i18n("Less saturation ") + br + activeColorMsg); 0110 0111 } 0112 0113 QString saturationMaxLabel() 0114 { 0115 // xgettext: no-c-format 0116 QString activeColorMsg = i18n("(50% is active color)"); 0117 QString br("<br />"); 0118 QString fullPercent = i18n("+100%"); 0119 QString zeroPercent = i18n("-100%"); 0120 0121 return QString(fullPercent + br + i18n("More saturation")); 0122 } 0123 0124 QString valueMinLabel() 0125 { 0126 // xgettext: no-c-format 0127 QString activeColorMsg = i18n("(50% is active color)"); 0128 QString br("<br />"); 0129 QString fullPercent = i18n("+100%"); 0130 QString zeroPercent = i18n("-100%"); 0131 0132 return QString(zeroPercent + br + i18nc("Lower HSV brightness", "Lower value ") + br + activeColorMsg); 0133 0134 } 0135 0136 QString valueMaxLabel() 0137 { 0138 // xgettext: no-c-format 0139 QString activeColorMsg = i18n("(50% is active color)"); 0140 QString br("<br />"); 0141 QString fullPercent = i18n("+100%"); 0142 QString zeroPercent = i18n("-100%"); 0143 0144 return QString(fullPercent + br + i18nc("Higher HSV brightness", "Higher value")); 0145 0146 0147 } 0148 } 0149 0150 KisCurveOptionWidget *createHueOptionWidget() 0151 { 0152 return createCurveOptionWidget(KisHueOptionData(), KisPaintOpOption::COLOR, 0153 detail::hueMinLabel(), 0154 detail::hueMaxLabel(), 0155 -180, 180, i18n("°")); 0156 } 0157 0158 KisCurveOptionWidget *createSaturationOptionWidget() 0159 { 0160 return createCurveOptionWidget(KisSaturationOptionData(), KisPaintOpOption::COLOR, 0161 detail::saturationMinLabel(), 0162 detail::saturationMaxLabel()); 0163 } 0164 0165 KisCurveOptionWidget *createValueOptionWidget() 0166 { 0167 return createCurveOptionWidget(KisValueOptionData(), 0168 KisPaintOpOption::COLOR, 0169 detail::valueMinLabel(), 0170 detail::valueMaxLabel()); 0171 } 0172 0173 KisCurveOptionWidget *createRateOptionWidget() 0174 { 0175 return createCurveOptionWidget(KisRateOptionData(), 0176 KisPaintOpOption::COLOR); 0177 } 0178 0179 KisCurveOptionWidget *createStrengthOptionWidget() 0180 { 0181 return createCurveOptionWidget(KisStrengthOptionData(), 0182 KisPaintOpOption::TEXTURE); 0183 } 0184 0185 KisCurveOptionWidget *createMaskingOpacityOptionWidget() 0186 { 0187 return detail::createOpacityOptionWidgetImpl(KisPaintOpOption::MASKING_BRUSH, KisPaintOpUtils::MaskingBrushPresetPrefix); 0188 } 0189 0190 KisCurveOptionWidget *createMaskingFlowOptionWidget() 0191 { 0192 return createCurveOptionWidget(KisFlowOptionData(KisPaintOpUtils::MaskingBrushPresetPrefix), 0193 KisPaintOpOption::MASKING_BRUSH); 0194 } 0195 0196 KisCurveOptionWidget *createMaskingRatioOptionWidget() 0197 { 0198 return createCurveOptionWidget(KisRatioOptionData(KisPaintOpUtils::MaskingBrushPresetPrefix), 0199 KisPaintOpOption::MASKING_BRUSH); 0200 } 0201 0202 KisCurveOptionWidget *createMaskingRotationOptionWidget() 0203 { 0204 return detail::createRotationOptionWidgetImpl(KisPaintOpOption::MASKING_BRUSH, KisPaintOpUtils::MaskingBrushPresetPrefix); 0205 } 0206 0207 }