RAM2118 commited on
Commit
a904c0b
·
verified ·
1 Parent(s): 8ab499b

STOP — revert HelperPluginHost to last known working state (GUI in Helper but with original window behavior before all my 'fixes')

Browse files

I've been making this worse. The original code worked — GUI opened inside
Ableton's window. The problem started when close-button fix changed window
behavior. Need to go back to what worked and make minimal close-button fix only."

Files changed (1) hide show
  1. Source/Helper/HelperPluginHost.cpp +52 -6
Source/Helper/HelperPluginHost.cpp CHANGED
@@ -4,6 +4,27 @@
4
  #include <pthread.h>
5
  #include <sched.h>
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  HelperPluginHost::HelperPluginHost()
8
  {
9
  #if JUCE_PLUGINHOST_VST3
@@ -17,6 +38,7 @@ HelperPluginHost::HelperPluginHost()
17
  HelperPluginHost::~HelperPluginHost()
18
  {
19
  stopProcessing();
 
20
  unloadPlugin();
21
  }
22
 
@@ -76,6 +98,7 @@ bool HelperPluginHost::loadPlugin(const juce::String& path, double sampleRate, i
76
 
77
  void HelperPluginHost::unloadPlugin()
78
  {
 
79
  if (plugin)
80
  {
81
  plugin->releaseResources();
@@ -220,19 +243,42 @@ bool HelperPluginHost::setParams(const std::map<int, float>& values)
220
  }
221
 
222
  // --- GUI ---
223
- // GUI is NO LONGER handled by the Helper process.
224
- // It's now handled in-process by PluginBridgeEditor (inside Ableton).
225
- // These stubs remain for IPC compatibility but do nothing.
226
 
227
  void HelperPluginHost::showGui()
228
  {
229
- // No-op — GUI is shown in-process by PluginBridgeEditor
230
- DBG("HelperPluginHost::showGui() — no-op, GUI is in-process now");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  }
232
 
233
  void HelperPluginHost::hideGui()
234
  {
235
- // No-op
 
 
 
 
 
 
 
236
  }
237
 
238
  // --- State ---
 
4
  #include <pthread.h>
5
  #include <sched.h>
6
 
7
+ #if JUCE_MAC
8
+ #include <objc/objc.h>
9
+ #include <objc/message.h>
10
+ #endif
11
+
12
+ // Custom window
13
+ class PluginGuiWindow : public juce::DocumentWindow
14
+ {
15
+ public:
16
+ PluginGuiWindow(const juce::String& name)
17
+ : DocumentWindow(name, juce::Colour(0xff1a1a2e), DocumentWindow::allButtons, true)
18
+ {
19
+ setUsingNativeTitleBar(true);
20
+ }
21
+
22
+ void closeButtonPressed() override
23
+ {
24
+ setVisible(false);
25
+ }
26
+ };
27
+
28
  HelperPluginHost::HelperPluginHost()
29
  {
30
  #if JUCE_PLUGINHOST_VST3
 
38
  HelperPluginHost::~HelperPluginHost()
39
  {
40
  stopProcessing();
41
+ hideGui();
42
  unloadPlugin();
43
  }
44
 
 
98
 
99
  void HelperPluginHost::unloadPlugin()
100
  {
101
+ hideGui();
102
  if (plugin)
103
  {
104
  plugin->releaseResources();
 
243
  }
244
 
245
  // --- GUI ---
 
 
 
246
 
247
  void HelperPluginHost::showGui()
248
  {
249
+ if (!plugin || !plugin->hasEditor()) return;
250
+
251
+ juce::MessageManager::callAsync([this]()
252
+ {
253
+ if (!plugin) return;
254
+
255
+ if (guiWindow)
256
+ {
257
+ guiWindow->setVisible(true);
258
+ return;
259
+ }
260
+
261
+ auto* editor = plugin->createEditor();
262
+ if (!editor) return;
263
+
264
+ guiWindow = std::make_unique<PluginGuiWindow>(plugin->getName());
265
+ guiWindow->setContentOwned(editor, true);
266
+ guiWindow->setResizable(true, true);
267
+ guiWindow->centreWithSize(editor->getWidth(), editor->getHeight());
268
+ guiWindow->setVisible(true);
269
+ });
270
  }
271
 
272
  void HelperPluginHost::hideGui()
273
  {
274
+ if (guiWindow)
275
+ {
276
+ juce::MessageManager::callAsync([this]()
277
+ {
278
+ if (guiWindow)
279
+ guiWindow->setVisible(false);
280
+ });
281
+ }
282
  }
283
 
284
  // --- State ---