ControllerLinks.cpp (1987B)
1 #include "ControllerLinks.h" 2 3 #include "VirusEditor.h" 4 5 namespace genericVirusUI 6 { 7 // The only purpose of this class is to provide backwards-compatibility with old skins that do not have their links expressed in the json description file 8 ControllerLinks::ControllerLinks(const VirusEditor& _editor) 9 { 10 std::vector<juce::Slider*> lfoSliderL, lfoSliderR, envVel; 11 std::vector<juce::Button*> lfoToggles; 12 13 _editor.findComponents(lfoSliderL, "LfoOsc1Pitch"); 14 _editor.findComponents(lfoSliderR, "LfoOsc2Pitch"); 15 16 _editor.findComponents(lfoToggles, "Lfo1Link"); 17 if(lfoToggles.empty()) 18 _editor.findComponents(lfoToggles, "LfoOscPitchLink"); 19 20 _editor.findComponents(envVel, "EnvVel"); 21 if(envVel.empty()) 22 _editor.findComponents(envVel, "EnvVelo"); 23 24 auto* linkEnv = _editor.findComponentT<juce::Button>("LinkEnv", false); 25 26 auto* flt1Vel = _editor.findComponentT<juce::Slider>("VelFlt1Freq", false); 27 auto* flt2Vel = _editor.findComponentT<juce::Slider>("VelFlt2Freq", false); 28 29 if(lfoSliderL.size() == 2 && lfoSliderR.size() == 2 && lfoToggles.size() == 2) 30 { 31 for(size_t i=0; i<2; ++i) 32 createLink(lfoSliderL[i], lfoSliderR[i], lfoToggles[i]); 33 } 34 35 if(linkEnv) 36 { 37 if(envVel.size() == 2) 38 createLink(envVel[0], envVel[1], linkEnv); 39 40 if(flt1Vel && flt2Vel) 41 createLink(flt1Vel, flt2Vel, linkEnv); 42 } 43 44 auto* vocModQ = _editor.findComponentT<juce::Slider>("VocModQ", false); 45 auto* vocCarrSpread = _editor.findComponentT<juce::Slider>("VocCarrSpread", false); 46 auto* vocLink = _editor.findComponentT<juce::Button>("VocoderLink", false); 47 48 if(vocModQ && vocCarrSpread && vocLink) 49 createLink(vocModQ, vocCarrSpread, vocLink); 50 } 51 52 void ControllerLinks::createLink(juce::Slider* _a, juce::Slider* _b, juce::Button* _cond) 53 { 54 auto* link = new genericUI::ControllerLink(); 55 link->create(_a, _b, _cond); 56 m_links.emplace_back(link); 57 58 link = new genericUI::ControllerLink(); 59 link->create(_b, _a, _cond); 60 m_links.emplace_back(link); 61 } 62 }