kopia lustrzana https://github.com/jameshball/osci-render
Use native window with native menu bar
rodzic
3540074cc8
commit
151aaf68cf
|
@ -1,5 +1,6 @@
|
|||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
#include <juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h>
|
||||
|
||||
OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioProcessor& p)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), collapseButton("Collapse", juce::Colours::white, juce::Colours::white, juce::Colours::white)
|
||||
|
@ -8,8 +9,16 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
|||
setLookAndFeel(&lookAndFeel);
|
||||
addAndMakeVisible(volume);
|
||||
|
||||
menuBar.setModel(&menuBarModel);
|
||||
addAndMakeVisible(menuBar);
|
||||
#if JUCE_MAC
|
||||
if (audioProcessor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone) {
|
||||
usingNativeMenuBar = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!usingNativeMenuBar) {
|
||||
menuBar.setModel(&menuBarModel);
|
||||
addAndMakeVisible(menuBar);
|
||||
}
|
||||
|
||||
addAndMakeVisible(collapseButton);
|
||||
collapseButton.onClick = [this] {
|
||||
|
@ -92,7 +101,10 @@ void OscirenderAudioProcessorEditor::paint(juce::Graphics& g) {
|
|||
|
||||
void OscirenderAudioProcessorEditor::resized() {
|
||||
auto area = getLocalBounds();
|
||||
menuBar.setBounds(area.removeFromTop(25));
|
||||
if (!usingNativeMenuBar) {
|
||||
menuBar.setBounds(area.removeFromTop(25));
|
||||
}
|
||||
|
||||
area.removeFromTop(2);
|
||||
area.removeFromLeft(3);
|
||||
auto volumeArea = area.removeFromLeft(30);
|
||||
|
@ -384,3 +396,8 @@ void OscirenderAudioProcessorEditor::updateTitle() {
|
|||
}
|
||||
getTopLevelComponent()->setName(title);
|
||||
}
|
||||
|
||||
void OscirenderAudioProcessorEditor::openAudioSettings() {
|
||||
juce::StandalonePluginHolder* standalone = juce::StandalonePluginHolder::getInstance();
|
||||
standalone->showAudioSettingsDialog();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
void saveProject();
|
||||
void saveProjectAs();
|
||||
void updateTitle();
|
||||
void openAudioSettings();
|
||||
|
||||
std::atomic<bool> editingPerspective = false;
|
||||
|
||||
|
@ -61,6 +62,8 @@ private:
|
|||
|
||||
std::atomic<bool> updatingDocumentsWithParserLock = false;
|
||||
|
||||
bool usingNativeMenuBar = false;
|
||||
|
||||
void codeDocumentTextInserted(const juce::String& newText, int insertIndex) override;
|
||||
void codeDocumentTextDeleted(int startIndex, int endIndex) override;
|
||||
void updateCodeDocument();
|
||||
|
|
|
@ -608,6 +608,12 @@ bool OscirenderAudioProcessor::hasEditor() const {
|
|||
|
||||
juce::AudioProcessorEditor* OscirenderAudioProcessor::createEditor() {
|
||||
auto editor = new OscirenderAudioProcessorEditor(*this);
|
||||
if (wrapperType == wrapperType_Standalone) {
|
||||
if (juce::TopLevelWindow::getNumTopLevelWindows() == 1) {
|
||||
juce::TopLevelWindow* w = juce::TopLevelWindow::getTopLevelWindow(0);
|
||||
w->setUsingNativeTitleBar(true);
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,31 +2,47 @@
|
|||
#include "../PluginEditor.h"
|
||||
|
||||
juce::StringArray MainMenuBarModel::getMenuBarNames() {
|
||||
return juce::StringArray("File");
|
||||
return juce::StringArray("File", "Options");
|
||||
}
|
||||
|
||||
juce::PopupMenu MainMenuBarModel::getMenuForIndex(int topLevelMenuIndex, const juce::String& menuName) {
|
||||
juce::PopupMenu menu;
|
||||
menu.addItem(1, "Open");
|
||||
menu.addItem(2, "Save");
|
||||
menu.addItem(3, "Save As");
|
||||
|
||||
if (topLevelMenuIndex == 0) {
|
||||
menu.addItem(1, "Open");
|
||||
menu.addItem(2, "Save");
|
||||
menu.addItem(3, "Save As");
|
||||
} else if (topLevelMenuIndex == 1) {
|
||||
menu.addItem(1, "Audio Settings");
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
void MainMenuBarModel::menuItemSelected(int menuItemID, int topLevelMenuIndex) {
|
||||
switch (menuItemID) {
|
||||
switch (topLevelMenuIndex) {
|
||||
case 0:
|
||||
switch (menuItemID) {
|
||||
case 1:
|
||||
editor.openProject();
|
||||
break;
|
||||
case 2:
|
||||
editor.saveProject();
|
||||
break;
|
||||
case 3:
|
||||
editor.saveProjectAs();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
editor.openProject();
|
||||
break;
|
||||
case 2:
|
||||
editor.saveProject();
|
||||
break;
|
||||
case 3:
|
||||
editor.saveProjectAs();
|
||||
editor.openAudioSettings();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainMenuBarModel::menuBarActivated(bool isActive) {}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "LuaParser.h"
|
||||
#include "luaimport.h"
|
||||
|
||||
|
||||
LuaParser::LuaParser(juce::String fileName, juce::String script, std::function<void(int, juce::String, juce::String)> errorCallback, juce::String fallbackScript) : fallbackScript(fallbackScript), errorCallback(errorCallback), fileName(fileName) {
|
||||
reset(script);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue