commit 067cc2f6e3054156c8e5b37ddd686ba3d3041880
parent 355a8a1b2a2c7f4af5fff0c3c7c243a53c26bdf7
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 5 Dec 2024 23:44:20 +0100
move file type menu creation to one place to allow to add more file types at one position
Diffstat:
4 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/source/jucePluginEditorLib/patchmanager/datasourcetreeitem.cpp b/source/jucePluginEditorLib/patchmanager/datasourcetreeitem.cpp
@@ -158,15 +158,7 @@ namespace jucePluginEditorLib::patchManager
beginEdit();
});
- auto fileTypeMenu = [this](const std::function<void(FileType)>& _func)
- {
- juce::PopupMenu menu;
- menu.addItem(".syx", [this, _func]{_func(FileType::Syx);});
- menu.addItem(".mid", [this, _func]{_func(FileType::Mid);});
- return menu;
- };
-
- menu.addSubMenu("Export...", fileTypeMenu([this](const FileType& _fileType)
+ menu.addSubMenu("Export...", getPatchManager().getEditor().createExportFileTypeMenu([this](const FileType& _fileType)
{
const auto s = getPatchManager().getSearch(getSearchHandle());
if(s)
diff --git a/source/jucePluginEditorLib/patchmanager/listmodel.cpp b/source/jucePluginEditorLib/patchmanager/listmodel.cpp
@@ -104,22 +104,16 @@ namespace jucePluginEditorLib::patchManager
if(!_mouseEvent.mods.isPopupMenu())
return false;
- auto fileTypeMenu = [this](const std::function<void(FileType)>& _func)
- {
- juce::PopupMenu menu;
- menu.addItem(".syx", [this, _func]{_func(FileType::Syx);});
- menu.addItem(".mid", [this, _func]{_func(FileType::Mid);});
- return menu;
- };
-
auto selectedPatches = getSelectedPatches();
const auto hasSelectedPatches = !selectedPatches.empty();
+ const auto& editor = getPatchManager().getEditor();
+
juce::PopupMenu menu;
if(hasSelectedPatches)
- menu.addSubMenu("Export selected...", fileTypeMenu([this](const FileType& _fileType) { exportPresets(true, _fileType); }));
- menu.addSubMenu("Export all...", fileTypeMenu([this](const FileType& _fileType) { exportPresets(false, _fileType); }));
+ menu.addSubMenu("Export selected...", editor.createExportFileTypeMenu([this](const FileType& _fileType) { exportPresets(true, _fileType); }));
+ menu.addSubMenu("Export all...", editor.createExportFileTypeMenu([this](const FileType& _fileType) { exportPresets(false, _fileType); }));
if(hasSelectedPatches)
{
diff --git a/source/jucePluginEditorLib/pluginEditor.cpp b/source/jucePluginEditorLib/pluginEditor.cpp
@@ -553,6 +553,14 @@ namespace jucePluginEditorLib
m_overlays.refreshAll();
}
+ juce::PopupMenu Editor::createExportFileTypeMenu(const std::function<void(FileType)>& _func) const
+ {
+ juce::PopupMenu menu;
+ menu.addItem(".syx", [this, _func]{_func(FileType::Syx);});
+ menu.addItem(".mid", [this, _func]{_func(FileType::Mid);});
+ return menu;
+ }
+
bool Editor::keyPressed(const juce::KeyPress& _key)
{
if(_key.getModifiers().isCommandDown())
diff --git a/source/jucePluginEditorLib/pluginEditor.h b/source/jucePluginEditorLib/pluginEditor.h
@@ -97,6 +97,8 @@ namespace jucePluginEditorLib
void parentHierarchyChanged() override;
+ juce::PopupMenu createExportFileTypeMenu(const std::function<void(FileType)>& _func) const;
+
protected:
bool keyPressed(const juce::KeyPress& _key) override;