File size: 2,014 Bytes
179fedf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #include "PluginBridgeEditor.h"
PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p)
: AudioProcessorEditor(&p), processorRef(p)
{
setSize(300, 150);
titleLabel.setText("PluginBridge", juce::dontSendNotification);
titleLabel.setFont(juce::FontOptions(20.0f));
titleLabel.setJustificationType(juce::Justification::centred);
addAndMakeVisible(titleLabel);
statusLabel.setText("MCP: starting...", juce::dontSendNotification);
statusLabel.setFont(juce::FontOptions(14.0f));
statusLabel.setJustificationType(juce::Justification::centred);
addAndMakeVisible(statusLabel);
portLabel.setText("", juce::dontSendNotification);
portLabel.setFont(juce::FontOptions(12.0f));
portLabel.setJustificationType(juce::Justification::centred);
portLabel.setColour(juce::Label::textColourId, juce::Colours::grey);
addAndMakeVisible(portLabel);
startTimerHz(2); // Update status 2x per second
}
PluginBridgeEditor::~PluginBridgeEditor()
{
stopTimer();
}
void PluginBridgeEditor::paint(juce::Graphics& g)
{
g.fillAll(juce::Colour(0xff1a1a2e));
}
void PluginBridgeEditor::resized()
{
auto area = getLocalBounds().reduced(10);
titleLabel.setBounds(area.removeFromTop(40));
area.removeFromTop(10);
statusLabel.setBounds(area.removeFromTop(30));
portLabel.setBounds(area.removeFromTop(25));
}
void PluginBridgeEditor::timerCallback()
{
if (processorRef.isMcpServerRunning()) {
statusLabel.setText("MCP: running", juce::dontSendNotification);
statusLabel.setColour(juce::Label::textColourId, juce::Colours::limegreen);
portLabel.setText("http://127.0.0.1:" + juce::String(processorRef.getMcpServerPort()) + "/mcp",
juce::dontSendNotification);
} else {
statusLabel.setText("MCP: offline", juce::dontSendNotification);
statusLabel.setColour(juce::Label::textColourId, juce::Colours::red);
portLabel.setText("", juce::dontSendNotification);
}
}
|