alphaosc/plugin/ui.cpp

122 lines
3.6 KiB
C++
Raw Normal View History

2025-01-08 01:24:12 +00:00
#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)
{
2025-01-08 11:23:03 +00:00
Image whiteSlider(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA);
2025-01-08 01:24:12 +00:00
xSliderSqrMode = new ImageSlider(this, whiteSlider);
xSliderSqrMode->setId(AlphaOsc::pSqrMode);
2025-01-08 11:23:03 +00:00
xSliderSqrMode->setStartPos(32, 36);
xSliderSqrMode->setEndPos(32, 84);
2025-01-08 02:11:03 +00:00
xSliderSqrMode->setRange(0, 3.0f);
xSliderSqrMode->setInverted(true);
xSliderSqrMode->setStep(1);
2025-01-08 01:24:12 +00:00
xSliderSqrMode->setCallback(this);
xSliderSawMode = new ImageSlider(this, whiteSlider);
xSliderSawMode->setId(AlphaOsc::pSawMode);
2025-01-08 11:23:03 +00:00
xSliderSawMode->setStartPos(87, 36);
xSliderSawMode->setEndPos(87, 117);
2025-01-08 01:24:12 +00:00
xSliderSawMode->setRange(0, 5.0f);
2025-01-08 02:11:03 +00:00
xSliderSawMode->setInverted(true);
xSliderSawMode->setStep(1);
2025-01-08 01:24:12 +00:00
xSliderSawMode->setCallback(this);
xSliderSubMode = new ImageSlider(this, whiteSlider);
xSliderSubMode->setId(AlphaOsc::pSubMode);
2025-01-08 11:23:03 +00:00
xSliderSubMode->setStartPos(142, 36);
xSliderSubMode->setEndPos(1425, 117);
2025-01-08 01:24:12 +00:00
xSliderSubMode->setRange(0, 5.0f);
2025-01-08 02:11:03 +00:00
xSliderSubMode->setInverted(true);
xSliderSubMode->setStep(1);
2025-01-08 01:24:12 +00:00
xSliderSubMode->setCallback(this);
xSliderSubLevel = new ImageSlider(this, whiteSlider);
xSliderSubLevel->setId(AlphaOsc::pSubLevel);
2025-01-08 11:23:03 +00:00
xSliderSubLevel->setStartPos(202, 36);
xSliderSubLevel->setEndPos(202, 117);
2025-01-08 01:24:12 +00:00
xSliderSubLevel->setRange(0, 1.0f);
2025-01-08 02:11:03 +00:00
xSliderSubLevel->setInverted(true);
2025-01-08 01:24:12 +00:00
xSliderSubLevel->setCallback(this);
xSliderPWMDepth = new ImageSlider(this, whiteSlider);
xSliderPWMDepth->setId(AlphaOsc::pPWMDepth);
2025-01-08 11:23:03 +00:00
xSliderPWMDepth->setStartPos(272, 36);
xSliderPWMDepth->setEndPos(272, 117);
2025-01-08 01:24:12 +00:00
xSliderPWMDepth->setRange(0, 1.0f);
2025-01-08 02:11:03 +00:00
xSliderPWMDepth->setInverted(true);
2025-01-08 01:24:12 +00:00
xSliderPWMDepth->setCallback(this);
xSliderPWMRate = new ImageSlider(this, whiteSlider);
xSliderPWMRate->setId(AlphaOsc::pPWMRate);
2025-01-08 11:23:03 +00:00
xSliderPWMRate->setStartPos(312, 36);
xSliderPWMRate->setEndPos(312, 117);
2025-01-08 01:24:12 +00:00
xSliderPWMRate->setRange(0, 1.0f);
2025-01-08 02:11:03 +00:00
xSliderPWMRate->setInverted(true);
2025-01-08 01:24:12 +00:00
xSliderPWMRate->setCallback(this);
2025-01-08 02:11:03 +00:00
// default settings
xSliderSubMode->setValue(2.0f);
2025-01-08 01:24:12 +00:00
}
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