Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_standard_uniform_properties_factory.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
12#include "kis_image_config.h"
13
15
16
17
20 KisPaintOpPresetUpdateProxy *updateProxy)
21{
22 return createProperty(id.id(), settings, updateProxy);
23}
24
27 KisPaintOpPresetUpdateProxy *updateProxy)
28{
30
31
32 if (id == size.id()) {
34 new KisDoubleSliderBasedPaintOpPropertyCallback(KisDoubleSliderBasedPaintOpPropertyCallback::Double, KoID("size", i18n("Size")), settings, 0);
35
36 prop->setRange(0, KisImageConfig(true).maxBrushSize());
37 prop->setDecimals(2);
38 prop->setSingleStep(1);
39 prop->setExponentRatio(3.0);
40 prop->setSuffix(i18n(" px"));
41
42 prop->setReadCallback(
44 prop->setValue(prop->settings()->paintOpSize());
45 });
46 prop->setWriteCallback(
48 prop->settings()->setPaintOpSize(prop->value().toReal());
49 });
50
51 QObject::connect(updateProxy, SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
52 prop->requestReadValue();
53 result = toQShared(prop);
54 } else if (id == opacity.id()) {
56 new KisDoubleSliderBasedPaintOpPropertyCallback(KisDoubleSliderBasedPaintOpPropertyCallback::Double, opacity, settings, 0);
57
58 prop->setRange(0.0, 1.0);
59 prop->setSingleStep(0.01);
60
61 prop->setReadCallback(
63 prop->setValue(prop->settings()->paintOpOpacity());
64 });
65 prop->setWriteCallback(
67 prop->settings()->setPaintOpOpacity(prop->value().toReal());
68 });
69
70 QObject::connect(updateProxy, SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
71 prop->requestReadValue();
72 result = toQShared(prop);
73 } else if (id == flow.id()) {
75 new KisDoubleSliderBasedPaintOpPropertyCallback(KisDoubleSliderBasedPaintOpPropertyCallback::Double, flow, settings, 0);
76
77 prop->setRange(0.0, 1.0);
78 prop->setSingleStep(0.01);
79
80 prop->setReadCallback(
82 prop->setValue(prop->settings()->paintOpFlow());
83 });
84 prop->setWriteCallback(
86 prop->settings()->setPaintOpFlow(prop->value().toReal());
87 });
88
89 QObject::connect(updateProxy, SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
90 prop->requestReadValue();
91 result = toQShared(prop);
92 } else if (id == angle.id()) {
93 qFatal("Not implemented");
94 } else if (id == spacing.id()) {
95 qFatal("Not implemented");
96 }
97
98 if (!result) {
99 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "Unknown Uniform property id!");
100 }
101
102 return result;
103}
104}
The KisPaintOpPresetUpdateProxy class.
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
QSharedPointer< T > toQShared(T *ptr)
KisCallbackBasedPaintopProperty< KisSliderBasedPaintOpProperty< qreal > > KisDoubleSliderBasedPaintOpPropertyCallback
KisUniformPaintOpPropertySP createProperty(const KoID &id, KisPaintOpSettingsRestrictedSP settings, KisPaintOpPresetUpdateProxy *updateProxy)
static const KoID spacing("spacing", ki18n("Spacing"))
static const KoID angle("angle", ki18n("Angle"))
static const KoID size("size", ki18n("Size"))
static const KoID flow("flow", ki18n("Flow"))
static const KoID opacity("opacity", ki18n("Opacity"))