Changeset View
Changeset View
Standalone View
Standalone View
libs/image/brushengine/kis_callback_based_paintop_property.h
Context not available. | |||||
21 | 21 | | |||
---|---|---|---|---|---|
22 | #include <functional> | 22 | #include <functional> | ||
23 | 23 | | |||
24 | | ||||
25 | template <class ParentClass> | 24 | template <class ParentClass> | ||
26 | class KisCallbackBasedPaintopProperty : public ParentClass | 25 | class KRITAIMAGE_EXPORT KisCallbackBasedPaintopProperty : public ParentClass | ||
27 | { | 26 | { | ||
28 | public: | 27 | public: | ||
29 | KisCallbackBasedPaintopProperty(typename ParentClass::Type type, | 28 | KisCallbackBasedPaintopProperty(typename ParentClass::Type type, | ||
30 | const QString &id, | 29 | const QString &id, | ||
31 | const QString &name, | 30 | const QString &name, | ||
32 | KisPaintOpSettingsRestrictedSP settings, | 31 | KisPaintOpSettingsRestrictedSP settings, | ||
33 | QObject *parent) | 32 | QObject *parent); | ||
34 | : ParentClass(type, id, name, settings, parent) {} | | |||
35 | 33 | | |||
36 | KisCallbackBasedPaintopProperty(const QString &id, | 34 | KisCallbackBasedPaintopProperty(const QString &id, | ||
37 | const QString &name, | 35 | const QString &name, | ||
38 | KisPaintOpSettingsRestrictedSP settings, | 36 | KisPaintOpSettingsRestrictedSP settings, | ||
39 | QObject *parent) | 37 | QObject *parent); | ||
40 | : ParentClass(id, name, settings, parent) {} | | |||
41 | 38 | | |||
42 | typedef std::function<void (KisUniformPaintOpProperty*)> Callback; | 39 | typedef std::function<void (KisUniformPaintOpProperty*)> Callback; | ||
43 | typedef std::function<bool (const KisUniformPaintOpProperty*)> VisibleCallback; | 40 | typedef std::function<bool (const KisUniformPaintOpProperty*)> VisibleCallback; | ||
44 | 41 | | |||
45 | void setReadCallback(Callback func) { m_readFunc = func; } | 42 | void setReadCallback(Callback func); | ||
46 | void setWriteCallback(Callback func) { m_writeFunc = func; } | 43 | void setWriteCallback(Callback func); | ||
47 | void setIsVisibleCallback(VisibleCallback func) { m_visibleFunc = func; } | 44 | void setIsVisibleCallback(VisibleCallback func); | ||
48 | 45 | | |||
49 | protected: | 46 | protected: | ||
50 | void readValueImpl() override { if (m_readFunc) m_readFunc(this); } | 47 | void readValueImpl() override; | ||
51 | void writeValueImpl() override { if (m_writeFunc) m_writeFunc(this); } | 48 | void writeValueImpl() override; | ||
52 | bool isVisible() const override { return m_visibleFunc ? m_visibleFunc(this) : true; } | 49 | bool isVisible() const override; | ||
53 | 50 | | |||
54 | private: | 51 | private: | ||
55 | Callback m_readFunc; | 52 | Callback m_readFunc; | ||
Context not available. |