diff --git a/Source/LookAndFeel.cpp b/Source/LookAndFeel.cpp index 0697f89c..e8d02e8f 100644 --- a/Source/LookAndFeel.cpp +++ b/Source/LookAndFeel.cpp @@ -33,6 +33,11 @@ OscirenderLookAndFeel::OscirenderLookAndFeel() { setColour(juce::CodeEditorComponent::highlightColourId, Colours::grey); setColour(juce::CaretComponent::caretColourId, Dracula::foreground); setColour(juce::TextEditor::highlightColourId, Colours::grey); + setColour(juce::TabbedButtonBar::tabOutlineColourId, Colours::veryDark); + setColour(juce::TabbedButtonBar::frontOutlineColourId, Colours::veryDark); + setColour(juce::TabbedButtonBar::tabTextColourId, juce::Colours::black); + setColour(juce::TabbedButtonBar::frontTextColourId, juce::Colours::black); + setColour(juce::TabbedComponent::outlineColourId, Colours::veryDark); getCurrentColourScheme().setUIColour(ColourScheme::widgetBackground, Colours::veryDark); } diff --git a/Source/MidiComponent.cpp b/Source/MidiComponent.cpp new file mode 100644 index 00000000..6120547d --- /dev/null +++ b/Source/MidiComponent.cpp @@ -0,0 +1,20 @@ +#include "MidiComponent.h" +#include "PluginEditor.h" + +MidiComponent::MidiComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) { + addAndMakeVisible(midiToggle); + addAndMakeVisible(keyboard); +} + + +void MidiComponent::resized() { + auto area = getLocalBounds().reduced(5); + midiToggle.setBounds(area.removeFromTop(50)); + keyboard.setBounds(area.removeFromBottom(100)); +} + +void MidiComponent::paint(juce::Graphics& g) { + auto rect = getLocalBounds().reduced(5); + g.setColour(getLookAndFeel().findColour(groupComponentBackgroundColourId)); + g.fillRect(rect); +} diff --git a/Source/MidiComponent.h b/Source/MidiComponent.h new file mode 100644 index 00000000..1a09d933 --- /dev/null +++ b/Source/MidiComponent.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "PluginProcessor.h" + +class OscirenderAudioProcessorEditor; +class MidiComponent : public juce::Component { +public: + MidiComponent(OscirenderAudioProcessor&, OscirenderAudioProcessorEditor&); + + void resized() override; + void paint(juce::Graphics& g) override; +private: + OscirenderAudioProcessor& audioProcessor; + OscirenderAudioProcessorEditor& pluginEditor; + + juce::ToggleButton midiToggle{"Enable MIDI"}; + juce::MidiKeyboardState keyboardState; + juce::MidiKeyboardComponent keyboard{keyboardState, juce::MidiKeyboardComponent::horizontalKeyboard}; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MidiComponent) +}; \ No newline at end of file diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index ced58017..ec769caf 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -4,11 +4,11 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioProcessor& p) : AudioProcessorEditor(&p), audioProcessor(p), collapseButton("Collapse", juce::Colours::white, juce::Colours::white, juce::Colours::white) { - addAndMakeVisible(effects); - addAndMakeVisible(main); - addChildComponent(lua); - addChildComponent(obj); - addChildComponent(txt); + addAndMakeVisible(tabs); + tabs.addTab("Main", juce::Colours::white, &settings, false); + tabs.addTab("MIDI", juce::Colours::white, &midi, false); + tabs.setTabBackgroundColour(0, juce::Colours::white); + tabs.setTabBackgroundColour(1, juce::Colours::white); addAndMakeVisible(volume); menuBar.setModel(&menuBarModel); @@ -82,16 +82,6 @@ void OscirenderAudioProcessorEditor::initialiseCodeEditors() { void OscirenderAudioProcessorEditor::paint(juce::Graphics& g) { g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId)); - juce::DropShadow ds(juce::Colours::black, 10, juce::Point(0, 0)); - ds.drawForRectangle(g, main.getBounds()); - ds.drawForRectangle(g, effects.getBounds()); - if (lua.isVisible()) { - ds.drawForRectangle(g, lua.getBounds()); - } - if (obj.isVisible()) { - ds.drawForRectangle(g, obj.getBounds()); - } - g.setColour(juce::Colours::white); g.setFont(15.0f); } @@ -134,15 +124,8 @@ void OscirenderAudioProcessorEditor::resized() { collapseButton.setShape(path, false, true, true); } - auto effectsSection = area.removeFromRight(1.2 * getWidth() / sections); - main.setBounds(area.reduced(5)); - if (lua.isVisible() || obj.isVisible() || txt.isVisible()) { - auto altEffectsSection = effectsSection.removeFromBottom(juce::jmin(effectsSection.getHeight() / 2, txt.isVisible() ? 150 : 300)); - lua.setBounds(altEffectsSection.reduced(5)); - obj.setBounds(altEffectsSection.reduced(5)); - txt.setBounds(altEffectsSection.reduced(5)); - } - effects.setBounds(effectsSection.reduced(5)); + settings.sections = sections; + tabs.setBounds(area); repaint(); } @@ -213,20 +196,7 @@ void OscirenderAudioProcessorEditor::updateCodeEditor() { // parsersLock MUST be locked before calling this function void OscirenderAudioProcessorEditor::fileUpdated(juce::String fileName) { - juce::String extension = fileName.fromLastOccurrenceOf(".", true, false); - lua.setVisible(false); - obj.setVisible(false); - txt.setVisible(false); - if (fileName.isEmpty()) { - // do nothing - } else if (extension == ".lua") { - lua.setVisible(true); - } else if (extension == ".obj") { - obj.setVisible(true); - } else if (extension == ".txt") { - txt.setVisible(true); - } - main.updateFileLabel(); + settings.fileUpdated(fileName); updateCodeEditor(); } @@ -237,7 +207,7 @@ void OscirenderAudioProcessorEditor::handleAsyncUpdate() { void OscirenderAudioProcessorEditor::changeListenerCallback(juce::ChangeBroadcaster* source) { juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock); initialiseCodeEditors(); - txt.update(); + settings.update(); } void OscirenderAudioProcessorEditor::editPerspectiveFunction(bool enable) { @@ -310,7 +280,7 @@ bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) { bool consumeKey2 = true; if (key.isKeyCode(juce::KeyPress::escapeKey)) { - obj.disableMouseRotation(); + settings.disableMouseRotation(); } else if (key.getModifiers().isCommandDown() && key.getModifiers().isShiftDown() && key.getKeyCode() == 'S') { saveProjectAs(); } else if (key.getModifiers().isCommandDown() && key.getKeyCode() == 'S') { diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 149d0abd..eafa853b 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -2,11 +2,8 @@ #include #include "PluginProcessor.h" -#include "EffectsComponent.h" -#include "MainComponent.h" -#include "LuaComponent.h" -#include "ObjComponent.h" -#include "TxtComponent.h" +#include "SettingsComponent.h" +#include "MidiComponent.h" #include "components/VolumeComponent.h" #include "components/MainMenuBarModel.h" #include "LookAndFeel.h" @@ -41,11 +38,9 @@ public: private: OscirenderAudioProcessor& audioProcessor; - MainComponent main{audioProcessor, *this}; - LuaComponent lua{audioProcessor, *this}; - ObjComponent obj{audioProcessor, *this}; - TxtComponent txt{audioProcessor, *this}; - EffectsComponent effects{audioProcessor, *this}; + juce::TabbedComponent tabs{juce::TabbedButtonBar::TabsAtTop}; + MidiComponent midi{audioProcessor, *this}; + SettingsComponent settings{audioProcessor, *this}; VolumeComponent volume{audioProcessor}; std::vector> codeDocuments; std::vector> codeEditors; diff --git a/Source/SettingsComponent.cpp b/Source/SettingsComponent.cpp new file mode 100644 index 00000000..ff4ca9af --- /dev/null +++ b/Source/SettingsComponent.cpp @@ -0,0 +1,69 @@ +#include "SettingsComponent.h" +#include "PluginEditor.h" + +SettingsComponent::SettingsComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) { + addAndMakeVisible(effects); + addAndMakeVisible(main); + addChildComponent(lua); + addChildComponent(obj); + addChildComponent(txt); +} + + +void SettingsComponent::resized() { + auto area = getLocalBounds(); + auto effectsSection = area.removeFromRight(1.2 * pluginEditor.getWidth() / sections); + area.removeFromLeft(5); + area.removeFromRight(3); + area.removeFromTop(5); + area.removeFromBottom(5); + + main.setBounds(area); + if (lua.isVisible() || obj.isVisible() || txt.isVisible()) { + int height = txt.isVisible() ? 150 : 300; + auto altEffectsSection = effectsSection.removeFromBottom(juce::jmin(effectsSection.getHeight() / 2, height)); + altEffectsSection.removeFromTop(3); + altEffectsSection.removeFromLeft(2); + altEffectsSection.removeFromRight(5); + altEffectsSection.removeFromBottom(5); + + lua.setBounds(altEffectsSection); + obj.setBounds(altEffectsSection); + txt.setBounds(altEffectsSection); + + effectsSection.removeFromBottom(2); + } else { + effectsSection.removeFromBottom(5); + } + + effectsSection.removeFromLeft(2); + effectsSection.removeFromRight(5); + effectsSection.removeFromTop(5); + effects.setBounds(effectsSection); +} + +void SettingsComponent::fileUpdated(juce::String fileName) { + juce::String extension = fileName.fromLastOccurrenceOf(".", true, false); + lua.setVisible(false); + obj.setVisible(false); + txt.setVisible(false); + if (fileName.isEmpty()) { + // do nothing + } else if (extension == ".lua") { + lua.setVisible(true); + } else if (extension == ".obj") { + obj.setVisible(true); + } else if (extension == ".txt") { + txt.setVisible(true); + } + main.updateFileLabel(); + resized(); +} + +void SettingsComponent::update() { + txt.update(); +} + +void SettingsComponent::disableMouseRotation() { + obj.disableMouseRotation(); +} diff --git a/Source/SettingsComponent.h b/Source/SettingsComponent.h new file mode 100644 index 00000000..ab96db64 --- /dev/null +++ b/Source/SettingsComponent.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include "PluginProcessor.h" +#include "MainComponent.h" +#include "LuaComponent.h" +#include "ObjComponent.h" +#include "TxtComponent.h" +#include "EffectsComponent.h" + +class OscirenderAudioProcessorEditor; +class SettingsComponent : public juce::Component { +public: + SettingsComponent(OscirenderAudioProcessor&, OscirenderAudioProcessorEditor&); + + void resized() override; + void fileUpdated(juce::String fileName); + void update(); + void disableMouseRotation(); + + int sections = 2; +private: + OscirenderAudioProcessor& audioProcessor; + OscirenderAudioProcessorEditor& pluginEditor; + + MainComponent main{audioProcessor, pluginEditor}; + LuaComponent lua{audioProcessor, pluginEditor}; + ObjComponent obj{audioProcessor, pluginEditor}; + TxtComponent txt{audioProcessor, pluginEditor}; + EffectsComponent effects{audioProcessor, pluginEditor}; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SettingsComponent) +}; \ No newline at end of file diff --git a/osci-render.jucer b/osci-render.jucer index 29004872..594ea79b 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -382,6 +382,9 @@ + + @@ -413,6 +416,10 @@ file="Source/PluginProcessor.cpp"/> + +