File indexing completed on 2025-03-09 04:04:38
0001 /* 0002 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_PAINTOP_REGISTRY_H_ 0008 #define KIS_PAINTOP_REGISTRY_H_ 0009 0010 #include <QObject> 0011 0012 #include "KoGenericRegistry.h" 0013 0014 #include "kis_paintop.h" 0015 #include <brushengine/kis_paintop_factory.h> 0016 #include "kis_types.h" 0017 #include <brushengine/kis_paintop_settings.h> 0018 #include <brushengine/kis_paintop_preset.h> 0019 #include <kis_threaded_text_rendering_workaround.h> 0020 0021 #include <kritaimage_export.h> 0022 0023 0024 class KisPaintOp; 0025 class KisPainter; 0026 0027 /** 0028 * Manages the loading and creating of all paintop plugins. 0029 */ 0030 class KRITAIMAGE_EXPORT KisPaintOpRegistry : public QObject, public KoGenericRegistry<KisPaintOpFactory*> 0031 { 0032 0033 Q_OBJECT 0034 0035 public: 0036 KisPaintOpRegistry(); 0037 ~KisPaintOpRegistry() override; 0038 0039 #ifdef HAVE_THREADED_TEXT_RENDERING_WORKAROUND 0040 void preinitializePaintOpIfNeeded(const KisPaintOpPresetSP preset); 0041 #endif /* HAVE_THREADED_TEXT_RENDERING_WORKAROUND */ 0042 0043 /** 0044 * Create and return a paintop based on the given preset. A preset defines 0045 * a paintop, a settings object and possible a brush tip. 0046 */ 0047 KisPaintOp* paintOp(const KisPaintOpPresetSP preset, KisPainter * painter, KisNodeSP node, KisImageSP image) const; 0048 0049 KisInterstrokeDataFactory* createInterstrokeDataFactory(KisPaintOpPresetSP preset) const; 0050 0051 /** 0052 * Create and return an (abstracted) configuration widget 0053 * for using the specified paintop with the specified input device, 0054 * with the specified parent as widget parent. Returns 0 if there 0055 * are no settings available for the given device. 0056 */ 0057 KisPaintOpSettingsSP createSettings(const KoID& id, KisResourcesInterfaceSP resourcesInterface) const; 0058 0059 /** 0060 * @return a default preset for the given paintop. 0061 */ 0062 KisPaintOpPresetSP defaultPreset(const KoID& id, KisResourcesInterfaceSP resourcesInterface) const; 0063 0064 // Get the icon to show in the user interface 0065 QIcon icon(const KoID & id) const; 0066 0067 /** 0068 * This function return a list of all the keys in KoID format by using the name() method 0069 * on the objects stored in the registry. 0070 */ 0071 QList<KoID> listKeys() const; 0072 0073 public: 0074 0075 static KisPaintOpRegistry* instance(); 0076 0077 private: 0078 0079 KisPaintOpRegistry(const KisPaintOpRegistry&); 0080 KisPaintOpRegistry operator=(const KisPaintOpRegistry&); 0081 void initRegistry(); 0082 0083 0084 // So the settings can get a paintop to render their sample image 0085 friend class KisPaintOpSettings; 0086 0087 /** 0088 * Return a newly created paintop. You are responsible for deleting 0089 */ 0090 KisPaintOp * paintOp(const QString& id, const KisPaintOpSettingsSP settings, KisPainter * painter, KisNodeSP node, KisImageSP image) const; 0091 0092 }; 0093 0094 #endif // KIS_PAINTOP_REGISTRY_H_ 0095