osci-render/Source/components/LuaListComponent.cpp

46 wiersze
1.6 KiB
C++
Czysty Zwykły widok Historia

#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);
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());
};
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;
}
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) {
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]);
}
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>("+");
item->onClick = [this]() {
2023-07-04 13:58:36 +00:00
audioProcessor.addLuaSlider();
listBox.updateContent();
};
return item.release();
}
}