kopia lustrzana https://github.com/jameshball/osci-render
Add tabs for main settings and MIDI settings
rodzic
4667019163
commit
8107c521b8
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#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)
|
||||
};
|
||||
|
|
@ -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<int>(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') {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
#include <JuceHeader.h>
|
||||
#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<std::shared_ptr<juce::CodeDocument>> codeDocuments;
|
||||
std::vector<std::shared_ptr<juce::CodeEditorComponent>> codeEditors;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#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)
|
||||
};
|
||||
|
|
@ -382,6 +382,9 @@
|
|||
<FILE id="GKBQ8j" name="MainComponent.cpp" compile="1" resource="0"
|
||||
file="Source/MainComponent.cpp"/>
|
||||
<FILE id="RU8fGr" name="MainComponent.h" compile="0" resource="0" file="Source/MainComponent.h"/>
|
||||
<FILE id="eB92KJ" name="MidiComponent.cpp" compile="1" resource="0"
|
||||
file="Source/MidiComponent.cpp"/>
|
||||
<FILE id="GJqoJa" name="MidiComponent.h" compile="0" resource="0" file="Source/MidiComponent.h"/>
|
||||
<GROUP id="{E6ED85A9-3843-825F-EF48-BCF81E38F8AD}" name="obj">
|
||||
<FILE id="Tyz6WY" name="Camera.cpp" compile="1" resource="0" file="Source/obj/Camera.cpp"/>
|
||||
<FILE id="ix12FT" name="Camera.h" compile="0" resource="0" file="Source/obj/Camera.h"/>
|
||||
|
|
@ -413,6 +416,10 @@
|
|||
file="Source/PluginProcessor.cpp"/>
|
||||
<FILE id="G4mTsK" name="PluginProcessor.h" compile="0" resource="0"
|
||||
file="Source/PluginProcessor.h"/>
|
||||
<FILE id="x57ccs" name="SettingsComponent.cpp" compile="1" resource="0"
|
||||
file="Source/SettingsComponent.cpp"/>
|
||||
<FILE id="Vlmozi" name="SettingsComponent.h" compile="0" resource="0"
|
||||
file="Source/SettingsComponent.h"/>
|
||||
<GROUP id="{92CEA658-C82C-9CEB-15EB-945EF6B6B5C8}" name="shape">
|
||||
<FILE id="iglTFG" name="CircleArc.cpp" compile="1" resource="0" file="Source/shape/CircleArc.cpp"/>
|
||||
<FILE id="T3S8Sg" name="CircleArc.h" compile="0" resource="0" file="Source/shape/CircleArc.h"/>
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue