Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(XT 1.1) Make certain osc controls semitransparent for Audio In #5766

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/common/SurgePatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,31 @@ 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
{
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;
Expand All @@ -551,27 +567,41 @@ 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;
scene[sc].lfo[lf].start_phase.dynamicDeactivation = &lfoRatePhaseDeact;
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;
Expand Down
27 changes: 16 additions & 11 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4797,6 +4797,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
return dynamic_cast<Surge::GUI::IComponentTagValue *>(
juceSkinComponents[skinCtrl->sessionid].get());
}

if (skinCtrl->defaultComponent == Surge::Skin::Components::MultiSwitch)
{
auto rect = juce::Rectangle<int>(skinCtrl->x, skinCtrl->y, skinCtrl->w, skinCtrl->h);
Expand Down Expand Up @@ -4860,6 +4861,8 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control

if (p)
{
hsw->setDeactivated(p->appears_deactivated());

auto fval = p->get_value_f01();

if (p->ctrltype == ct_scenemode)
Expand Down Expand Up @@ -4898,22 +4901,14 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
case tag_mp_jogwaveshape:
cg = cg_FILTER;
break;

/* keep these up top
case tag_mp_category:
case tag_mp_patch:
case tag_store:
cg = endCG;
addToGlobalControls = true;
break; */
case tag_mp_jogfx:
cg = cg_FX;
break;

default:
cg = endCG;
break;
}

if (cg != endCG)
{
addAndMakeVisibleWithTracking(frame->getControlGroupLayer(cg), *hsw);
Expand Down Expand Up @@ -4941,9 +4936,10 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
}
else
{
std::cout << "Can't get a CHSwitch2 BG" << std::endl;
std::cout << "Can't get a MultiSwitch background" << std::endl;
}
}

if (skinCtrl->defaultComponent == Surge::Skin::Components::Switch)
{
auto rect = juce::Rectangle<int>(skinCtrl->x, skinCtrl->y, skinCtrl->w, skinCtrl->h);
Expand All @@ -4953,6 +4949,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
{
auto hsw = componentForSkinSession<Surge::Widgets::Switch>(skinCtrl->sessionid);
hsw->setStorage(&(synth->storage));

if (p)
{
addAndMakeVisibleWithTrackingInCG(p->ctrlgroup, *hsw);
Expand Down Expand Up @@ -4994,9 +4991,11 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control

if (paramIndex >= 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)
Expand Down Expand Up @@ -5032,6 +5031,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
juceSkinComponents[skinCtrl->sessionid].get());
}
}

if (skinCtrl->defaultComponent == Surge::Skin::Components::LFODisplay)
{
if (!p)
Expand Down Expand Up @@ -5108,6 +5108,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
addAndMakeVisibleWithTrackingInCG(cg_OSC, *oscMenu);
return oscMenu.get();
}

if (skinCtrl->defaultComponent == Surge::Skin::Components::FxMenu)
{
if (!fxMenu)
Expand Down Expand Up @@ -5228,6 +5229,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
}
return nullptr;
}

if (skinCtrl->defaultComponent == Surge::Skin::Components::FilterSelector)
{
// Obviously exposing this widget as a controllable widget would be better
Expand Down Expand Up @@ -5325,6 +5327,7 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
return dynamic_cast<Surge::GUI::IComponentTagValue *>(
juceSkinComponents[skinCtrl->sessionid].get());
}

if (skinCtrl->defaultComponent == Surge::Skin::Components::WaveShaperSelector)
{
// Obviously exposing this widget as a controllable widget would be better
Expand Down Expand Up @@ -5358,9 +5361,11 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control

return dynamic_cast<Surge::GUI::IComponentTagValue *>(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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/widgets/ModulatableControlInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool()> f)
{
hasDeactivatedFn = true;
Expand Down
13 changes: 10 additions & 3 deletions src/surge-xt/gui/widgets/MultiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,30 @@ 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)
{
int iv = getIntegerValue();

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);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/surge-xt/gui/widgets/MultiSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ struct MultiSwitch : public juce::Component,
void updateAccessibleStateOnUserValueChange() override;
std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override;

bool isDeactivated{false};
void setDeactivated(bool b) { isDeactivated = b; }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MultiSwitch);
};

Expand Down
11 changes: 9 additions & 2 deletions src/surge-xt/gui/widgets/Switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/surge-xt/gui/widgets/Switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ struct Switch : public juce::Component, public WidgetBaseMixin<Switch>

std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override;

bool isDeactivated{false};
void setDeactivated(bool b) { isDeactivated = b; }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Switch);
};
} // namespace Widgets
Expand Down