#include "ui.hpp" #include "alphaosc.hpp" START_NAMESPACE_DISTRHO namespace Art = Artwork; DistrhoUIAlphaOsc::DistrhoUIAlphaOsc() : UI(Art::bgWidth, Art::bgHeight, true), fImgBackground(Art::bgData, Art::bgWidth, Art::bgHeight, kImageFormatRGB) { Image whiteSlider(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA); xSliderSqrMode = new ImageSlider(this, whiteSlider); xSliderSqrMode->setId(AlphaOsc::pSqrMode); xSliderSqrMode->setStartPos(32, 35); xSliderSqrMode->setEndPos(32, 83); xSliderSqrMode->setRange(0, 3.0f); xSliderSqrMode->setInverted(true); xSliderSqrMode->setStep(1); xSliderSqrMode->setCallback(this); xSliderSawMode = new ImageSlider(this, whiteSlider); xSliderSawMode->setId(AlphaOsc::pSawMode); xSliderSawMode->setStartPos(87, 35); xSliderSawMode->setEndPos(87, 115); xSliderSawMode->setRange(0, 5.0f); xSliderSawMode->setInverted(true); xSliderSawMode->setStep(1); xSliderSawMode->setCallback(this); xSliderSubMode = new ImageSlider(this, whiteSlider); xSliderSubMode->setId(AlphaOsc::pSubMode); xSliderSubMode->setStartPos(142, 35); xSliderSubMode->setEndPos(1425, 115); xSliderSubMode->setRange(0, 5.0f); xSliderSubMode->setInverted(true); xSliderSubMode->setStep(1); xSliderSubMode->setCallback(this); xSliderSubLevel = new ImageSlider(this, whiteSlider); xSliderSubLevel->setId(AlphaOsc::pSubLevel); xSliderSubLevel->setStartPos(202, 35); xSliderSubLevel->setEndPos(202, 115); xSliderSubLevel->setRange(0, 1.0f); xSliderSubLevel->setInverted(true); xSliderSubLevel->setCallback(this); xSliderPWMDepth = new ImageSlider(this, whiteSlider); xSliderPWMDepth->setId(AlphaOsc::pPWMDepth); xSliderPWMDepth->setStartPos(272, 35); xSliderPWMDepth->setEndPos(272, 115); xSliderPWMDepth->setRange(0, 1.0f); xSliderPWMDepth->setInverted(true); xSliderPWMDepth->setCallback(this); xSliderPWMRate = new ImageSlider(this, whiteSlider); xSliderPWMRate->setId(AlphaOsc::pPWMRate); xSliderPWMRate->setStartPos(312, 35); xSliderPWMRate->setEndPos(312, 115); xSliderPWMRate->setRange(0, 1.0f); xSliderPWMRate->setInverted(true); xSliderPWMRate->setCallback(this); // default settings xSliderSubMode->setValue(2.0f); } void DistrhoUIAlphaOsc::parameterChanged(uint32_t index, float value) { switch (index) { case AlphaOsc::pSqrMode: xSliderSqrMode->setValue(value); break; case AlphaOsc::pSawMode: xSliderSawMode->setValue(value); break; case AlphaOsc::pSubMode: xSliderSubMode->setValue(value); break; case AlphaOsc::pSubLevel: xSliderSubLevel->setValue(value); break; case AlphaOsc::pPWMDepth: xSliderPWMDepth->setValue(value); break; case AlphaOsc::pPWMRate: xSliderPWMRate->setValue(value); break; } } void DistrhoUIAlphaOsc::imageSliderDragStarted(ImageSlider* slider) { editParameter(slider->getId(), true); } void DistrhoUIAlphaOsc::imageSliderDragFinished(ImageSlider* slider) { editParameter(slider->getId(), false); } void DistrhoUIAlphaOsc::imageSliderValueChanged(ImageSlider* slider, float value) { setParameterValue(slider->getId(), value); } void DistrhoUIAlphaOsc::onDisplay() { const GraphicsContext& context(getGraphicsContext()); fImgBackground.draw(context); }; UI* createUI() { return new DistrhoUIAlphaOsc(); } END_NAMESPACE_DISTRHO