savepatchdesc.h (1641B)
1 #pragma once 2 3 #include "jucePluginEditorLib/dragAndDropObject.h" 4 5 #include "jucePluginLib/patchdb/patchdbtypes.h" 6 7 #include "juce_core/juce_core.h" 8 #include "juce_gui_basics/juce_gui_basics.h" 9 10 namespace jucePluginEditorLib::patchManager 11 { 12 class PatchManager; 13 14 class SavePatchDesc : public jucePluginEditorLib::DragAndDropObject 15 { 16 static constexpr int InvalidPart = -1; 17 18 public: 19 SavePatchDesc(PatchManager& _pm, int _part, std::string _name = {}); 20 21 SavePatchDesc(PatchManager& _pm, std::map<uint32_t, pluginLib::patchDB::PatchPtr>&& _patches, std::string _name = {}); 22 23 auto getPart() const { return m_part; } 24 25 std::map<uint32_t, pluginLib::patchDB::PatchPtr>& getPatches() const; 26 27 bool isPartValid() const { return m_part != InvalidPart; } 28 bool hasPatches() const { return !getPatches().empty(); } 29 30 bool writePatchesToFile(const juce::File& _file) const; 31 32 const std::string& getName() const { return m_name; } 33 34 std::string getExportFileName(const pluginLib::Processor& _processor) const override; 35 bool canDropExternally() const override { return hasPatches(); } 36 bool writeToFile(const juce::File& _file) const override; 37 38 static const SavePatchDesc* fromDragSource(const juce::DragAndDropTarget::SourceDetails& _source) 39 { 40 return dynamic_cast<const SavePatchDesc*>(_source.description.getObject()); 41 } 42 43 static std::vector<pluginLib::patchDB::PatchPtr> getPatchesFromDragSource(const juce::DragAndDropTarget::SourceDetails& _dragSourceDetails); 44 45 private: 46 PatchManager& m_patchManager; 47 int m_part; 48 mutable std::map<uint32_t, pluginLib::patchDB::PatchPtr> m_patches; 49 const std::string m_name; 50 }; 51 }