2023-07-02 20:00:14 +00:00
|
|
|
#include "LuaListComponent.h"
|
|
|
|
|
2023-07-04 13:58:36 +00:00
|
|
|
LuaListComponent::LuaListComponent(OscirenderAudioProcessor& p, Effect& effect) {
|
|
|
|
effectComponent = std::make_shared<EffectComponent>(0.0, 1.0, 0.01, effect);
|
2023-07-05 11:02:28 +00:00
|
|
|
effectComponent->setCheckboxVisible(false);
|
2023-07-04 13:58:36 +00:00
|
|
|
|
|
|
|
effectComponent->slider.onValueChange = [this, &effect, &p] {
|
|
|
|
effect.setValue(effectComponent->slider.getValue());
|
|
|
|
effect.apply(0, Vector2());
|
|
|
|
};
|
|
|
|
|
2023-07-02 20:00:14 +00:00
|
|
|
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() {
|
2023-07-04 13:58:36 +00:00
|
|
|
return audioProcessor.luaEffects.size() + 1;
|
2023-07-02 20:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LuaListBoxModel::paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool rowIsSelected) {}
|
|
|
|
|
2023-07-04 13:58:36 +00:00
|
|
|
juce::Component* LuaListBoxModel::refreshComponentForRow(int rowNum, bool isRowSelected, juce::Component *existingComponentToUpdate) {
|
|
|
|
if (rowNum < getNumRows() - 1) {
|
2023-07-02 20:00:14 +00:00
|
|
|
std::unique_ptr<LuaListComponent> item(dynamic_cast<LuaListComponent*>(existingComponentToUpdate));
|
2023-07-04 13:58:36 +00:00
|
|
|
if (juce::isPositiveAndBelow(rowNum, getNumRows())) {
|
|
|
|
item = std::make_unique<LuaListComponent>(audioProcessor, *audioProcessor.luaEffects[rowNum]);
|
2023-07-02 20:00:14 +00:00
|
|
|
}
|
|
|
|
return item.release();
|
|
|
|
} else {
|
|
|
|
std::unique_ptr<juce::TextButton> item(dynamic_cast<juce::TextButton*>(existingComponentToUpdate));
|
2023-07-04 13:58:36 +00:00
|
|
|
item = std::make_unique<juce::TextButton>("+");
|
2023-07-02 20:00:14 +00:00
|
|
|
item->onClick = [this]() {
|
2023-07-04 13:58:36 +00:00
|
|
|
audioProcessor.addLuaSlider();
|
2023-07-02 20:00:14 +00:00
|
|
|
listBox.updateContent();
|
|
|
|
};
|
|
|
|
return item.release();
|
|
|
|
}
|
|
|
|
}
|