alphaosc/plugin/ui.cpp
Gordon JC Pearce ae581d8c72 gui shows up
2025-01-08 01:24:12 +00:00

113 lines
3.4 KiB
C++

#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::whiteData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA);
xSliderSqrMode = new ImageSlider(this, whiteSlider);
xSliderSqrMode->setId(AlphaOsc::pSqrMode);
xSliderSqrMode->setStartPos(25, 84);
xSliderSqrMode->setEndPos(25, 20);
xSliderSqrMode->setRange(0, 4.0f);
xSliderSqrMode->setCallback(this);
xSliderSawMode = new ImageSlider(this, whiteSlider);
xSliderSawMode->setId(AlphaOsc::pSawMode);
xSliderSawMode->setStartPos(80, 117);
xSliderSawMode->setEndPos(80, 36);
xSliderSawMode->setRange(0, 5.0f);
xSliderSawMode->setCallback(this);
xSliderSubMode = new ImageSlider(this, whiteSlider);
xSliderSubMode->setId(AlphaOsc::pSubMode);
xSliderSubMode->setStartPos(135, 117);
xSliderSubMode->setEndPos(135, 36);
xSliderSubMode->setRange(0, 5.0f);
xSliderSubMode->setCallback(this);
xSliderSubLevel = new ImageSlider(this, whiteSlider);
xSliderSubLevel->setId(AlphaOsc::pSubLevel);
xSliderSubLevel->setStartPos(195, 117);
xSliderSubLevel->setEndPos(195, 36);
xSliderSubLevel->setRange(0, 1.0f);
xSliderSubLevel->setCallback(this);
xSliderPWMDepth = new ImageSlider(this, whiteSlider);
xSliderPWMDepth->setId(AlphaOsc::pPWMDepth);
xSliderPWMDepth->setStartPos(265, 117);
xSliderPWMDepth->setEndPos(265, 36);
xSliderPWMDepth->setRange(0, 1.0f);
xSliderPWMDepth->setCallback(this);
xSliderPWMRate = new ImageSlider(this, whiteSlider);
xSliderPWMRate->setId(AlphaOsc::pPWMRate);
xSliderPWMRate->setStartPos(305, 117);
xSliderPWMRate->setEndPos(305, 36);
xSliderPWMRate->setRange(0, 1.0f);
xSliderPWMRate->setCallback(this);
}
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) {
printf("dragstarted on %d\n", slider->getId());
editParameter(slider->getId(), true);
}
void DistrhoUIAlphaOsc::imageSliderDragFinished(ImageSlider* slider) {
printf("dragfinished on %d\n", slider->getId());
editParameter(slider->getId(), false);
}
void DistrhoUIAlphaOsc::imageSliderValueChanged(ImageSlider* slider, float value) {
printf("%f\n", value);
printf("valuechanged on %d\n", slider->getId());
setParameterValue(slider->getId(), value);
}
void DistrhoUIAlphaOsc::onDisplay() {
const GraphicsContext& context(getGraphicsContext());
fImgBackground.draw(context);
};
UI* createUI() {
return new DistrhoUIAlphaOsc();
}
END_NAMESPACE_DISTRHO