File indexing completed on 2025-02-02 04:22:18

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include <MyPaintStandardOptionData.h>
0008 
0009 namespace deprecated_remove_after_krita6 {
0010 
0011 /**
0012  * Before Krita 5.2 MyPaint brushes saved into .kpp files used to have
0013  * separate properties for hardness, opacity and diameter. They are gone
0014  * with Krita 5.2, but to make sure new brush presets can be open with the
0015  * older versions of Krita, we should keep them for some time.
0016  */
0017 
0018 const QString MYPAINT_HARDNESS = "MyPaint/hardness";
0019 const QString MYPAINT_OPACITY = "MyPaint/opcity";
0020 const QString MYPAINT_DIAMETER = "MyPaint/diameter";
0021 
0022 class SensorPackOpacity : public MyPaintSensorPack
0023 {
0024 public:
0025     KisSensorPackInterface * clone() const override
0026     {
0027         return new SensorPackOpacity(*this);
0028     }
0029 
0030     void write(const KisCurveOptionDataCommon &data, KisPropertiesConfiguration *setting) const override
0031     {
0032         MyPaintSensorPack::write(data, setting);
0033         setting->setProperty(MYPAINT_OPACITY, data.strengthValue);
0034     }
0035 };
0036 
0037 class SensorPackHardness : public MyPaintSensorPack
0038 {
0039 public:
0040     KisSensorPackInterface * clone() const override
0041     {
0042         return new SensorPackHardness(*this);
0043     }
0044     void write(const KisCurveOptionDataCommon &data, KisPropertiesConfiguration *setting) const override
0045     {
0046         MyPaintSensorPack::write(data, setting);
0047         setting->setProperty(MYPAINT_HARDNESS, data.strengthValue);
0048     }
0049 };
0050 
0051 
0052 class SensorPackRadiusLogarithmic : public MyPaintSensorPack
0053 {
0054 public:
0055     KisSensorPackInterface * clone() const override {
0056         return new SensorPackRadiusLogarithmic(*this);
0057     }
0058     void write(const KisCurveOptionDataCommon &data, KisPropertiesConfiguration *setting) const override
0059     {
0060         MyPaintSensorPack::write(data, setting);
0061         setting->setProperty(MYPAINT_DIAMETER, 2.0 * exp(data.strengthValue));
0062     }
0063 };
0064 
0065 } // namespace deprecated_remove_after_krita6
0066 
0067 MyPaintRadiusLogarithmicData::MyPaintRadiusLogarithmicData()
0068     : MyPaintCurveOptionData("",
0069                              KoID("radius_logarithmic",
0070                                   i18n("Radius Logarithmic")),
0071                              false, true, 0.01, 8.0,
0072                              new deprecated_remove_after_krita6::SensorPackRadiusLogarithmic())
0073 {
0074 }
0075 
0076 MyPaintHardnessData::MyPaintHardnessData()
0077     : MyPaintCurveOptionData("",
0078                              KoID("hardness", i18n("Hardness")),
0079                              false, true, 0.02, 1.0,
0080                              new deprecated_remove_after_krita6::SensorPackHardness())
0081 {
0082 }
0083 
0084 MyPaintOpacityData::MyPaintOpacityData()
0085     : MyPaintCurveOptionData("",
0086                              KoID("opaque", i18n("Opaque")),
0087                              false, true, 0.0, 2.0,
0088                              new deprecated_remove_after_krita6::SensorPackOpacity())
0089 {
0090 }