Sprint 2: Update PluginBridgeEditor.cpp \u2014 Load Plugin button + status display
Browse files- Source/PluginBridgeEditor.cpp +63 -11
Source/PluginBridgeEditor.cpp
CHANGED
|
@@ -3,25 +3,39 @@
|
|
| 3 |
PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p)
|
| 4 |
: AudioProcessorEditor(&p), processorRef(p)
|
| 5 |
{
|
| 6 |
-
setSize(
|
| 7 |
|
|
|
|
| 8 |
titleLabel.setText("PluginBridge", juce::dontSendNotification);
|
| 9 |
titleLabel.setFont(juce::FontOptions(20.0f));
|
| 10 |
titleLabel.setJustificationType(juce::Justification::centred);
|
| 11 |
addAndMakeVisible(titleLabel);
|
| 12 |
|
|
|
|
| 13 |
statusLabel.setText("MCP: starting...", juce::dontSendNotification);
|
| 14 |
-
statusLabel.setFont(juce::FontOptions(
|
| 15 |
statusLabel.setJustificationType(juce::Justification::centred);
|
| 16 |
addAndMakeVisible(statusLabel);
|
| 17 |
|
|
|
|
| 18 |
portLabel.setText("", juce::dontSendNotification);
|
| 19 |
-
portLabel.setFont(juce::FontOptions(
|
| 20 |
portLabel.setJustificationType(juce::Justification::centred);
|
| 21 |
portLabel.setColour(juce::Label::textColourId, juce::Colours::grey);
|
| 22 |
addAndMakeVisible(portLabel);
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
PluginBridgeEditor::~PluginBridgeEditor()
|
|
@@ -36,23 +50,61 @@ void PluginBridgeEditor::paint(juce::Graphics& g)
|
|
| 36 |
|
| 37 |
void PluginBridgeEditor::resized()
|
| 38 |
{
|
| 39 |
-
auto area = getLocalBounds().reduced(
|
| 40 |
-
titleLabel.setBounds(area.removeFromTop(
|
| 41 |
-
area.removeFromTop(
|
| 42 |
-
statusLabel.setBounds(area.removeFromTop(
|
| 43 |
-
portLabel.setBounds(area.removeFromTop(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
void PluginBridgeEditor::timerCallback()
|
| 47 |
{
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
statusLabel.setText("MCP: running", juce::dontSendNotification);
|
| 50 |
statusLabel.setColour(juce::Label::textColourId, juce::Colours::limegreen);
|
| 51 |
portLabel.setText("http://127.0.0.1:" + juce::String(processorRef.getMcpServerPort()) + "/mcp",
|
| 52 |
juce::dontSendNotification);
|
| 53 |
-
}
|
|
|
|
|
|
|
| 54 |
statusLabel.setText("MCP: offline", juce::dontSendNotification);
|
| 55 |
statusLabel.setColour(juce::Label::textColourId, juce::Colours::red);
|
| 56 |
portLabel.setText("", juce::dontSendNotification);
|
| 57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
|
|
|
| 3 |
PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p)
|
| 4 |
: AudioProcessorEditor(&p), processorRef(p)
|
| 5 |
{
|
| 6 |
+
setSize(320, 200);
|
| 7 |
|
| 8 |
+
// Title
|
| 9 |
titleLabel.setText("PluginBridge", juce::dontSendNotification);
|
| 10 |
titleLabel.setFont(juce::FontOptions(20.0f));
|
| 11 |
titleLabel.setJustificationType(juce::Justification::centred);
|
| 12 |
addAndMakeVisible(titleLabel);
|
| 13 |
|
| 14 |
+
// MCP status
|
| 15 |
statusLabel.setText("MCP: starting...", juce::dontSendNotification);
|
| 16 |
+
statusLabel.setFont(juce::FontOptions(13.0f));
|
| 17 |
statusLabel.setJustificationType(juce::Justification::centred);
|
| 18 |
addAndMakeVisible(statusLabel);
|
| 19 |
|
| 20 |
+
// Port
|
| 21 |
portLabel.setText("", juce::dontSendNotification);
|
| 22 |
+
portLabel.setFont(juce::FontOptions(11.0f));
|
| 23 |
portLabel.setJustificationType(juce::Justification::centred);
|
| 24 |
portLabel.setColour(juce::Label::textColourId, juce::Colours::grey);
|
| 25 |
addAndMakeVisible(portLabel);
|
| 26 |
|
| 27 |
+
// Hosted plugin name
|
| 28 |
+
pluginLabel.setText("No plugin loaded", juce::dontSendNotification);
|
| 29 |
+
pluginLabel.setFont(juce::FontOptions(13.0f));
|
| 30 |
+
pluginLabel.setJustificationType(juce::Justification::centred);
|
| 31 |
+
pluginLabel.setColour(juce::Label::textColourId, juce::Colours::lightyellow);
|
| 32 |
+
addAndMakeVisible(pluginLabel);
|
| 33 |
+
|
| 34 |
+
// Load button
|
| 35 |
+
loadButton.onClick = [this]() { loadPluginClicked(); };
|
| 36 |
+
addAndMakeVisible(loadButton);
|
| 37 |
+
|
| 38 |
+
startTimerHz(2);
|
| 39 |
}
|
| 40 |
|
| 41 |
PluginBridgeEditor::~PluginBridgeEditor()
|
|
|
|
| 50 |
|
| 51 |
void PluginBridgeEditor::resized()
|
| 52 |
{
|
| 53 |
+
auto area = getLocalBounds().reduced(12);
|
| 54 |
+
titleLabel.setBounds(area.removeFromTop(32));
|
| 55 |
+
area.removeFromTop(6);
|
| 56 |
+
statusLabel.setBounds(area.removeFromTop(22));
|
| 57 |
+
portLabel.setBounds(area.removeFromTop(18));
|
| 58 |
+
area.removeFromTop(8);
|
| 59 |
+
pluginLabel.setBounds(area.removeFromTop(22));
|
| 60 |
+
area.removeFromTop(8);
|
| 61 |
+
loadButton.setBounds(area.removeFromTop(28).reduced(60, 0));
|
| 62 |
}
|
| 63 |
|
| 64 |
void PluginBridgeEditor::timerCallback()
|
| 65 |
{
|
| 66 |
+
// MCP status
|
| 67 |
+
if (processorRef.isMcpServerRunning())
|
| 68 |
+
{
|
| 69 |
statusLabel.setText("MCP: running", juce::dontSendNotification);
|
| 70 |
statusLabel.setColour(juce::Label::textColourId, juce::Colours::limegreen);
|
| 71 |
portLabel.setText("http://127.0.0.1:" + juce::String(processorRef.getMcpServerPort()) + "/mcp",
|
| 72 |
juce::dontSendNotification);
|
| 73 |
+
}
|
| 74 |
+
else
|
| 75 |
+
{
|
| 76 |
statusLabel.setText("MCP: offline", juce::dontSendNotification);
|
| 77 |
statusLabel.setColour(juce::Label::textColourId, juce::Colours::red);
|
| 78 |
portLabel.setText("", juce::dontSendNotification);
|
| 79 |
}
|
| 80 |
+
|
| 81 |
+
// Plugin status
|
| 82 |
+
auto& mgr = processorRef.getHostedPluginManager();
|
| 83 |
+
if (mgr.isLoaded())
|
| 84 |
+
{
|
| 85 |
+
pluginLabel.setText(mgr.getPluginName() + " (" + juce::String(mgr.getParameterCount()) + " params)",
|
| 86 |
+
juce::dontSendNotification);
|
| 87 |
+
pluginLabel.setColour(juce::Label::textColourId, juce::Colours::lightyellow);
|
| 88 |
+
}
|
| 89 |
+
else
|
| 90 |
+
{
|
| 91 |
+
pluginLabel.setText("No plugin loaded", juce::dontSendNotification);
|
| 92 |
+
pluginLabel.setColour(juce::Label::textColourId, juce::Colours::grey);
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
void PluginBridgeEditor::loadPluginClicked()
|
| 97 |
+
{
|
| 98 |
+
auto chooser = std::make_shared<juce::FileChooser>(
|
| 99 |
+
"Select VST3 or AU plugin",
|
| 100 |
+
juce::File("/Library/Audio/Plug-Ins"),
|
| 101 |
+
"*.vst3;*.component");
|
| 102 |
+
|
| 103 |
+
chooser->launchAsync(juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles,
|
| 104 |
+
[this, chooser](const juce::FileChooser& fc)
|
| 105 |
+
{
|
| 106 |
+
auto file = fc.getResult();
|
| 107 |
+
if (file.exists())
|
| 108 |
+
processorRef.loadPluginFromFile(file);
|
| 109 |
+
});
|
| 110 |
}
|