kopia lustrzana https://github.com/jameshball/osci-render
Add .lua file settings with infinite (non-working) slider support
rodzic
e4b5545723
commit
2ec4eaba52
|
@ -4,7 +4,7 @@
|
|||
#include "audio/BitCrushEffect.h"
|
||||
#include "PluginProcessor.h"
|
||||
#include "components/DraggableListBox.h"
|
||||
#include "components/MyListComponent.h"
|
||||
#include "components/EffectsListComponent.h"
|
||||
|
||||
class EffectsComponent : public juce::GroupComponent {
|
||||
public:
|
||||
|
@ -18,8 +18,8 @@ private:
|
|||
|
||||
// juce::TextButton addBtn;
|
||||
|
||||
MyListBoxItemData itemData;
|
||||
MyListBoxModel listBoxModel;
|
||||
AudioEffectListBoxItemData itemData;
|
||||
EffectsListBoxModel listBoxModel;
|
||||
DraggableListBox listBox;
|
||||
|
||||
EffectComponent frequency = EffectComponent(0.0, 12000.0, 0.1, 400, "Frequency", "frequency");
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
#include "LuaComponent.h"
|
||||
#include "PluginEditor.h"
|
||||
|
||||
LuaComponent::LuaComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) {
|
||||
LuaComponent::LuaComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor), slidersModel(sliders) {
|
||||
setText(".lua File Settings");
|
||||
|
||||
sliders.setModel(&slidersModel);
|
||||
sliders.setRowHeight(30);
|
||||
addAndMakeVisible(sliders);
|
||||
}
|
||||
|
||||
LuaComponent::~LuaComponent() {
|
||||
}
|
||||
|
||||
void LuaComponent::resized() {
|
||||
auto area = getLocalBounds().reduced(20);
|
||||
sliders.setBounds(area);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <JuceHeader.h>
|
||||
#include "PluginProcessor.h"
|
||||
#include "components/LuaListComponent.h"
|
||||
|
||||
class OscirenderAudioProcessorEditor;
|
||||
class LuaComponent : public juce::GroupComponent {
|
||||
|
@ -14,6 +15,8 @@ private:
|
|||
OscirenderAudioProcessor& audioProcessor;
|
||||
OscirenderAudioProcessorEditor& pluginEditor;
|
||||
|
||||
LuaListBoxModel slidersModel;
|
||||
juce::ListBox sliders;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LuaComponent)
|
||||
};
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
//==============================================================================
|
||||
OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioProcessor& p)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), effects(p), main(p, *this), collapseButton("Collapse", juce::Colours::white, juce::Colours::white, juce::Colours::white)
|
||||
: AudioProcessorEditor(&p), audioProcessor(p), effects(p), main(p, *this), collapseButton("Collapse", juce::Colours::white, juce::Colours::white, juce::Colours::white), lua(p, *this)
|
||||
{
|
||||
// Make sure that before the constructor has finished, you've set the
|
||||
// editor's size to whatever you need it to be.
|
||||
|
@ -20,6 +20,7 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
|
|||
|
||||
addAndMakeVisible(effects);
|
||||
addAndMakeVisible(main);
|
||||
addAndMakeVisible(lua);
|
||||
|
||||
addAndMakeVisible(collapseButton);
|
||||
collapseButton.onClick = [this] {
|
||||
|
@ -74,6 +75,7 @@ void OscirenderAudioProcessorEditor::resized() {
|
|||
}
|
||||
effects.setBounds(area.removeFromRight(getWidth() / sections));
|
||||
main.setBounds(area.removeFromTop(getHeight() / 2));
|
||||
lua.setBounds(area);
|
||||
}
|
||||
|
||||
void OscirenderAudioProcessorEditor::addCodeEditor(int index) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "PluginProcessor.h"
|
||||
#include "EffectsComponent.h"
|
||||
#include "MainComponent.h"
|
||||
#include "LuaComponent.h"
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
@ -33,6 +34,7 @@ private:
|
|||
OscirenderAudioProcessor& audioProcessor;
|
||||
|
||||
MainComponent main;
|
||||
LuaComponent lua;
|
||||
EffectsComponent effects;
|
||||
std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments;
|
||||
std::vector<std::shared_ptr<juce::CodeEditorComponent>> codeEditors;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "MyListComponent.h"
|
||||
#include "EffectsListComponent.h"
|
||||
|
||||
MyListComponent::MyListComponent(DraggableListBox& lb, MyListBoxItemData& data, int rn, std::shared_ptr<EffectComponent> effectComponent) : DraggableListBoxItem(lb, data, rn), effectComponent(effectComponent) {
|
||||
EffectsListComponent::EffectsListComponent(DraggableListBox& lb, AudioEffectListBoxItemData& data, int rn, std::shared_ptr<EffectComponent> effectComponent) : DraggableListBoxItem(lb, data, rn), effectComponent(effectComponent) {
|
||||
addAndMakeVisible(*effectComponent);
|
||||
|
||||
effectComponent->slider.setValue(data.getValue(rn), juce::dontSendNotification);
|
||||
effectComponent->slider.onValueChange = [this] {
|
||||
((MyListBoxItemData&)modelData).setValue(rowNum, this->effectComponent->slider.getValue());
|
||||
((AudioEffectListBoxItemData&)modelData).setValue(rowNum, this->effectComponent->slider.getValue());
|
||||
};
|
||||
|
||||
// check if effect is in audioProcessor enabled effects
|
||||
|
@ -18,13 +18,13 @@ MyListComponent::MyListComponent(DraggableListBox& lb, MyListBoxItemData& data,
|
|||
}
|
||||
effectComponent->selected.setToggleState(isSelected, juce::dontSendNotification);
|
||||
effectComponent->selected.onClick = [this] {
|
||||
((MyListBoxItemData&)modelData).setSelected(rowNum, this->effectComponent->selected.getToggleState());
|
||||
((AudioEffectListBoxItemData&)modelData).setSelected(rowNum, this->effectComponent->selected.getToggleState());
|
||||
};
|
||||
}
|
||||
|
||||
MyListComponent::~MyListComponent() {}
|
||||
EffectsListComponent::~EffectsListComponent() {}
|
||||
|
||||
void MyListComponent::paint(juce::Graphics& g) {
|
||||
void EffectsListComponent::paint(juce::Graphics& g) {
|
||||
DraggableListBoxItem::paint(g);
|
||||
auto bounds = getLocalBounds();
|
||||
bounds.removeFromLeft(20);
|
||||
|
@ -42,18 +42,18 @@ void MyListComponent::paint(juce::Graphics& g) {
|
|||
g.fillEllipse(leftPad + spacing, topPad + 2 * spacing, size, size);
|
||||
}
|
||||
|
||||
void MyListComponent::resized() {
|
||||
void EffectsListComponent::resized() {
|
||||
auto area = getLocalBounds();
|
||||
area.removeFromLeft(20);
|
||||
effectComponent->setBounds(area);
|
||||
}
|
||||
|
||||
juce::Component* MyListBoxModel::refreshComponentForRow(int rowNumber, bool isRowSelected, juce::Component *existingComponentToUpdate) {
|
||||
std::unique_ptr<MyListComponent> item(dynamic_cast<MyListComponent*>(existingComponentToUpdate));
|
||||
juce::Component* EffectsListBoxModel::refreshComponentForRow(int rowNumber, bool isRowSelected, juce::Component *existingComponentToUpdate) {
|
||||
std::unique_ptr<EffectsListComponent> item(dynamic_cast<EffectsListComponent*>(existingComponentToUpdate));
|
||||
if (juce::isPositiveAndBelow(rowNumber, modelData.getNumItems())) {
|
||||
auto data = (MyListBoxItemData&)modelData;
|
||||
auto data = (AudioEffectListBoxItemData&)modelData;
|
||||
std::shared_ptr<EffectComponent> effectComponent = std::make_shared<EffectComponent>(0, 1, 0.01, 0, data.getText(rowNumber), data.getId(rowNumber));
|
||||
item = std::make_unique<MyListComponent>(listBox, (MyListBoxItemData&)modelData, rowNumber, effectComponent);
|
||||
item = std::make_unique<EffectsListComponent>(listBox, (AudioEffectListBoxItemData&)modelData, rowNumber, effectComponent);
|
||||
}
|
||||
return item.release();
|
||||
}
|
|
@ -6,12 +6,12 @@
|
|||
#include "EffectComponent.h"
|
||||
|
||||
// Application-specific data container
|
||||
struct MyListBoxItemData : public DraggableListBoxItemData
|
||||
struct AudioEffectListBoxItemData : public DraggableListBoxItemData
|
||||
{
|
||||
std::vector<std::shared_ptr<Effect>> data;
|
||||
OscirenderAudioProcessor& audioProcessor;
|
||||
|
||||
MyListBoxItemData(OscirenderAudioProcessor& p) : audioProcessor(p) {}
|
||||
AudioEffectListBoxItemData(OscirenderAudioProcessor& p) : audioProcessor(p) {}
|
||||
|
||||
int getNumItems() override {
|
||||
return data.size();
|
||||
|
@ -91,11 +91,11 @@ struct MyListBoxItemData : public DraggableListBoxItemData
|
|||
};
|
||||
|
||||
// Custom list-item Component (which includes item-delete button)
|
||||
class MyListComponent : public DraggableListBoxItem
|
||||
class EffectsListComponent : public DraggableListBoxItem
|
||||
{
|
||||
public:
|
||||
MyListComponent(DraggableListBox& lb, MyListBoxItemData& data, int rn, std::shared_ptr<EffectComponent> effectComponent);
|
||||
~MyListComponent();
|
||||
EffectsListComponent(DraggableListBox& lb, AudioEffectListBoxItemData& data, int rn, std::shared_ptr<EffectComponent> effectComponent);
|
||||
~EffectsListComponent();
|
||||
|
||||
void paint(juce::Graphics& g) override;
|
||||
void resized() override;
|
||||
|
@ -103,15 +103,15 @@ public:
|
|||
protected:
|
||||
std::shared_ptr<EffectComponent> effectComponent;
|
||||
private:
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MyListComponent)
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EffectsListComponent)
|
||||
};
|
||||
|
||||
// Customized DraggableListBoxModel overrides refreshComponentForRow() to ensure that every
|
||||
// list-item Component is a MyListComponent.
|
||||
class MyListBoxModel : public DraggableListBoxModel
|
||||
// list-item Component is a EffectsListComponent.
|
||||
class EffectsListBoxModel : public DraggableListBoxModel
|
||||
{
|
||||
public:
|
||||
MyListBoxModel(DraggableListBox& lb, DraggableListBoxItemData& md)
|
||||
EffectsListBoxModel(DraggableListBox& lb, DraggableListBoxItemData& md)
|
||||
: DraggableListBoxModel(lb, md) {}
|
||||
|
||||
juce::Component* refreshComponentForRow(int, bool, juce::Component*) override;
|
|
@ -0,0 +1,48 @@
|
|||
#include "LuaListComponent.h"
|
||||
|
||||
LuaListComponent::LuaListComponent(int sliderNum) {
|
||||
juce::String sliderName = "";
|
||||
|
||||
sliderNum++;
|
||||
while (sliderNum > 0) {
|
||||
int mod = (sliderNum - 1) % 26;
|
||||
sliderName = (char)(mod + 'A') + sliderName;
|
||||
sliderNum = (sliderNum - mod) / 26;
|
||||
}
|
||||
|
||||
effectComponent = std::make_shared<EffectComponent>(0.0, 1.0, 0.01, 0, "Lua " + sliderName, "lua" + sliderName);
|
||||
effectComponent->setHideCheckbox(true);
|
||||
addAndMakeVisible(*effectComponent);
|
||||
}
|
||||
|
||||
LuaListComponent::~LuaListComponent() {}
|
||||
|
||||
void LuaListComponent::resized() {
|
||||
effectComponent->setBounds(getLocalBounds());
|
||||
}
|
||||
|
||||
void paintListBoxItem(int sliderNum, juce::Graphics& g, int width, int height, bool rowIsSelected) {}
|
||||
|
||||
int LuaListBoxModel::getNumRows() {
|
||||
return numSliders + 1;
|
||||
}
|
||||
|
||||
void LuaListBoxModel::paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected) {}
|
||||
|
||||
juce::Component* LuaListBoxModel::refreshComponentForRow(int sliderNum, bool isRowSelected, juce::Component *existingComponentToUpdate) {
|
||||
if (sliderNum < getNumRows() - 1) {
|
||||
std::unique_ptr<LuaListComponent> item(dynamic_cast<LuaListComponent*>(existingComponentToUpdate));
|
||||
if (juce::isPositiveAndBelow(sliderNum, getNumRows())) {
|
||||
item = std::make_unique<LuaListComponent>(sliderNum);
|
||||
}
|
||||
return item.release();
|
||||
} else {
|
||||
std::unique_ptr<juce::TextButton> item(dynamic_cast<juce::TextButton*>(existingComponentToUpdate));
|
||||
item = std::make_unique<juce::TextButton>("Add");
|
||||
item->onClick = [this]() {
|
||||
numSliders++;
|
||||
listBox.updateContent();
|
||||
};
|
||||
return item.release();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#include <JuceHeader.h>
|
||||
#include "../PluginProcessor.h"
|
||||
#include "../audio/Effect.h"
|
||||
#include "EffectComponent.h"
|
||||
|
||||
class LuaListComponent : public juce::Component
|
||||
{
|
||||
public:
|
||||
LuaListComponent(int sliderNum);
|
||||
~LuaListComponent();
|
||||
|
||||
void resized() override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<EffectComponent> effectComponent;
|
||||
private:
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LuaListComponent)
|
||||
};
|
||||
|
||||
class LuaListBoxModel : public juce::ListBoxModel
|
||||
{
|
||||
public:
|
||||
LuaListBoxModel(juce::ListBox& lb) : listBox(lb) {}
|
||||
|
||||
int getNumRows() override;
|
||||
void paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected) override;
|
||||
juce::Component* refreshComponentForRow(int sliderNum, bool isRowSelected, juce::Component *existingComponentToUpdate) override;
|
||||
|
||||
private:
|
||||
int numSliders = 5;
|
||||
juce::ListBox& listBox;
|
||||
};
|
|
@ -88,10 +88,14 @@
|
|||
file="Source/components/EffectComponent.cpp"/>
|
||||
<FILE id="u4UCwb" name="EffectComponent.h" compile="0" resource="0"
|
||||
file="Source/components/EffectComponent.h"/>
|
||||
<FILE id="M9ImIg" name="MyListComponent.cpp" compile="1" resource="0"
|
||||
file="Source/components/MyListComponent.cpp"/>
|
||||
<FILE id="goyxlC" name="MyListComponent.h" compile="0" resource="0"
|
||||
file="Source/components/MyListComponent.h"/>
|
||||
<FILE id="JG4NCF" name="EffectsListComponent.cpp" compile="1" resource="0"
|
||||
file="Source/components/EffectsListComponent.cpp"/>
|
||||
<FILE id="dcLchL" name="EffectsListComponent.h" compile="0" resource="0"
|
||||
file="Source/components/EffectsListComponent.h"/>
|
||||
<FILE id="qIxm1z" name="LuaListComponent.cpp" compile="1" resource="0"
|
||||
file="Source/components/LuaListComponent.cpp"/>
|
||||
<FILE id="x0Syav" name="LuaListComponent.h" compile="0" resource="0"
|
||||
file="Source/components/LuaListComponent.h"/>
|
||||
</GROUP>
|
||||
<GROUP id="{85A33213-D880-BD92-70D8-1901DA6D23F0}" name="audio">
|
||||
<FILE id="NWuowi" name="BitCrushEffect.cpp" compile="1" resource="0"
|
||||
|
|
Ładowanie…
Reference in New Issue