File size: 1,783 Bytes
a33ab3c
 
9f7698e
a33ab3c
 
fdc4e41
a33ab3c
9f7698e
a33ab3c
 
9f7698e
a33ab3c
 
9f7698e
a33ab3c
 
 
 
 
fdc4e41
 
 
 
 
a33ab3c
 
 
d966811
6b15202
 
 
a33ab3c
6b15202
a33ab3c
fdc4e41
 
 
 
 
 
 
 
9f7698e
fdc4e41
 
224d9fb
6b15202
 
 
 
 
 
ac5992d
a33ab3c
 
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
#pragma once

#include <juce_audio_processors/juce_audio_processors.h>
#include <juce_gui_basics/juce_gui_basics.h>
#include "PluginBridgeProcessor.h"
#include "PluginPickerComponent.h"

class PluginBridgeEditor : public juce::AudioProcessorEditor, private juce::Timer
{
public:
    PluginBridgeEditor(PluginBridgeProcessor& p);
    ~PluginBridgeEditor() override;

    void paint(juce::Graphics& g) override;
    void resized() override;

private:
    void timerCallback() override;
    void showPluginMenu();
    void hidePicker();
    void attachPluginEditor();
    void detachPluginEditor();
    void showAudioOnlyUI();
    void hideAudioOnlyUI();

    PluginBridgeProcessor& processorRef;

    // Top bar controls
    juce::Label     titleLabel;
    juce::Label     mcpStatusLabel;
    juce::Label     pluginStatusLabel;
    juce::TextButton selectButton{"Select Plugin"};
    juce::ComboBox  channelDropdown;

    // In-process plugin editor (null for unsafe plugins)
    std::unique_ptr<juce::AudioProcessorEditor> pluginEditor;

    // Plugin browser — shown inline when user hits Select Plugin
    std::unique_ptr<PluginPickerComponent> activePicker;

    // Shown instead of plugin editor when plugin is unsafe (audio-only mode)
    juce::Label audioOnlyLabel;

    bool showingError      = false;
    bool audioOnlyMode     = false;

    static constexpr int kTopBarHeight     = 32;
    static constexpr int kChannelBarHeight = 26;
    static constexpr int kHeaderHeight     = kTopBarHeight + kChannelBarHeight;
    static constexpr int kAudioOnlyHeight  = 80;
    static constexpr int kDefaultWidth     = PluginPickerComponent::kWidth;
    static constexpr int kDefaultHeight    = kHeaderHeight;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginBridgeEditor)
};