kis_paintop_registry.h 3.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  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 20 21
 */

#ifndef KIS_PAINTOP_REGISTRY_H_
#define KIS_PAINTOP_REGISTRY_H_

22
#include <QObject>
23

24 25
#include "KoGenericRegistry.h"

Adrian Page's avatar
Adrian Page committed
26
#include "kis_paintop.h"
Boudewijn Rempt's avatar
Boudewijn Rempt committed
27
#include "kis_paintop_factory.h"
28
#include "kis_types.h"
29 30
#include "kis_paintop_settings.h"
#include "kis_paintop_preset.h"
Dmitry Kazakov's avatar
Dmitry Kazakov committed
31
#include <kis_threaded_text_rendering_workaround.h>
32

33
#include <krita_export.h>
34

35 36
class QWidget;

37
class KisPaintOp;
38
class KisPainter;
39
class KoColorSpace;
40
class KoInputDevice;
41

Boudewijn Rempt's avatar
Boudewijn Rempt committed
42 43 44
/**
 * Manages the loading and creating of all paintop plugins.
 */
45
class KRITAIMAGE_EXPORT KisPaintOpRegistry : public QObject, public KoGenericRegistry<KisPaintOpFactory*>
46 47 48
{

    Q_OBJECT
49 50

public:
51
    virtual ~KisPaintOpRegistry();
52

Dmitry Kazakov's avatar
Dmitry Kazakov committed
53 54 55 56
#ifdef HAVE_THREADED_TEXT_RENDERING_WORKAROUND
    void preinitializePaintOpIfNeeded(const KisPaintOpPresetSP preset);
#endif /* HAVE_THREADED_TEXT_RENDERING_WORKAROUND */

57 58 59 60
    /**
     * Create and return a paintop based on the given preset. A preset defines
     * a paintop, a settings object and possible a brush tip.
     */
61
    KisPaintOp* paintOp(const KisPaintOpPresetSP preset, KisPainter * painter, KisNodeSP node, KisImageSP image) const;
62

63
    /**
64
     * Create and return an (abstracted) configuration widget
65
     * for using the specified paintop with the specified input device,
66 67
     * with the specified parent as widget parent. Returns 0 if there
     * are no settings available for the given device.
68
     */
Boudewijn Rempt's avatar
Boudewijn Rempt committed
69
    KisPaintOpSettingsSP settings(const KoID& id) const;
70

71 72 73
    /**
     * @return a default preset for the given paintop.
     */
Boudewijn Rempt's avatar
Boudewijn Rempt committed
74
    KisPaintOpPresetSP defaultPreset(const KoID& id) const;
75

76
    // Get the name of the icon to show in the toolchest
77
    QString pixmap(const KoID & id) const;
78

79 80 81 82 83 84
    /**
     * This function return a list of all the keys in KoID format by using the name() method
     * on the objects stored in the registry.
     */
    QList<KoID> listKeys() const;

85
public:
Boudewijn Rempt's avatar
Boudewijn Rempt committed
86

87
    static KisPaintOpRegistry* instance();
88

89
private:
Boudewijn Rempt's avatar
Boudewijn Rempt committed
90

91 92 93
    KisPaintOpRegistry();
    KisPaintOpRegistry(const KisPaintOpRegistry&);
    KisPaintOpRegistry operator=(const KisPaintOpRegistry&);
94

95 96 97 98

    // So the settings can get a paintop to render their sample image
    friend class KisPaintOpSettings;

Boudewijn Rempt's avatar
Boudewijn Rempt committed
99 100 101
    /**
     * Return a newly created paintop. You are responsible for deleting
     */
102
    KisPaintOp * paintOp(const QString& id, const KisPaintOpSettingsSP settings, KisPainter * painter, KisNodeSP node, KisImageSP image) const;
Boudewijn Rempt's avatar
Boudewijn Rempt committed
103

104 105 106 107
};

#endif // KIS_PAINTOP_REGISTRY_H_