RAM2118 commited on
Commit
4ca2875
·
verified ·
1 Parent(s): a4fe44e

remove old files replaced by .mm versions + Blocklist (now in PluginBridgeProcessor.h)

Browse files
Source/Helper/HelperPluginHost.cpp DELETED
@@ -1,3 +0,0 @@
1
- // HelperPluginHost.cpp — implementation is fully in the header (header-only class)
2
- // This file exists only to keep CMake happy as a compilation unit.
3
- #include "HelperPluginHost.h"
 
 
 
 
Source/Plugin/Blocklist.h DELETED
@@ -1,70 +0,0 @@
1
- #pragma once
2
-
3
- #include <juce_core/juce_core.h>
4
- #include <set>
5
-
6
- // Persistent blocklist — stores plugin paths that crashed on load.
7
- // Saved to ~/Library/PluginBridge/blocklist.txt
8
- // (JUCE's userApplicationDataDirectory on macOS = ~/Library/)
9
-
10
- class Blocklist
11
- {
12
- public:
13
- Blocklist()
14
- {
15
- load();
16
- }
17
-
18
- bool isBlocked(const juce::String& path) const
19
- {
20
- return blockedPaths.count(path.toStdString()) > 0;
21
- }
22
-
23
- void addBlocked(const juce::String& path)
24
- {
25
- blockedPaths.insert(path.toStdString());
26
- save();
27
- }
28
-
29
- void clear()
30
- {
31
- blockedPaths.clear();
32
- save();
33
- }
34
-
35
- private:
36
- std::set<std::string> blockedPaths;
37
-
38
- juce::File getBlocklistFile() const
39
- {
40
- // userApplicationDataDirectory on macOS = ~/Library/
41
- auto dir = juce::File::getSpecialLocation(juce::File::userApplicationDataDirectory)
42
- .getChildFile("PluginBridge");
43
- dir.createDirectory();
44
- return dir.getChildFile("blocklist.txt");
45
- }
46
-
47
- void load()
48
- {
49
- auto file = getBlocklistFile();
50
- if (!file.existsAsFile()) return;
51
-
52
- juce::StringArray lines;
53
- file.readLines(lines);
54
- for (auto& line : lines)
55
- {
56
- auto trimmed = line.trim();
57
- if (trimmed.isNotEmpty())
58
- blockedPaths.insert(trimmed.toStdString());
59
- }
60
- }
61
-
62
- void save()
63
- {
64
- auto file = getBlocklistFile();
65
- juce::String content;
66
- for (auto& path : blockedPaths)
67
- content += juce::String(path) + "\n";
68
- file.replaceWithText(content);
69
- }
70
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Source/Plugin/PluginBridgeEditor.cpp DELETED
@@ -1,222 +0,0 @@
1
- #include "PluginBridgeEditor.h"
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 kTextPrimary (0xffe8e8f0);
7
- static const juce::Colour kTextSecondary(0xff8888aa);
8
- static const juce::Colour kGreen (0xff4cef50);
9
- static const juce::Colour kRed (0xffef5350);
10
-
11
- PluginBridgeEditor::PluginBridgeEditor(PluginBridgeProcessor& p)
12
- : AudioProcessorEditor(&p), processorRef(p)
13
- {
14
- setSize(kDefaultWidth, kDefaultHeight);
15
- setResizable(true, true);
16
-
17
- // Title
18
- titleLabel.setText("PluginBridge", juce::dontSendNotification);
19
- titleLabel.setFont(juce::FontOptions(14.0f));
20
- titleLabel.setJustificationType(juce::Justification::centredLeft);
21
- titleLabel.setColour(juce::Label::textColourId, kTextPrimary);
22
- addAndMakeVisible(titleLabel);
23
-
24
- // MCP status
25
- mcpStatusLabel.setFont(juce::FontOptions(11.0f));
26
- mcpStatusLabel.setJustificationType(juce::Justification::centredRight);
27
- addAndMakeVisible(mcpStatusLabel);
28
-
29
- // Plugin name
30
- pluginStatusLabel.setFont(juce::FontOptions(11.0f));
31
- pluginStatusLabel.setJustificationType(juce::Justification::centredLeft);
32
- pluginStatusLabel.setColour(juce::Label::textColourId, kTextSecondary);
33
- addAndMakeVisible(pluginStatusLabel);
34
-
35
- // Select button
36
- selectButton.onClick = [this]() { showPluginMenu(); };
37
- selectButton.setColour(juce::TextButton::buttonColourId, kAccent);
38
- selectButton.setColour(juce::TextButton::textColourOffId, kTextPrimary);
39
- addAndMakeVisible(selectButton);
40
-
41
- // Callbacks from processor
42
- processorRef.onPluginLoaded = [this]()
43
- {
44
- juce::MessageManager::callAsync([this]() { embedPluginEditor(); });
45
- };
46
-
47
- processorRef.onPluginUnloaded = [this]()
48
- {
49
- juce::MessageManager::callAsync([this]() { removePluginEditor(); });
50
- };
51
-
52
- processorRef.onLoadFailed = [this](const juce::String& error)
53
- {
54
- juce::MessageManager::callAsync([this, error]()
55
- {
56
- pluginStatusLabel.setText(error, juce::dontSendNotification);
57
- pluginStatusLabel.setColour(juce::Label::textColourId, kRed);
58
- showingError = true;
59
- });
60
- };
61
-
62
- // If plugin already loaded (e.g. restoring state), embed it
63
- if (processorRef.isPluginLoaded())
64
- embedPluginEditor();
65
-
66
- startTimerHz(4);
67
- }
68
-
69
- PluginBridgeEditor::~PluginBridgeEditor()
70
- {
71
- stopTimer();
72
- processorRef.onPluginLoaded = nullptr;
73
- processorRef.onPluginUnloaded = nullptr;
74
- processorRef.onLoadFailed = nullptr;
75
- removePluginEditor();
76
- }
77
-
78
- void PluginBridgeEditor::paint(juce::Graphics& g)
79
- {
80
- g.fillAll(kBgDark);
81
-
82
- // Top bar background
83
- auto topBar = getLocalBounds().removeFromTop(kTopBarHeight);
84
- g.setColour(kBgPanel);
85
- g.fillRect(topBar);
86
-
87
- // Separator line
88
- g.setColour(kAccent.withAlpha(0.3f));
89
- g.drawHorizontalLine(kTopBarHeight - 1, 0.0f, (float)getWidth());
90
- }
91
-
92
- void PluginBridgeEditor::resized()
93
- {
94
- auto area = getLocalBounds();
95
- auto topBar = area.removeFromTop(kTopBarHeight).reduced(6, 4);
96
-
97
- // Top bar layout
98
- titleLabel.setBounds(topBar.removeFromLeft(90));
99
- selectButton.setBounds(topBar.removeFromLeft(110).reduced(0, 2));
100
- topBar.removeFromLeft(6);
101
- pluginStatusLabel.setBounds(topBar.removeFromLeft(topBar.getWidth() - 70));
102
- mcpStatusLabel.setBounds(topBar);
103
-
104
- // Plugin editor fills the rest
105
- if (hostedEditor)
106
- hostedEditor->setBounds(area);
107
- }
108
-
109
- void PluginBridgeEditor::timerCallback()
110
- {
111
- if (processorRef.isMcpServerRunning())
112
- {
113
- mcpStatusLabel.setText("MCP:" + juce::String(processorRef.getMcpServerPort()), juce::dontSendNotification);
114
- mcpStatusLabel.setColour(juce::Label::textColourId, kGreen);
115
- }
116
- else
117
- {
118
- mcpStatusLabel.setText("MCP:off", juce::dontSendNotification);
119
- mcpStatusLabel.setColour(juce::Label::textColourId, kRed);
120
- }
121
-
122
- if (processorRef.isPluginLoaded())
123
- {
124
- selectButton.setButtonText(processorRef.getLoadedPluginName());
125
- pluginStatusLabel.setText(juce::String(processorRef.getLoadedPluginParamCount()) + " params", juce::dontSendNotification);
126
- pluginStatusLabel.setColour(juce::Label::textColourId, kGreen);
127
- showingError = false;
128
- }
129
- else if (!showingError)
130
- {
131
- selectButton.setButtonText("Select Plugin");
132
- pluginStatusLabel.setText("No plugin loaded", juce::dontSendNotification);
133
- pluginStatusLabel.setColour(juce::Label::textColourId, kTextSecondary);
134
- }
135
- }
136
-
137
- void PluginBridgeEditor::embedPluginEditor()
138
- {
139
- removePluginEditor();
140
-
141
- auto* editor = processorRef.createHostedPluginEditor();
142
- if (!editor) return;
143
-
144
- hostedEditor.reset(editor);
145
- addAndMakeVisible(hostedEditor.get());
146
-
147
- // Resize PluginBridge editor to fit the hosted plugin's GUI + top bar
148
- auto editorWidth = std::max(hostedEditor->getWidth(), kDefaultWidth);
149
- auto editorHeight = hostedEditor->getHeight() + kTopBarHeight;
150
- setSize(editorWidth, editorHeight);
151
-
152
- showingError = false;
153
- }
154
-
155
- void PluginBridgeEditor::removePluginEditor()
156
- {
157
- if (hostedEditor)
158
- {
159
- removeChildComponent(hostedEditor.get());
160
- hostedEditor.reset();
161
- setSize(kDefaultWidth, kDefaultHeight);
162
- }
163
- }
164
-
165
- void PluginBridgeEditor::showPluginMenu()
166
- {
167
- auto files = processorRef.getInstalledPluginFiles();
168
-
169
- juce::PopupMenu menu;
170
-
171
- if (files.isEmpty())
172
- {
173
- menu.addItem(-1, "(No plugins found)", false);
174
- menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(&selectButton), [](int) {});
175
- return;
176
- }
177
-
178
- juce::PopupMenu vst3Menu;
179
- juce::PopupMenu auMenu;
180
- int itemId = 1;
181
-
182
- for (int i = 0; i < files.size(); ++i)
183
- {
184
- const auto& file = files[i];
185
- auto name = file.getFileNameWithoutExtension();
186
- auto path = file.getFullPathName();
187
- bool blocked = processorRef.isBlocked(path);
188
-
189
- if (file.getFileExtension() == ".vst3")
190
- vst3Menu.addItem(itemId, blocked ? name + " (not compatible)" : name, !blocked);
191
- else
192
- auMenu.addItem(itemId, blocked ? name + " (not compatible)" : name, !blocked);
193
-
194
- itemId++;
195
- }
196
-
197
- if (vst3Menu.getNumItems() > 0)
198
- menu.addSubMenu("VST3", vst3Menu);
199
- if (auMenu.getNumItems() > 0)
200
- menu.addSubMenu("Audio Units", auMenu);
201
-
202
- menu.addSeparator();
203
- menu.addItem(9999, "Clear blocklist");
204
-
205
- menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(&selectButton),
206
- [this, files](int result)
207
- {
208
- if (result == 9999)
209
- {
210
- processorRef.getBlocklist().clear();
211
- return;
212
- }
213
-
214
- if (result > 0 && result <= files.size())
215
- {
216
- pluginStatusLabel.setText("Loading...", juce::dontSendNotification);
217
- pluginStatusLabel.setColour(juce::Label::textColourId, kTextSecondary);
218
- showingError = false;
219
- processorRef.loadPlugin(files[result - 1].getFullPathName());
220
- }
221
- });
222
- }