1 /*
2  *  Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __KIS_ASL_CALLBACK_OBJECT_CATCHER_H
20 #define __KIS_ASL_CALLBACK_OBJECT_CATCHER_H
21 
22 #include "kis_asl_object_catcher.h"
23 
24 #include <boost/function.hpp>
25 #include <QScopedPointer>
26 
27 #include <resources/KoAbstractGradient.h>
28 
29 #include "kritapsd_export.h"
30 
31 class KoPattern;
32 
33 typedef boost::function<void (double)> ASLCallbackDouble;
34 typedef boost::function<void (int)> ASLCallbackInteger;
35 typedef boost::function<void (const QString &)> ASLCallbackString;
36 typedef boost::function<void (bool)> ASLCallbackBoolean;
37 typedef boost::function<void (const QColor &)> ASLCallbackColor;
38 typedef boost::function<void (const QPointF &)> ASLCallbackPoint;
39 typedef boost::function<void (const QString &, const QVector<QPointF> &)> ASLCallbackCurve;
40 typedef boost::function<void (const KoPattern *)> ASLCallbackPattern;
41 typedef boost::function<void (const QString &, const QString &)> ASLCallbackPatternRef;
42 typedef boost::function<void (KoAbstractGradientSP)> ASLCallbackGradient;
43 typedef boost::function<void ()> ASLCallbackNewStyle;
44 
45 
46 class KRITAPSD_EXPORT KisAslCallbackObjectCatcher : public KisAslObjectCatcher
47 {
48 public:
49     KisAslCallbackObjectCatcher();
50     ~KisAslCallbackObjectCatcher() override;
51 
52     void addDouble(const QString &path, double value) override;
53     void addInteger(const QString &path, int value) override;
54     void addEnum(const QString &path, const QString &typeId, const QString &value) override;
55     void addUnitFloat(const QString &path, const QString &unit, double value) override;
56     void addText(const QString &path, const QString &value) override;
57     void addBoolean(const QString &path, bool value) override;
58     void addColor(const QString &path, const QColor &value) override;
59     void addPoint(const QString &path, const QPointF &value) override;
60     void addCurve(const QString &path, const QString &name, const QVector<QPointF> &points) override;
61     void addPattern(const QString &path, const KoPattern *pattern) override;
62     void addPatternRef(const QString &path, const QString &patternUuid, const QString &patternName) override;
63     void addGradient(const QString &path, KoAbstractGradientSP gradient) override;
64     void newStyleStarted() override;
65 
66     void subscribeDouble(const QString &path, ASLCallbackDouble callback);
67     void subscribeInteger(const QString &path, ASLCallbackInteger callback);
68     void subscribeEnum(const QString &path, const QString &typeId, ASLCallbackString callback);
69     void subscribeUnitFloat(const QString &path, const QString &unit, ASLCallbackDouble callback);
70     void subscribeText(const QString &path, ASLCallbackString callback);
71     void subscribeBoolean(const QString &path, ASLCallbackBoolean callback);
72     void subscribeColor(const QString &path, ASLCallbackColor callback);
73     void subscribePoint(const QString &path, ASLCallbackPoint callback);
74     void subscribeCurve(const QString &path, ASLCallbackCurve callback);
75     void subscribePattern(const QString &path, ASLCallbackPattern callback);
76     void subscribePatternRef(const QString &path, ASLCallbackPatternRef callback);
77     void subscribeGradient(const QString &path, ASLCallbackGradient callback);
78     void subscribeNewStyleStarted(ASLCallbackNewStyle callback);
79 
80 private:
81     struct Private;
82     const QScopedPointer<Private> m_d;
83 };
84 
85 #endif /* __KIS_ASL_CALLBACK_OBJECT_CATCHER_H */
86