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) {
|
2024-09-12 22:09:54 +00:00
|
|
|
effectComponent = std::make_shared<EffectComponent>(effect);
|
2023-07-04 13:58:36 +00:00
|
|
|
|
|
|
|
effectComponent->slider.onValueChange = [this, &effect, &p] {
|
|
|
|
effect.setValue(effectComponent->slider.getValue());
|
|
|
|
};
|
|
|
|
|
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-21 10:08:55 +00:00
|
|
|
return audioProcessor.luaEffects.size();
|
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) {
|
2023-09-07 21:04:08 +00:00
|
|
|
// TODO: We should REALLY be locking here but it causes a deadlock :( works fine without.....
|
|
|
|
// juce::SpinLock::ScopedLockType lock1(audioProcessor.effectsLock);
|
2023-07-21 10:08:55 +00:00
|
|
|
std::unique_ptr<LuaListComponent> item(dynamic_cast<LuaListComponent*>(existingComponentToUpdate));
|
|
|
|
if (juce::isPositiveAndBelow(rowNum, getNumRows())) {
|
|
|
|
item = std::make_unique<LuaListComponent>(audioProcessor, *audioProcessor.luaEffects[rowNum]);
|
2023-07-02 20:00:14 +00:00
|
|
|
}
|
2023-07-21 10:08:55 +00:00
|
|
|
return item.release();
|
2023-07-02 20:00:14 +00:00
|
|
|
}
|