21#include <JuceHeader.h>
23#include "../MemaProcessor/MemaPluginParameterInfo.h"
25#include <FixedFontTextEditor.h>
42 return m_list.getNumTypes() +
m_list.getBlacklistedFiles().size();
47 const auto defaultColour =
m_owner.findColour(ListBox::backgroundColourId);
48 const auto c = rowIsSelected ? defaultColour.interpolatedWith(
m_owner.findColour(ListBox::textColourId), 0.5f)
63 void paintCell(juce::Graphics& g,
int row,
int columnId,
int width,
int height,
bool )
override
66 bool isBlacklisted = row >=
m_list.getNumTypes();
71 text =
m_list.getBlacklistedFiles()[row -
m_list.getNumTypes()];
73 text = TRANS(
"Deactivated after failing to initialise correctly");
77 auto desc =
m_list.getTypes()[row];
81 case nameCol: text = desc.name;
break;
82 case typeCol: text = desc.pluginFormatName;
break;
83 case categoryCol: text = desc.category.isNotEmpty() ? desc.category :
"-";
break;
87 default: jassertfalse;
break;
91 if (text.isNotEmpty())
93 const auto defaultTextColour =
m_owner.findColour(ListBox::textColourId);
94 g.setColour(isBlacklisted ? Colours::red
95 : columnId ==
nameCol ? defaultTextColour
96 : defaultTextColour.interpolatedWith(Colours::transparentBlack, 0.3f));
97 g.setFont(
m_owner.withDefaultMetrics(juce::FontOptions((
float)height * 0.7f, Font::bold)));
98 g.drawFittedText(text, 4, 0, width - 6, height, juce::Justification::centredLeft, 1, 0.9f);
102 void cellClicked(
int rowNumber,
int columnId,
const juce::MouseEvent& e)
override
104 juce::TableListBoxModel::cellClicked(rowNumber, columnId, e);
106 if (rowNumber >= 0 && rowNumber <
getNumRows() && e.mods.isPopupMenu())
107 m_owner.createMenuForRow(rowNumber).showMenuAsync(juce::PopupMenu::Options().withDeletionCheck(
m_owner));
112 m_owner.removeSelectedPlugins();
117 switch (newSortColumnId)
119 case nameCol:
m_list.sort(juce::KnownPluginList::sortAlphabetically, isForwards);
break;
120 case typeCol:
m_list.sort(juce::KnownPluginList::sortByFormat, isForwards);
break;
121 case categoryCol:
m_list.sort(juce::KnownPluginList::sortByCategory, isForwards);
break;
125 default: jassertfalse;
break;
133 juce::TableListBoxModel::selectedRowsChanged(lastRowSelected);
141 juce::StringArray items;
143 if (desc.descriptiveName != desc.name)
144 items.add(desc.descriptiveName);
146 items.add(desc.version);
148 items.removeEmptyStrings();
149 return items.joinIntoString(
" - ");
156 auto currentPluginDescriptionListContents =
m_list.getTypes();
185 g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId));
189 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
Spacing)
198 addDefaultFormatsToManager(m_formatManager);
199 juce::File deadMansPedalFile;
200 m_pluginListComponent = std::make_unique<juce::PluginListComponent>(m_formatManager, m_pluginList, deadMansPedalFile,
nullptr);
201 m_pluginListComponent->getTableListBox().setMultipleSelectionEnabled(
false);
202 auto customTableModel = std::make_unique<CustomPluginListComponentTableModel>(*m_pluginListComponent, m_pluginList);
203 customTableModel->onSelectionChanged = [=](
int lastRowSelected) {
205 m_selectButton->setEnabled(-1 != lastRowSelected);
207 m_pluginListComponent->setTableModel(
dynamic_cast<juce::TableListBoxModel*
>(customTableModel.release()));
208 addAndMakeVisible(m_pluginListComponent.get());
210 m_selectButton = std::make_unique<juce::TextButton>(
"Select",
"Accept the current plugin selection as new type to instantiate and close.");
211 m_selectButton->onClick = [=]() {
212 if (m_pluginListComponent)
220 m_selectButton->setEnabled(
false);
221 addAndMakeVisible(m_selectButton.get());
223 m_cancelButton = std::make_unique<juce::TextButton>(
"Cancel",
"Discard the current plugin selection and close.");
224 m_cancelButton->onClick = [=]() {
227 addAndMakeVisible(m_cancelButton.get());
237 g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId));
241 auto bounds = getLocalBounds();
242 m_pluginListComponent->setBounds(bounds);
244 bounds = bounds.removeFromBottom(28);
245 m_cancelButton->setBounds(bounds.removeFromRight(80).reduced(2));
246 m_selectButton->setBounds(bounds.removeFromRight(80).reduced(2));
254 juce::AudioPluginFormatManager m_formatManager;
255 juce::KnownPluginList m_pluginList;
257 std::unique_ptr<juce::PluginListComponent> m_pluginListComponent;
258 std::unique_ptr<juce::TextButton> m_selectButton;
259 std::unique_ptr<juce::TextButton> m_cancelButton;
267 public juce::DragAndDropTarget
276 void paint(juce::Graphics& g)
override;
277 void mouseDown(
const juce::MouseEvent& e)
override;
278 void mouseDrag(
const juce::MouseEvent& e)
override;
279 void mouseUp(
const juce::MouseEvent& e)
override;
284 void itemDragMove(
const SourceDetails& details)
override;
285 void itemDragExit(
const SourceDetails& details)
override;
286 void itemDropped(
const SourceDetails& details)
override;
291 std::unique_ptr<JUCEAppBasics::FixedFontTextEditor>
stepsEdit;
296 std::function<void(
int fromParamIndex,
int toParamIndex,
bool insertBefore)>
onRowDropped;
299 bool m_mouseDownInGrip =
false;
300 bool m_showInsertionLine =
false;
301 bool m_insertionLineAtTop =
true;
308 public juce::DragAndDropContainer
314 void addRow(std::unique_ptr<ParameterRowComponent> row);
318 void reorderRow(
int fromParamIndex,
int toParamIndex,
bool insertBefore);
321 std::vector<std::unique_ptr<ParameterRowComponent>> m_rows;
358 std::unique_ptr<juce::DrawableButton> m_enableButton;
359 std::unique_ptr<Spacing> m_spacing1;
360 std::unique_ptr<juce::TextButton> m_postButton;
361 std::unique_ptr<Spacing> m_spacing2;
362 std::unique_ptr<juce::TextButton> m_showEditorButton;
363 std::unique_ptr<juce::DrawableButton> m_triggerSelectButton;
364 std::unique_ptr<Spacing> m_spacing3;
365 std::unique_ptr<juce::DrawableButton> m_parameterConfigButton;
366 std::unique_ptr<Spacing> m_spacing4;
367 std::unique_ptr<juce::DrawableButton> m_clearButton;
369 std::unique_ptr<PluginListAndSelectComponent> m_pluginSelectionComponent;
370 juce::PluginDescription m_selectedPluginDescription;
372 std::map<int, Mema::PluginParameterInfo> m_parameterInfos;
373 std::vector<int> m_parameterDisplayOrder;
375 std::unique_ptr<ParameterListComponent> m_messageBoxParameterListComponent;
376 std::unique_ptr<juce::Viewport> m_messageBoxParameterTogglesViewport;
377 std::unique_ptr<juce::AlertWindow> m_messageBox;
juce::PluginListComponent & m_owner
std::function< void(int)> onSelectionChanged
void deleteKeyPressed(int) override
CustomPluginListComponentTableModel(juce::PluginListComponent &c, juce::KnownPluginList &l)
void cellClicked(int rowNumber, int columnId, const juce::MouseEvent &e) override
void paintCell(juce::Graphics &g, int row, int columnId, int width, int height, bool) override
int getNumRows() override
static juce::String getPluginDescription(const juce::PluginDescription &desc)
void sortOrderChanged(int newSortColumnId, bool isForwards) override
void selectedRowsChanged(int lastRowSelected) override
juce::KnownPluginList & m_list
void paintRowBackground(juce::Graphics &g, int, int, int, bool rowIsSelected) override
juce::PluginDescription getPluginDescriptionOfSelectedRow()
ParameterRowComponent * getRowForParamIndex(int paramIdx)
std::vector< int > getDisplayOrder() const
void addRow(std::unique_ptr< ParameterRowComponent > row)
~ParameterListComponent() override=default
ParameterListComponent()=default
void reorderRow(int fromParamIndex, int toParamIndex, bool insertBefore)
static constexpr int gripWidth
std::function< void(int fromParamIndex, int toParamIndex, bool insertBefore)> onRowDropped
std::unique_ptr< JUCEAppBasics::FixedFontTextEditor > stepsEdit
void itemDragMove(const SourceDetails &details) override
void itemDropped(const SourceDetails &details) override
std::unique_ptr< juce::ComboBox > typeCombo
void paint(juce::Graphics &g) override
bool isInterestedInDragSource(const SourceDetails &details) override
void itemDragEnter(const SourceDetails &details) override
void mouseDown(const juce::MouseEvent &e) override
void mouseDrag(const juce::MouseEvent &e) override
~ParameterRowComponent() override=default
void itemDragExit(const SourceDetails &details) override
void mouseUp(const juce::MouseEvent &e) override
std::unique_ptr< juce::ToggleButton > toggleButton
std::function< void()> onClearPlugin
void setParameterInfos(const std::vector< PluginParameterInfo > &infos)
void lookAndFeelChanged() override
void setSelectedPlugin(const juce::PluginDescription &pluginDescription)
void showParameterConfig()
std::function< void()> onShowPluginEditor
std::function< void(bool)> onPluginPrePostChange
void setPluginEnabled(bool enabled=true)
std::function< void()> onPluginParametersStatusChanged
const std::map< int, Mema::PluginParameterInfo > & getParameterInfos()
void setPluginPrePost(bool post=false)
std::function< void(bool)> onPluginEnabledChange
~PluginControlComponent()
std::function< void(const juce::PluginDescription &)> onPluginSelected
void setParameterDisplayOrder(const std::vector< int > &order)
void showPluginsList(juce::Point< int > showPosition)
void paint(Graphics &) override
const std::vector< int > & getParameterDisplayOrder()
~PluginListAndSelectComponent()=default
std::function< void(const juce::PluginDescription &)> onPluginSelected
PluginListAndSelectComponent()
void paint(Graphics &g) override
void paint(Graphics &g) override
Metadata describing a single plugin parameter exposed for remote control.