RAM2118 commited on
Commit
54c3f6b
·
verified ·
1 Parent(s): 4a72dce

Fix: Editor reload button uses getLastPluginPath() (retained after crash)

Browse files
Source/Plugin/PluginBridgeEditor.cpp CHANGED
@@ -2,7 +2,7 @@
2
 
3
  static const juce::Colour kBgDark (0xff0d0d1a);
4
  static const juce::Colour kBgPanel (0xff1a1a2e);
5
- static const juce::Colour kAccent (0xff6c63ff); // Purple accent
6
  static const juce::Colour kAccentDim (0xff4a42cc);
7
  static const juce::Colour kTextPrimary (0xffe8e8f0);
8
  static const juce::Colour kTextSecondary(0xff8888aa);
@@ -16,48 +16,40 @@ PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p)
16
  {
17
  setSize(340, 200);
18
 
19
- // Title
20
  titleLabel.setText("PluginBridge", juce::dontSendNotification);
21
  titleLabel.setFont(juce::FontOptions(18.0f));
22
  titleLabel.setJustificationType(juce::Justification::centredLeft);
23
  titleLabel.setColour(juce::Label::textColourId, kTextPrimary);
24
  addAndMakeVisible(titleLabel);
25
 
26
- // MCP status
27
  mcpStatusLabel.setFont(juce::FontOptions(11.0f));
28
  mcpStatusLabel.setJustificationType(juce::Justification::centredRight);
29
  addAndMakeVisible(mcpStatusLabel);
30
 
31
- // Plugin status
32
  pluginStatusLabel.setFont(juce::FontOptions(13.0f));
33
  pluginStatusLabel.setJustificationType(juce::Justification::centredLeft);
34
  pluginStatusLabel.setColour(juce::Label::textColourId, kTextSecondary);
35
  addAndMakeVisible(pluginStatusLabel);
36
 
37
- // Connection status
38
  connectionLabel.setFont(juce::FontOptions(10.0f));
39
  connectionLabel.setJustificationType(juce::Justification::centredLeft);
40
  connectionLabel.setColour(juce::Label::textColourId, kTextSecondary);
41
  addAndMakeVisible(connectionLabel);
42
 
43
- // Select plugin button
44
  selectButton.onClick = [this]() { showPluginMenu(); };
45
  selectButton.setColour(juce::TextButton::buttonColourId, kAccent);
46
  selectButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
47
  addAndMakeVisible(selectButton);
48
 
49
- // Open GUI button
50
  guiButton.onClick = [this]() { processorRef.showPluginGui(); };
51
  guiButton.setColour(juce::TextButton::buttonColourId, kBtnBg);
52
  guiButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
53
  addAndMakeVisible(guiButton);
54
 
55
- // Reload button (shown after crash)
56
  reloadButton.onClick = [this]() {
57
- auto path = processorRef.getLoadedPluginName();
58
- // Re-attempt load with same plugin
59
- // For now, just respawn helper
60
- processorRef.loadPlugin(processorRef.getLoadedPluginName());
61
  };
62
  reloadButton.setColour(juce::TextButton::buttonColourId, kRed);
63
  reloadButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
@@ -76,12 +68,10 @@ void PluginBridgeEditor::paint(juce::Graphics& g)
76
  {
77
  g.fillAll(kBgDark);
78
 
79
- // Main panel
80
  auto panelArea = getLocalBounds().reduced(8);
81
  g.setColour(kBgPanel);
82
  g.fillRoundedRectangle(panelArea.toFloat(), 8.0f);
83
 
84
- // Subtle border
85
  g.setColour(kAccent.withAlpha(0.3f));
86
  g.drawRoundedRectangle(panelArea.toFloat(), 8.0f, 1.0f);
87
  }
@@ -90,20 +80,15 @@ void PluginBridgeEditor::resized()
90
  {
91
  auto area = getLocalBounds().reduced(16);
92
 
93
- // Top row: title + MCP status
94
  auto topRow = area.removeFromTop(24);
95
  titleLabel.setBounds(topRow.removeFromLeft(160));
96
  mcpStatusLabel.setBounds(topRow);
97
 
98
  area.removeFromTop(8);
99
-
100
- // Plugin status line
101
  pluginStatusLabel.setBounds(area.removeFromTop(20));
102
  connectionLabel.setBounds(area.removeFromTop(16));
103
-
104
  area.removeFromTop(12);
105
 
106
- // Button row
107
  auto buttonRow = area.removeFromTop(32);
108
  selectButton.setBounds(buttonRow.removeFromLeft(140));
109
  buttonRow.removeFromLeft(8);
@@ -114,7 +99,6 @@ void PluginBridgeEditor::resized()
114
 
115
  void PluginBridgeEditor::timerCallback()
116
  {
117
- // MCP status
118
  if (processorRef.isMcpServerRunning())
119
  {
120
  mcpStatusLabel.setText("MCP:" + juce::String(processorRef.getMcpServerPort()), juce::dontSendNotification);
@@ -126,7 +110,6 @@ void PluginBridgeEditor::timerCallback()
126
  mcpStatusLabel.setColour(juce::Label::textColourId, kRed);
127
  }
128
 
129
- // Plugin + connection status
130
  auto connState = processorRef.getConnectionState();
131
 
132
  if (processorRef.isPluginLoaded())
@@ -153,15 +136,15 @@ void PluginBridgeEditor::timerCallback()
153
  connectionLabel.setText("", juce::dontSendNotification);
154
  break;
155
  case HelperConnection::State::Starting:
156
- connectionLabel.setText("⏳ Starting helper...", juce::dontSendNotification);
157
  connectionLabel.setColour(juce::Label::textColourId, kYellow);
158
  break;
159
  case HelperConnection::State::Connected:
160
- connectionLabel.setText("⚡ Helper connected", juce::dontSendNotification);
161
  connectionLabel.setColour(juce::Label::textColourId, kGreen);
162
  break;
163
  case HelperConnection::State::Crashed:
164
- connectionLabel.setText("💥 Plugin crashed — click Reload", juce::dontSendNotification);
165
  connectionLabel.setColour(juce::Label::textColourId, kRed);
166
  reloadButton.setVisible(true);
167
  guiButton.setVisible(false);
 
2
 
3
  static const juce::Colour kBgDark (0xff0d0d1a);
4
  static const juce::Colour kBgPanel (0xff1a1a2e);
5
+ static const juce::Colour kAccent (0xff6c63ff);
6
  static const juce::Colour kAccentDim (0xff4a42cc);
7
  static const juce::Colour kTextPrimary (0xffe8e8f0);
8
  static const juce::Colour kTextSecondary(0xff8888aa);
 
16
  {
17
  setSize(340, 200);
18
 
 
19
  titleLabel.setText("PluginBridge", juce::dontSendNotification);
20
  titleLabel.setFont(juce::FontOptions(18.0f));
21
  titleLabel.setJustificationType(juce::Justification::centredLeft);
22
  titleLabel.setColour(juce::Label::textColourId, kTextPrimary);
23
  addAndMakeVisible(titleLabel);
24
 
 
25
  mcpStatusLabel.setFont(juce::FontOptions(11.0f));
26
  mcpStatusLabel.setJustificationType(juce::Justification::centredRight);
27
  addAndMakeVisible(mcpStatusLabel);
28
 
 
29
  pluginStatusLabel.setFont(juce::FontOptions(13.0f));
30
  pluginStatusLabel.setJustificationType(juce::Justification::centredLeft);
31
  pluginStatusLabel.setColour(juce::Label::textColourId, kTextSecondary);
32
  addAndMakeVisible(pluginStatusLabel);
33
 
 
34
  connectionLabel.setFont(juce::FontOptions(10.0f));
35
  connectionLabel.setJustificationType(juce::Justification::centredLeft);
36
  connectionLabel.setColour(juce::Label::textColourId, kTextSecondary);
37
  addAndMakeVisible(connectionLabel);
38
 
 
39
  selectButton.onClick = [this]() { showPluginMenu(); };
40
  selectButton.setColour(juce::TextButton::buttonColourId, kAccent);
41
  selectButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
42
  addAndMakeVisible(selectButton);
43
 
 
44
  guiButton.onClick = [this]() { processorRef.showPluginGui(); };
45
  guiButton.setColour(juce::TextButton::buttonColourId, kBtnBg);
46
  guiButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
47
  addAndMakeVisible(guiButton);
48
 
 
49
  reloadButton.onClick = [this]() {
50
+ auto path = processorRef.getLastPluginPath();
51
+ if (path.isNotEmpty())
52
+ processorRef.loadPlugin(path);
 
53
  };
54
  reloadButton.setColour(juce::TextButton::buttonColourId, kRed);
55
  reloadButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
 
68
  {
69
  g.fillAll(kBgDark);
70
 
 
71
  auto panelArea = getLocalBounds().reduced(8);
72
  g.setColour(kBgPanel);
73
  g.fillRoundedRectangle(panelArea.toFloat(), 8.0f);
74
 
 
75
  g.setColour(kAccent.withAlpha(0.3f));
76
  g.drawRoundedRectangle(panelArea.toFloat(), 8.0f, 1.0f);
77
  }
 
80
  {
81
  auto area = getLocalBounds().reduced(16);
82
 
 
83
  auto topRow = area.removeFromTop(24);
84
  titleLabel.setBounds(topRow.removeFromLeft(160));
85
  mcpStatusLabel.setBounds(topRow);
86
 
87
  area.removeFromTop(8);
 
 
88
  pluginStatusLabel.setBounds(area.removeFromTop(20));
89
  connectionLabel.setBounds(area.removeFromTop(16));
 
90
  area.removeFromTop(12);
91
 
 
92
  auto buttonRow = area.removeFromTop(32);
93
  selectButton.setBounds(buttonRow.removeFromLeft(140));
94
  buttonRow.removeFromLeft(8);
 
99
 
100
  void PluginBridgeEditor::timerCallback()
101
  {
 
102
  if (processorRef.isMcpServerRunning())
103
  {
104
  mcpStatusLabel.setText("MCP:" + juce::String(processorRef.getMcpServerPort()), juce::dontSendNotification);
 
110
  mcpStatusLabel.setColour(juce::Label::textColourId, kRed);
111
  }
112
 
 
113
  auto connState = processorRef.getConnectionState();
114
 
115
  if (processorRef.isPluginLoaded())
 
136
  connectionLabel.setText("", juce::dontSendNotification);
137
  break;
138
  case HelperConnection::State::Starting:
139
+ connectionLabel.setText("Starting helper...", juce::dontSendNotification);
140
  connectionLabel.setColour(juce::Label::textColourId, kYellow);
141
  break;
142
  case HelperConnection::State::Connected:
143
+ connectionLabel.setText("Helper connected", juce::dontSendNotification);
144
  connectionLabel.setColour(juce::Label::textColourId, kGreen);
145
  break;
146
  case HelperConnection::State::Crashed:
147
+ connectionLabel.setText("Plugin crashed - click Reload", juce::dontSendNotification);
148
  connectionLabel.setColour(juce::Label::textColourId, kRed);
149
  reloadButton.setVisible(true);
150
  guiButton.setVisible(false);