2013-09-09 16:14:43 +00:00
|
|
|
#include "EnumFloatParameter.h"
|
|
|
|
|
|
|
|
|
|
|
|
EnumFloatParameter::EnumFloatParameter(String name, StringArray values)
|
|
|
|
:FloatParameter(name)
|
|
|
|
{
|
|
|
|
this->values = values;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EnumFloatParameter::~EnumFloatParameter(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int EnumFloatParameter::getParameterIndex(void)
|
|
|
|
{
|
|
|
|
int i = (int)(this->value * values.size());
|
|
|
|
if (i >= values.size())
|
|
|
|
i = values.size() - 1;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2013-09-12 15:21:30 +00:00
|
|
|
void EnumFloatParameter::setParameterIndex(int i)
|
|
|
|
{
|
|
|
|
this->value = (float)i/(float)values.size();
|
|
|
|
if (this->value < 0.0f)
|
|
|
|
this->value = 0.0f;
|
|
|
|
else if (this->value > 1.0f)
|
|
|
|
this->value = 1.0f;
|
|
|
|
}
|
|
|
|
|
2013-09-09 16:14:43 +00:00
|
|
|
String EnumFloatParameter::getParameterText(void)
|
|
|
|
{
|
|
|
|
return values[this->getParameterIndex()];
|
|
|
|
}
|