2024-09-22 17:49:58 +00:00
|
|
|
#include "SosciMainMenuBarModel.h"
|
|
|
|
#include "../SosciPluginEditor.h"
|
2024-10-05 19:45:18 +00:00
|
|
|
#include "../SosciPluginProcessor.h"
|
2024-09-22 17:49:58 +00:00
|
|
|
|
2025-01-04 18:29:09 +00:00
|
|
|
SosciMainMenuBarModel::SosciMainMenuBarModel(SosciPluginEditor& e, SosciAudioProcessor& p) : editor(e), processor(p) {
|
2024-12-14 18:15:22 +00:00
|
|
|
addTopLevelMenu("File");
|
|
|
|
addTopLevelMenu("About");
|
2024-12-23 19:37:12 +00:00
|
|
|
addTopLevelMenu("Recording");
|
2024-12-14 18:15:22 +00:00
|
|
|
addTopLevelMenu("Audio");
|
2025-01-04 18:29:09 +00:00
|
|
|
|
|
|
|
std::vector<std::tuple<juce::String, const void *, int>> examples = {
|
|
|
|
{"default.sosci", BinaryData::default_sosci, BinaryData::default_sosciSize},
|
2025-01-08 13:06:01 +00:00
|
|
|
{"clean.sosci", BinaryData::clean_sosci, BinaryData::clean_sosciSize},
|
|
|
|
{"vector_display.sosci", BinaryData::vector_display_sosci, BinaryData::vector_display_sosciSize},
|
|
|
|
{"real_oscilloscope.sosci", BinaryData::real_oscilloscope_sosci, BinaryData::real_oscilloscope_sosciSize},
|
|
|
|
{"rainbow.sosci", BinaryData::rainbow_sosci, BinaryData::rainbow_sosciSize},
|
2025-01-04 18:29:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This is a hack - ideally I would improve the MainMenuBarModel class to allow for submenus
|
|
|
|
customMenuLogic = [this, examples](juce::PopupMenu& menu, int topLevelMenuIndex) {
|
|
|
|
if (topLevelMenuIndex == 0) {
|
|
|
|
juce::PopupMenu submenu;
|
|
|
|
|
|
|
|
for (int i = 0; i < examples.size(); i++) {
|
|
|
|
submenu.addItem(SUBMENU_ID + i, std::get<0>(examples[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.addSubMenu("Examples", submenu);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
customMenuSelectedLogic = [this, examples](int menuItemID, int topLevelMenuIndex) {
|
|
|
|
if (topLevelMenuIndex == 0) {
|
|
|
|
if (menuItemID >= SUBMENU_ID) {
|
|
|
|
int index = menuItemID - SUBMENU_ID;
|
|
|
|
processor.setStateInformation(std::get<1>(examples[index]), std::get<2>(examples[index]));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2024-12-14 18:15:22 +00:00
|
|
|
|
2025-01-05 15:55:53 +00:00
|
|
|
addMenuItem(0, "Open Audio File", [&]() {
|
2025-01-06 18:27:23 +00:00
|
|
|
fileChooser = std::make_unique<juce::FileChooser>("Open Audio File", processor.lastOpenedDirectory, "*.wav;*.aiff;*.flac;*.ogg;*.mp3");
|
2025-01-05 15:55:53 +00:00
|
|
|
auto flags = juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles;
|
|
|
|
fileChooser->launchAsync(flags, [&](const juce::FileChooser& chooser) {
|
|
|
|
auto file = chooser.getResult();
|
|
|
|
if (file != juce::File()) {
|
|
|
|
processor.loadAudioFile(file);
|
2025-01-06 18:27:23 +00:00
|
|
|
processor.lastOpenedDirectory = file.getParentDirectory();
|
2025-01-05 15:55:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
addMenuItem(0, "Open Project", [&]() { editor.openProject(); });
|
|
|
|
addMenuItem(0, "Save Project", [&]() { editor.saveProject(); });
|
|
|
|
addMenuItem(0, "Save Project As", [&]() { editor.saveProjectAs(); });
|
2024-12-14 18:15:22 +00:00
|
|
|
if (editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) {
|
|
|
|
addMenuItem(0, "Create New Project", [&]() { editor.resetToDefault(); });
|
2024-09-22 17:49:58 +00:00
|
|
|
}
|
|
|
|
|
2024-12-14 18:15:22 +00:00
|
|
|
addMenuItem(1, "About sosci", [&]() {
|
|
|
|
juce::DialogWindow::LaunchOptions options;
|
2025-01-04 18:29:09 +00:00
|
|
|
AboutComponent* about = new AboutComponent(BinaryData::sosci_logo_png, BinaryData::sosci_logo_pngSize,
|
2025-01-04 14:35:10 +00:00
|
|
|
juce::String(ProjectInfo::projectName) + " by " + ProjectInfo::companyName + "\n"
|
|
|
|
#if SOSCI_FEATURES
|
|
|
|
"Thank you for purchasing sosci!\n"
|
|
|
|
#else
|
|
|
|
"Free version\n"
|
|
|
|
#endif
|
|
|
|
"Version " + ProjectInfo::versionString + "\n\n"
|
|
|
|
"A huge thank you to:\n"
|
|
|
|
"Neil Thapen, for allowing me to adapt the brilliant dood.al/oscilloscope\n"
|
|
|
|
"Kevin Kripper, for guiding much of the features and development of sosci\n"
|
|
|
|
"DJ_Level_3, for testing throughout and helping add features\n"
|
|
|
|
"All the community, for suggesting features and reporting issues!"
|
|
|
|
);
|
2024-12-14 18:15:22 +00:00
|
|
|
options.content.setOwned(about);
|
|
|
|
options.content->setSize(500, 270);
|
|
|
|
options.dialogTitle = "About";
|
2025-01-04 18:29:09 +00:00
|
|
|
options.dialogBackgroundColour = Colours::veryDark;
|
2024-12-14 18:15:22 +00:00
|
|
|
options.escapeKeyTriggersCloseButton = true;
|
2024-09-22 17:49:58 +00:00
|
|
|
#if JUCE_WINDOWS
|
2024-12-14 18:15:22 +00:00
|
|
|
// if not standalone, use native title bar for compatibility with DAWs
|
|
|
|
options.useNativeTitleBar = editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone;
|
2024-09-22 17:49:58 +00:00
|
|
|
#elif JUCE_MAC
|
2024-12-14 18:15:22 +00:00
|
|
|
options.useNativeTitleBar = true;
|
2024-09-22 17:49:58 +00:00
|
|
|
#endif
|
2024-12-14 18:15:22 +00:00
|
|
|
options.resizable = false;
|
|
|
|
|
|
|
|
juce::DialogWindow* dw = options.launchAsync();
|
|
|
|
});
|
2024-12-23 19:37:12 +00:00
|
|
|
|
|
|
|
addMenuItem(2, "Settings...", [this] {
|
|
|
|
editor.openRecordingSettings();
|
|
|
|
});
|
2024-12-14 18:15:22 +00:00
|
|
|
|
2024-12-23 19:37:12 +00:00
|
|
|
addMenuItem(3, "Force Disable Brightness Input", [&]() {
|
2024-12-14 18:15:22 +00:00
|
|
|
processor.forceDisableBrightnessInput = !processor.forceDisableBrightnessInput;
|
|
|
|
menuItemsChanged();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (editor.processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) {
|
2024-12-23 19:37:12 +00:00
|
|
|
addMenuItem(3, "Settings...", [&]() { editor.openAudioSettings(); });
|
2024-09-22 17:49:58 +00:00
|
|
|
}
|
|
|
|
}
|