pluginbridge / Source /PluginBridgeEditor.cpp
RAM2118's picture
Sprint 1: Add PluginBridgeEditor.cpp — shows MCP server status
179fedf verified
Raw History Blame
2.01 kB
#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);
}
}