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