Changeset View
Changeset View
Standalone View
Standalone View
libs/image/brushengine/kis_callback_based_paintop_property_impl.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2016 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_CALLBACK_BASED_PAINTOP_PROPERTY_IMPL_H | ||||
20 | #define __KIS_CALLBACK_BASED_PAINTOP_PROPERTY_IMPL_H | ||||
21 | | ||||
22 | #include <functional> | ||||
23 | | ||||
24 | template <class ParentClass> | ||||
25 | KisCallbackBasedPaintopProperty<ParentClass>::KisCallbackBasedPaintopProperty(typename ParentClass::Type type, | ||||
26 | const QString &id, | ||||
27 | const QString &name, | ||||
28 | KisPaintOpSettingsRestrictedSP settings, | ||||
29 | QObject *parent) | ||||
30 | : ParentClass(type, id, name, settings, parent) | ||||
31 | { | ||||
32 | } | ||||
33 | | ||||
34 | template <class ParentClass> | ||||
35 | KisCallbackBasedPaintopProperty<ParentClass>::KisCallbackBasedPaintopProperty(const QString &id, | ||||
36 | const QString &name, | ||||
37 | KisPaintOpSettingsRestrictedSP settings, | ||||
38 | QObject *parent) | ||||
39 | : ParentClass(id, name, settings, parent) | ||||
40 | { | ||||
41 | } | ||||
42 | | ||||
43 | template <class ParentClass> | ||||
44 | void KisCallbackBasedPaintopProperty<ParentClass>::setReadCallback(Callback func) | ||||
45 | { | ||||
46 | m_readFunc = func; | ||||
47 | } | ||||
48 | | ||||
49 | template <class ParentClass> | ||||
50 | void KisCallbackBasedPaintopProperty<ParentClass>::setWriteCallback(Callback func) | ||||
51 | { | ||||
52 | m_writeFunc = func; | ||||
53 | } | ||||
54 | | ||||
55 | template <class ParentClass> | ||||
56 | void KisCallbackBasedPaintopProperty<ParentClass>::setIsVisibleCallback(VisibleCallback func) | ||||
57 | { | ||||
58 | m_visibleFunc = func; | ||||
59 | } | ||||
60 | | ||||
61 | template <class ParentClass> | ||||
62 | void KisCallbackBasedPaintopProperty<ParentClass>::readValueImpl() | ||||
63 | { | ||||
64 | if (m_readFunc) m_readFunc(this); | ||||
65 | } | ||||
66 | | ||||
67 | template <class ParentClass> | ||||
68 | void KisCallbackBasedPaintopProperty<ParentClass>::writeValueImpl() | ||||
69 | { | ||||
70 | if (m_writeFunc) m_writeFunc(this); | ||||
71 | } | ||||
72 | | ||||
73 | template <class ParentClass> | ||||
74 | bool KisCallbackBasedPaintopProperty<ParentClass>::isVisible() const | ||||
75 | { | ||||
76 | return m_visibleFunc ? m_visibleFunc(this) : true; | ||||
77 | } | ||||
78 | | ||||
79 | #endif /* __KIS_CALLBACK_BASED_PAINTOP_PROPERTY_IMPL_H */ |