2024-09-12 22:09:54 +00:00
|
|
|
#include "SosciPluginProcessor.h"
|
|
|
|
#include "SosciPluginEditor.h"
|
|
|
|
#include <juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h>
|
|
|
|
|
2025-01-06 11:17:42 +00:00
|
|
|
SosciPluginEditor::SosciPluginEditor(SosciAudioProcessor& p) : CommonPluginEditor(p, "sosci", "sosci", 1180, 750), audioProcessor(p) {
|
2024-12-14 18:15:22 +00:00
|
|
|
initialiseMenuBar(model);
|
2025-01-06 09:14:34 +00:00
|
|
|
addAndMakeVisible(volume);
|
2025-01-06 11:17:42 +00:00
|
|
|
addAndMakeVisible(visualiserSettingsWrapper);
|
|
|
|
|
2025-01-07 18:28:55 +00:00
|
|
|
BooleanParameter* visualiserFullScreen = audioProcessor.visualiserParameters.visualiserFullScreen;
|
|
|
|
visualiserFullScreenChanged();
|
|
|
|
|
|
|
|
visualiser.setFullScreenCallback([this, visualiserFullScreen](FullScreenMode mode) {
|
|
|
|
if (mode == FullScreenMode::TOGGLE) {
|
|
|
|
visualiserFullScreen->setBoolValueNotifyingHost(!visualiserFullScreen->getBoolValue());
|
|
|
|
} else if (mode == FullScreenMode::FULL_SCREEN) {
|
|
|
|
visualiserFullScreen->setBoolValueNotifyingHost(true);
|
|
|
|
} else if (mode == FullScreenMode::MAIN_COMPONENT) {
|
|
|
|
visualiserFullScreen->setBoolValueNotifyingHost(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
visualiserFullScreenChanged();
|
|
|
|
});
|
|
|
|
|
2024-12-14 18:15:22 +00:00
|
|
|
resized();
|
2025-01-07 18:55:35 +00:00
|
|
|
visualiserFullScreen->addListener(this);
|
2024-09-12 22:09:54 +00:00
|
|
|
}
|
|
|
|
|
2024-12-14 20:42:35 +00:00
|
|
|
SosciPluginEditor::~SosciPluginEditor() {
|
2025-01-07 18:55:35 +00:00
|
|
|
audioProcessor.visualiserParameters.visualiserFullScreen->removeListener(this);
|
2024-12-14 20:42:35 +00:00
|
|
|
menuBar.setModel(nullptr);
|
|
|
|
}
|
|
|
|
|
2024-09-12 22:09:54 +00:00
|
|
|
void SosciPluginEditor::paint(juce::Graphics& g) {
|
2024-10-06 19:11:53 +00:00
|
|
|
g.fillAll(Colours::veryDark);
|
2024-09-12 22:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SosciPluginEditor::resized() {
|
2025-01-06 09:14:34 +00:00
|
|
|
auto area = getLocalBounds();
|
|
|
|
|
2025-01-07 18:28:55 +00:00
|
|
|
if (audioProcessor.visualiserParameters.visualiserFullScreen->getBoolValue()) {
|
|
|
|
visualiser.setBounds(area);
|
|
|
|
} else {
|
|
|
|
menuBar.setBounds(area.removeFromTop(25));
|
2025-01-06 09:14:34 +00:00
|
|
|
|
2025-01-07 18:28:55 +00:00
|
|
|
auto volumeArea = area.removeFromLeft(30);
|
|
|
|
volume.setBounds(volumeArea.withSizeKeepingCentre(volumeArea.getWidth(), juce::jmin(volumeArea.getHeight(), 300)));
|
2025-01-06 09:14:34 +00:00
|
|
|
|
2025-01-07 18:28:55 +00:00
|
|
|
auto settingsArea = area.removeFromRight(juce::jmax(juce::jmin(0.4 * getWidth(), 550.0), 350.0));
|
|
|
|
visualiserSettings.setSize(settingsArea.getWidth(), 550);
|
|
|
|
visualiserSettingsWrapper.setBounds(settingsArea);
|
2025-01-06 11:17:42 +00:00
|
|
|
|
2025-01-07 18:28:55 +00:00
|
|
|
visualiser.setBounds(area);
|
2025-01-06 18:27:23 +00:00
|
|
|
}
|
2024-09-12 22:09:54 +00:00
|
|
|
}
|
2025-01-07 12:17:38 +00:00
|
|
|
|
|
|
|
bool SosciPluginEditor::isInterestedInFileDrag(const juce::StringArray& files) {
|
|
|
|
if (files.size() != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
juce::File file(files[0]);
|
|
|
|
return
|
|
|
|
file.hasFileExtension("wav") ||
|
|
|
|
file.hasFileExtension("mp3") ||
|
|
|
|
file.hasFileExtension("aiff") ||
|
|
|
|
file.hasFileExtension("flac") ||
|
|
|
|
file.hasFileExtension("ogg");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SosciPluginEditor::filesDropped(const juce::StringArray& files, int x, int y) {
|
|
|
|
if (files.size() != 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
juce::File file(files[0]);
|
|
|
|
audioProcessor.loadAudioFile(file);
|
|
|
|
}
|
2025-01-07 18:28:55 +00:00
|
|
|
|
|
|
|
void SosciPluginEditor::visualiserFullScreenChanged() {
|
|
|
|
bool fullScreen = audioProcessor.visualiserParameters.visualiserFullScreen->getBoolValue();
|
|
|
|
|
|
|
|
volume.setVisible(!fullScreen);
|
|
|
|
visualiserSettingsWrapper.setVisible(!fullScreen);
|
|
|
|
menuBar.setVisible(!fullScreen);
|
2025-01-07 18:55:35 +00:00
|
|
|
resized();
|
|
|
|
repaint();
|
2025-01-07 18:28:55 +00:00
|
|
|
}
|
2025-01-07 18:55:35 +00:00
|
|
|
|
|
|
|
void SosciPluginEditor::parameterValueChanged(int parameterIndex, float newValue) {
|
|
|
|
juce::MessageManager::callAsync([this] {
|
|
|
|
visualiserFullScreenChanged();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void SosciPluginEditor::parameterGestureChanged(int parameterIndex, bool gestureIsStarting) {}
|