kopia lustrzana https://github.com/jameshball/osci-render
Ensure min < max always
rodzic
72951d3146
commit
a9e99d336b
|
@ -47,4 +47,4 @@ void EffectsComponent::resized() {
|
|||
|
||||
area.removeFromTop(6);
|
||||
listBox.setBounds(area);
|
||||
}
|
||||
}
|
|
@ -32,12 +32,24 @@ void EffectComponent::componentSetup() {
|
|||
max.textBox.setValue(details.max, juce::dontSendNotification);
|
||||
|
||||
min.textBox.onValueChange = [this]() {
|
||||
effect.details[index].min = min.textBox.getValue();
|
||||
double minValue = min.textBox.getValue();
|
||||
double maxValue = max.textBox.getValue();
|
||||
if (minValue >= maxValue) {
|
||||
minValue = maxValue - effect.details[index].step;
|
||||
min.textBox.setValue(minValue, juce::dontSendNotification);
|
||||
}
|
||||
effect.details[index].min = minValue;
|
||||
slider.setRange(effect.details[index].min, effect.details[index].max, effect.details[index].step);
|
||||
};
|
||||
|
||||
max.textBox.onValueChange = [this]() {
|
||||
effect.details[index].max = max.textBox.getValue();
|
||||
double minValue = min.textBox.getValue();
|
||||
double maxValue = max.textBox.getValue();
|
||||
if (maxValue <= minValue) {
|
||||
maxValue = minValue + effect.details[index].step;
|
||||
max.textBox.setValue(maxValue, juce::dontSendNotification);
|
||||
}
|
||||
effect.details[index].max = maxValue;
|
||||
slider.setRange(effect.details[index].min, effect.details[index].max, effect.details[index].step);
|
||||
};
|
||||
|
||||
|
@ -74,15 +86,15 @@ void EffectComponent::paint(juce::Graphics& g) {
|
|||
}
|
||||
|
||||
void EffectComponent::mouseDown(const juce::MouseEvent& event) {
|
||||
juce::PopupMenu menu;
|
||||
if (event.mods.isPopupMenu()) {
|
||||
juce::PopupMenu menu;
|
||||
|
||||
menu.addCustomItem(1, popupLabel, 200, 30, false);
|
||||
menu.addCustomItem(2, min, 160, 40, false);
|
||||
menu.addCustomItem(3, max, 160, 40, false);
|
||||
menu.addCustomItem(1, popupLabel, 200, 30, false);
|
||||
menu.addCustomItem(2, min, 160, 40, false);
|
||||
menu.addCustomItem(3, max, 160, 40, false);
|
||||
|
||||
menu.showMenuAsync(juce::PopupMenu::Options(), [this](int result) {
|
||||
|
||||
});
|
||||
menu.showMenuAsync(juce::PopupMenu::Options(), [this](int result) {});
|
||||
}
|
||||
}
|
||||
|
||||
void EffectComponent::setComponent(std::shared_ptr<juce::Component> component) {
|
||||
|
|
|
@ -6,35 +6,35 @@ EffectsListComponent::EffectsListComponent(DraggableListBox& lb, AudioEffectList
|
|||
std::shared_ptr<EffectComponent> effectComponent = std::make_shared<EffectComponent>(*effect, i, i == 0);
|
||||
// using weak_ptr to avoid circular reference and memory leak
|
||||
std::weak_ptr<EffectComponent> weakEffectComponent = effectComponent;
|
||||
effectComponent->slider.setValue(details[i].value, juce::dontSendNotification);
|
||||
effectComponent->slider.setValue(details[i].value, juce::dontSendNotification);
|
||||
effectComponent->slider.onValueChange = [this, i, weakEffectComponent] {
|
||||
if (auto effectComponent = weakEffectComponent.lock()) {
|
||||
this->effect->setValue(i, effectComponent->slider.getValue());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
if (i == 0) {
|
||||
bool isSelected = false;
|
||||
if (i == 0) {
|
||||
bool isSelected = false;
|
||||
|
||||
{
|
||||
juce::SpinLock::ScopedLockType lock(data.audioProcessor.effectsLock);
|
||||
// check if effect is in audioProcessor enabled effects
|
||||
for (auto processorEffect : data.audioProcessor.enabledEffects) {
|
||||
if (processorEffect->getId() == effect->getId()) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
{
|
||||
juce::SpinLock::ScopedLockType lock(data.audioProcessor.effectsLock);
|
||||
// check if effect is in audioProcessor enabled effects
|
||||
for (auto processorEffect : data.audioProcessor.enabledEffects) {
|
||||
if (processorEffect->getId() == effect->getId()) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
effectComponent->selected.setToggleState(isSelected, juce::dontSendNotification);
|
||||
}
|
||||
effectComponent->selected.setToggleState(isSelected, juce::dontSendNotification);
|
||||
effectComponent->selected.onClick = [this, weakEffectComponent] {
|
||||
if (auto effectComponent = weakEffectComponent.lock()) {
|
||||
auto data = (AudioEffectListBoxItemData&)modelData;
|
||||
juce::SpinLock::ScopedLockType lock(data.audioProcessor.effectsLock);
|
||||
data.setSelected(rowNum, effectComponent->selected.getToggleState());
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
listModel.addComponent(effectComponent);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue