diff --git a/src/common/SurgePatch.cpp b/src/common/SurgePatch.cpp index 31fd18f509e..a39fe690377 100644 --- a/src/common/SurgePatch.cpp +++ b/src/common/SurgePatch.cpp @@ -531,6 +531,18 @@ SurgePatch::SurgePatch(SurgeStorage *storage) } } lfoPhaseName; + // Assign the dynamic deactivation handlers + static struct OscAudioInDeact : public ParameterDynamicDeactivationFunction + { + const bool getValue(const Parameter *p) const override + { + auto cge = p->ctrlgroup_entry; + auto osc = &(p->storage->getPatch().scene[p->scene - 1].osc[cge]); + + return osc->type.val.i == ot_audioinput; + } + } oscAudioInDeact; + static struct LfoRatePhaseDeact : public ParameterDynamicDeactivationFunction { const bool getValue(const Parameter *p) const override @@ -538,8 +550,12 @@ SurgePatch::SurgePatch(SurgeStorage *storage) auto cge = p->ctrlgroup_entry - ms_lfo1; auto lf = &(p->storage->getPatch().scene[p->scene - 1].lfo[cge]); auto res = lf->shape.val.i == lt_envelope; + if (!res && p->can_deactivate()) + { return p->deactivated; + } + return res; } } lfoRatePhaseDeact; @@ -551,18 +567,30 @@ SurgePatch::SurgePatch(SurgeStorage *storage) auto cge = p->ctrlgroup_entry - ms_lfo1; auto lf = &(p->storage->getPatch().scene[p->scene - 1].lfo[cge]); auto res = lf->delay.deactivated; + return res; } + Parameter *getPrimaryDeactivationDriver(const Parameter *p) const override { auto cge = p->ctrlgroup_entry - ms_lfo1; auto lf = &(p->storage->getPatch().scene[p->scene - 1].lfo[cge]); + return &(lf->delay); } } lfoEnvelopeDeact; for (int sc = 0; sc < n_scenes; ++sc) { + // TODO: Don't forget to add osc phase here once we add it in XT 2.0! + for (int o = 0; o < n_oscs; ++o) + { + scene[sc].osc[o].pitch.dynamicDeactivation = &oscAudioInDeact; + scene[sc].osc[o].octave.dynamicDeactivation = &oscAudioInDeact; + scene[sc].osc[o].keytrack.dynamicDeactivation = &oscAudioInDeact; + scene[sc].osc[o].retrigger.dynamicDeactivation = &oscAudioInDeact; + } + for (int lf = 0; lf < n_lfos; ++lf) { scene[sc].lfo[lf].start_phase.dynamicName = &lfoPhaseName; @@ -570,8 +598,10 @@ SurgePatch::SurgePatch(SurgeStorage *storage) scene[sc].lfo[lf].rate.dynamicDeactivation = &lfoRatePhaseDeact; auto *curr = &(scene[sc].lfo[lf].delay), *end = &(scene[sc].lfo[lf].release); + curr->deactivated = false; curr++; // we don't want to apply it to delay + while (curr <= end) { curr->dynamicDeactivation = &lfoEnvelopeDeact; diff --git a/src/surge-xt/gui/SurgeGUIEditor.cpp b/src/surge-xt/gui/SurgeGUIEditor.cpp index 762f917ac3b..50dfbfe2fb5 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.cpp +++ b/src/surge-xt/gui/SurgeGUIEditor.cpp @@ -4809,6 +4809,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr( juceSkinComponents[skinCtrl->sessionid].get()); } + if (skinCtrl->defaultComponent == Surge::Skin::Components::MultiSwitch) { auto rect = juce::Rectangle(skinCtrl->x, skinCtrl->y, skinCtrl->w, skinCtrl->h); @@ -4872,6 +4873,8 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrsetDeactivated(p->appears_deactivated()); + auto fval = p->get_value_f01(); if (p->ctrltype == ct_scenemode) @@ -4910,22 +4913,14 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrgetControlGroupLayer(cg), *hsw); @@ -4953,9 +4948,10 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrdefaultComponent == Surge::Skin::Components::Switch) { auto rect = juce::Rectangle(skinCtrl->x, skinCtrl->y, skinCtrl->w, skinCtrl->h); @@ -4965,6 +4961,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr(skinCtrl->sessionid); hsw->setStorage(&(synth->storage)); + if (p) { addAndMakeVisibleWithTrackingInCG(p->ctrlgroup, *hsw); @@ -5006,9 +5003,11 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr= 0) nonmod_param[paramIndex] = hsw.get(); + if (p) { hsw->setValue(p->get_value_f01()); + hsw->setDeactivated(p->appears_deactivated()); // Carry over this filter type special case from the default control path if (p->ctrltype == ct_filtersubtype) @@ -5044,6 +5043,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrsessionid].get()); } } + if (skinCtrl->defaultComponent == Surge::Skin::Components::LFODisplay) { if (!p) @@ -5120,6 +5120,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrdefaultComponent == Surge::Skin::Components::FxMenu) { if (!fxMenu) @@ -5240,6 +5241,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrdefaultComponent == Surge::Skin::Components::FilterSelector) { // Obviously exposing this widget as a controllable widget would be better @@ -5337,6 +5339,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr( juceSkinComponents[skinCtrl->sessionid].get()); } + if (skinCtrl->defaultComponent == Surge::Skin::Components::WaveShaperSelector) { // Obviously exposing this widget as a controllable widget would be better @@ -5370,9 +5373,11 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr(waveshaperSelector.get()); } + if (skinCtrl->ultimateparentclassname != Surge::GUI::NoneClassName) - std::cout << "Unable to make control with upc " << skinCtrl->ultimateparentclassname + std::cout << "Unable to make control with UPC " << skinCtrl->ultimateparentclassname << std::endl; + return nullptr; } diff --git a/src/surge-xt/gui/widgets/ModulatableControlInterface.h b/src/surge-xt/gui/widgets/ModulatableControlInterface.h index 4913d9367d1..7060de11060 100644 --- a/src/surge-xt/gui/widgets/ModulatableControlInterface.h +++ b/src/surge-xt/gui/widgets/ModulatableControlInterface.h @@ -118,7 +118,7 @@ struct ModulatableControlInterface virtual float getModValue() const { return modValue; } float modValue{0.f}; - /* Deativation can occur by a function or by a value */ + /* Deactivation can occur by a function or by a value */ virtual void setDeactivatedFn(std::function f) { hasDeactivatedFn = true; diff --git a/src/surge-xt/gui/widgets/MultiSwitch.cpp b/src/surge-xt/gui/widgets/MultiSwitch.cpp index d59c24c73bf..8d7dc9492d3 100644 --- a/src/surge-xt/gui/widgets/MultiSwitch.cpp +++ b/src/surge-xt/gui/widgets/MultiSwitch.cpp @@ -40,8 +40,15 @@ void MultiSwitch::paint(juce::Graphics &g) auto y = -valueToOff(value) * heightOfOneImage; auto t = juce::AffineTransform().translated(0, y); + float activationOpacity = 1.0; + + if (isDeactivated) + { + activationOpacity = 0.5; + } + g.reduceClipRegion(getLocalBounds()); - switchD->draw(g, 1.0, t); + switchD->draw(g, activationOpacity, t); if (isHovered) { @@ -49,14 +56,14 @@ void MultiSwitch::paint(juce::Graphics &g) if (iv == hoverSelection && hoverOnSwitchD) { - hoverOnSwitchD->draw(g, 1.0, t); + hoverOnSwitchD->draw(g, activationOpacity, t); } else if (hoverSwitchD) { auto y2 = hoverSelection + frameOffset; auto t2 = juce::AffineTransform().translated(0, -y2 * heightOfOneImage); - hoverSwitchD->draw(g, 1.0, t2); + hoverSwitchD->draw(g, activationOpacity, t2); } } } diff --git a/src/surge-xt/gui/widgets/MultiSwitch.h b/src/surge-xt/gui/widgets/MultiSwitch.h index 2c562c5542d..de5ed9d463a 100644 --- a/src/surge-xt/gui/widgets/MultiSwitch.h +++ b/src/surge-xt/gui/widgets/MultiSwitch.h @@ -110,6 +110,9 @@ struct MultiSwitch : public juce::Component, void updateAccessibleStateOnUserValueChange() override; std::unique_ptr createAccessibilityHandler() override; + bool isDeactivated{false}; + void setDeactivated(bool b) { isDeactivated = b; } + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MultiSwitch); }; diff --git a/src/surge-xt/gui/widgets/Switch.cpp b/src/surge-xt/gui/widgets/Switch.cpp index d80dae7458f..ff6f8e60650 100644 --- a/src/surge-xt/gui/widgets/Switch.cpp +++ b/src/surge-xt/gui/widgets/Switch.cpp @@ -41,14 +41,21 @@ void Switch::paint(juce::Graphics &g) y = -getIntegerValue() * getLocalBounds().getHeight(); } + float activationOpacity = 1.0; + + if (isDeactivated) + { + activationOpacity = 0.35; + } + auto t = juce::AffineTransform().translated(0, y); g.reduceClipRegion(getLocalBounds()); - switchD->draw(g, 1.0, t); + switchD->draw(g, activationOpacity, t); if (isHovered && hoverSwitchD) { - hoverSwitchD->draw(g, 1.0, t); + hoverSwitchD->draw(g, activationOpacity, t); } } diff --git a/src/surge-xt/gui/widgets/Switch.h b/src/surge-xt/gui/widgets/Switch.h index d82dd6a9099..f061c71080f 100644 --- a/src/surge-xt/gui/widgets/Switch.h +++ b/src/surge-xt/gui/widgets/Switch.h @@ -109,6 +109,9 @@ struct Switch : public juce::Component, public WidgetBaseMixin std::unique_ptr createAccessibilityHandler() override; + bool isDeactivated{false}; + void setDeactivated(bool b) { isDeactivated = b; } + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Switch); }; } // namespace Widgets