MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / OnModulatorRepatch

Method OnModulatorRepatch

Source/IModulator.cpp:42–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void IModulator::OnModulatorRepatch()
43{
44 bool wasEmpty = (mTargets[0].mUIControlTarget == nullptr);
45
46 for (size_t i = 0; i < mTargets.size(); ++i)
47 {
48 IUIControl* newTarget = nullptr;
49 if (mTargetCable != nullptr && i < mTargetCable->GetPatchCables().size())
50 newTarget = dynamic_cast<IUIControl*>(mTargetCable->GetPatchCables()[i]->GetTarget());
51 if (newTarget != mTargets[i].mUIControlTarget)
52 {
53 if (mTargets[i].mSliderTarget != nullptr && mTargets[i].mSliderTarget->GetModulator() == this)
54 mTargets[i].mSliderTarget->SetModulator(nullptr); //clear old target's pointer to this
55
56 if (i + 1 < mTargets.size() && newTarget == mTargets[i + 1].mUIControlTarget) //one got deleted, shift the rest down
57 {
58 for (; i < mTargets.size(); ++i)
59 {
60 if (i + 1 < mTargets.size())
61 {
62 mTargets[i].mUIControlTarget = mTargets[i + 1].mUIControlTarget;
63 mTargets[i].mSliderTarget = mTargets[i + 1].mSliderTarget;
64 }
65 else
66 {
67 mTargets[i].mUIControlTarget = nullptr;
68 mTargets[i].mSliderTarget = nullptr;
69 }
70 }
71 break;
72 }
73
74 mTargets[i].mUIControlTarget = newTarget;
75 mTargets[i].mSliderTarget = dynamic_cast<FloatSlider*>(mTargets[i].mUIControlTarget);
76
77 if (newTarget != nullptr)
78 {
79 if (mTargets[i].mSliderTarget != nullptr)
80 {
81 mTargets[i].mSliderTarget->SetModulator(this);
82 if (wasEmpty)
83 InitializeRange(mTargets[i].mSliderTarget->GetValue(), mTargets[i].mUIControlTarget->GetModulationRangeMin(), mTargets[i].mUIControlTarget->GetModulationRangeMax(), mTargets[i].mSliderTarget->GetMode());
84 }
85 else
86 {
87 if (wasEmpty)
88 InitializeRange(mTargets[i].mUIControlTarget->GetValue(), mTargets[i].mUIControlTarget->GetModulationRangeMin(), mTargets[i].mUIControlTarget->GetModulationRangeMax(), FloatSlider::kNormal);
89 }
90 }
91 else
92 {
93 if (i == 0)
94 {
95 if (mMinSlider)
96 mMinSlider->SetVar(&mDummyMin);
97 if (mMaxSlider)
98 mMaxSlider->SetVar(&mDummyMax);
99 }

Callers

nothing calls this directly

Calls 11

sizeMethod · 0.80
GetModulatorMethod · 0.80
SetModulatorMethod · 0.80
GetModeMethod · 0.80
RemoveExtraPollerMethod · 0.80
AddExtraPollerMethod · 0.80
GetTargetMethod · 0.45
GetValueMethod · 0.45
GetModulationRangeMinMethod · 0.45
GetModulationRangeMaxMethod · 0.45
SetVarMethod · 0.45

Tested by

no test coverage detected