feat: add int slider, fix float slider rang

This commit is contained in:
parker
2025-08-11 18:39:52 +01:00
parent 5ac023e637
commit 1268de4f97
13 changed files with 249 additions and 67 deletions

View File

@@ -9,18 +9,18 @@
enzo::prm::Parameter::Parameter(Template prmTemplate)
: template_{prmTemplate}
{
floatValues_ = std::vector<bt::floatT>();
floatValues_.reserve(prmTemplate.getSize());
stringValues_ = std::vector<bt::String>(prmTemplate.getSize(), prmTemplate.getDefault().getString());
stringValues_.reserve(prmTemplate.getSize());
const unsigned int templateSize = prmTemplate.getSize();
const unsigned int numDefaults = prmTemplate.getNumDefaults();
floatValues_.reserve(templateSize);
stringValues_.reserve(templateSize);
intValues_.reserve(templateSize);
if(numDefaults==1)
{
floatValues_ = std::vector<bt::floatT>(templateSize, prmTemplate.getDefault().getFloat());
intValues_ = std::vector<bt::intT>(templateSize, prmTemplate.getDefault().getInt());
stringValues_ = std::vector<bt::String>(templateSize, prmTemplate.getDefault().getString());
}
@@ -33,6 +33,7 @@ enzo::prm::Parameter::Parameter(Template prmTemplate)
}
floatValues_.push_back(prmDefault.getFloat());
stringValues_.push_back(prmDefault.getString());
intValues_.push_back(prmDefault.getInt());
}
@@ -51,6 +52,13 @@ enzo::bt::floatT enzo::prm::Parameter::evalFloat(unsigned int index) const
return floatValues_[index];
}
enzo::bt::intT enzo::prm::Parameter::evalInt(unsigned int index) const
{
if(index >= intValues_.size())
throw std::out_of_range("Cannot access index: " + std::to_string(index) + " for parameter: " + getName());
return intValues_[index];
}
enzo::bt::String enzo::prm::Parameter::evalString(unsigned int index) const
{
if(index >= stringValues_.size())
@@ -66,6 +74,14 @@ enzo::prm::Type enzo::prm::Parameter::getType() const
}
void enzo::prm::Parameter::setInt(bt::intT value, unsigned int index)
{
if(index >= intValues_.size())
throw std::out_of_range("Cannot access index: " + std::to_string(index) + " for parameter: " + getName());
intValues_[index] = value;
valueChanged();
}
void enzo::prm::Parameter::setFloat(bt::floatT value, unsigned int index)
{
if(index >= floatValues_.size())