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

Method ADSRDisplay

Source/ADSRDisplay.cpp:36–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34ADSRDisplay::DisplayMode ADSRDisplay::sDisplayMode = ADSRDisplay::kDisplayEnvelope;
35
36ADSRDisplay::ADSRDisplay(IDrawableModule* owner, const char* name, int x, int y, int w, int h, ::ADSR* adsr)
37: mWidth(w)
38, mHeight(h)
39, mAdsr(adsr)
40{
41 assert(owner);
42 SetName(name);
43 SetPosition(x, y);
44 owner->AddUIControl(this);
45 SetParent(owner);
46
47 IFloatSliderListener* floatListener = dynamic_cast<IFloatSliderListener*>(owner);
48 assert(floatListener); //make anything that uses an ADSRDisplay a FloatSliderListener for these sliders
49 if (floatListener)
50 {
51 int sliderHeight = h / 4;
52 mASlider = new FloatSlider(floatListener, (std::string(name) + "A").c_str(), x, y, w, sliderHeight, &(mAdsr->GetA()), 0.001f, 1000);
53 mDSlider = new FloatSlider(floatListener, (std::string(name) + "D").c_str(), x, y + sliderHeight, w, sliderHeight, &(mAdsr->GetD()), 0.001f, 1000);
54 mSSlider = new FloatSlider(floatListener, (std::string(name) + "S").c_str(), x, y + sliderHeight * 2, w, sliderHeight, &(mAdsr->GetS()), 0, 1);
55 mRSlider = new FloatSlider(floatListener, (std::string(name) + "R").c_str(), x, y + sliderHeight * 3, w, sliderHeight, &(mAdsr->GetR()), 0.001f, 1000);
56
57 mASlider->SetMode(FloatSlider::kSquare);
58 mDSlider->SetMode(FloatSlider::kSquare);
59 mRSlider->SetMode(FloatSlider::kSquare);
60
61 mASlider->SetShowName(false);
62 mDSlider->SetShowName(false);
63 mSSlider->SetShowName(false);
64 mRSlider->SetShowName(false);
65
66 UpdateSliderVisibility();
67 }
68}
69
70ADSRDisplay::~ADSRDisplay()
71{

Callers

nothing calls this directly

Calls 3

AddUIControlMethod · 0.80
SetModeMethod · 0.45
SetShowNameMethod · 0.45

Tested by

no test coverage detected