2023-08-29 19:47:13 +00:00
|
|
|
#include "SettingsComponent.h"
|
|
|
|
#include "PluginEditor.h"
|
|
|
|
|
|
|
|
SettingsComponent::SettingsComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) {
|
|
|
|
addAndMakeVisible(effects);
|
|
|
|
addAndMakeVisible(main);
|
2023-11-25 22:10:36 +00:00
|
|
|
addAndMakeVisible(columnResizerBar);
|
|
|
|
addAndMakeVisible(rowResizerBar);
|
2023-08-29 19:47:13 +00:00
|
|
|
addChildComponent(lua);
|
|
|
|
addChildComponent(obj);
|
|
|
|
addChildComponent(txt);
|
2023-11-25 22:10:36 +00:00
|
|
|
|
|
|
|
columnLayout.setItemLayout(0, -0.1, -0.9, -0.4);
|
2023-12-10 21:57:34 +00:00
|
|
|
columnLayout.setItemLayout(1, 7, 7, 7);
|
2023-11-25 22:10:36 +00:00
|
|
|
columnLayout.setItemLayout(2, -0.1, -0.9, -0.6);
|
|
|
|
|
|
|
|
rowLayout.setItemLayout(0, -0.1, -1.0, -0.63);
|
2023-12-10 21:57:34 +00:00
|
|
|
rowLayout.setItemLayout(1, 7, 7, 7);
|
2023-11-25 22:10:36 +00:00
|
|
|
rowLayout.setItemLayout(2, -0.1, -0.9, -0.37);
|
2023-08-29 19:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SettingsComponent::resized() {
|
|
|
|
auto area = getLocalBounds();
|
|
|
|
area.removeFromLeft(5);
|
2023-11-25 22:10:36 +00:00
|
|
|
area.removeFromRight(5);
|
2023-08-29 19:47:13 +00:00
|
|
|
area.removeFromTop(5);
|
|
|
|
area.removeFromBottom(5);
|
|
|
|
|
2023-11-25 22:10:36 +00:00
|
|
|
juce::Component dummy;
|
2023-08-29 19:47:13 +00:00
|
|
|
|
2023-11-25 22:10:36 +00:00
|
|
|
juce::Component* columns[] = { &main, &columnResizerBar, &dummy };
|
|
|
|
columnLayout.layOutComponents(columns, 3, area.getX(), area.getY(), area.getWidth(), area.getHeight(), false, true);
|
2023-08-29 19:47:13 +00:00
|
|
|
|
2023-11-25 22:10:36 +00:00
|
|
|
juce::Component* effectSettings = nullptr;
|
|
|
|
|
|
|
|
if (lua.isVisible()) {
|
|
|
|
effectSettings = &lua;
|
|
|
|
} else if (obj.isVisible()) {
|
|
|
|
effectSettings = &obj;
|
|
|
|
} else if (txt.isVisible()) {
|
|
|
|
effectSettings = &txt;
|
2023-08-29 19:47:13 +00:00
|
|
|
}
|
|
|
|
|
2023-11-25 22:10:36 +00:00
|
|
|
juce::Component* rows[] = { &effects, &rowResizerBar, effectSettings };
|
|
|
|
|
|
|
|
// use the dummy component to work out the bounds of the rows
|
|
|
|
if (effectSettings != nullptr) {
|
|
|
|
rowLayout.layOutComponents(rows, 3, dummy.getX(), dummy.getY(), dummy.getWidth(), dummy.getHeight(), true, true);
|
|
|
|
} else {
|
|
|
|
effects.setBounds(dummy.getBounds());
|
|
|
|
}
|
2023-08-29 19:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsComponent::fileUpdated(juce::String fileName) {
|
|
|
|
juce::String extension = fileName.fromLastOccurrenceOf(".", true, false);
|
|
|
|
lua.setVisible(false);
|
|
|
|
obj.setVisible(false);
|
|
|
|
txt.setVisible(false);
|
2023-09-10 16:43:37 +00:00
|
|
|
if (fileName.isEmpty() || audioProcessor.objectServerRendering) {
|
2023-08-29 19:47:13 +00:00
|
|
|
// 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();
|
|
|
|
}
|