diff --git a/Source/EffectsComponent.cpp b/Source/EffectsComponent.cpp index 6834c65..60c8868 100644 --- a/Source/EffectsComponent.cpp +++ b/Source/EffectsComponent.cpp @@ -47,4 +47,4 @@ void EffectsComponent::resized() { area.removeFromTop(6); listBox.setBounds(area); -} +} \ No newline at end of file diff --git a/Source/components/EffectComponent.cpp b/Source/components/EffectComponent.cpp index 563da91..6efd3c4 100644 --- a/Source/components/EffectComponent.cpp +++ b/Source/components/EffectComponent.cpp @@ -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 component) { diff --git a/Source/components/EffectsListComponent.cpp b/Source/components/EffectsListComponent.cpp index e82f0bb..9d6acdf 100644 --- a/Source/components/EffectsListComponent.cpp +++ b/Source/components/EffectsListComponent.cpp @@ -6,35 +6,35 @@ EffectsListComponent::EffectsListComponent(DraggableListBox& lb, AudioEffectList std::shared_ptr effectComponent = std::make_shared(*effect, i, i == 0); // using weak_ptr to avoid circular reference and memory leak std::weak_ptr 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); }