1
0

Rename placeholder param-info classes

This commit is contained in:
Geraint 2025-06-23 12:39:58 +01:00
parent 64c739b4fc
commit bfb88d6fe1
2 changed files with 32 additions and 18 deletions

View File

@ -519,13 +519,13 @@ struct Plugin : public clap_plugin {
return v;
}
template<class RP>
PInfoPlaceholder range(const char *key, RP &param) {
RangeParamIgnore range(const char *key, RP &param) {
double v = param;
(*this)(key, v);
return {};
}
template<class SP>
PInfoPlaceholder stepped(const char *key, SP &param) {
SteppedParamIgnore stepped(const char *key, SP &param) {
int v = param;
(*this)(key, v);
return {};
@ -540,14 +540,14 @@ struct Plugin : public clap_plugin {
return v;
}
template<class RP>
PInfoPlaceholder range(const char *key, RP &param) {
RangeParamIgnore range(const char *key, RP &param) {
double v = param;
(*this)(key, v);
param = v;
return {};
}
template<class SP>
PInfoPlaceholder stepped(const char *key, SP &param) {
SteppedParamIgnore stepped(const char *key, SP &param) {
int v = param;
(*this)(key, v);
param = v;

View File

@ -95,30 +95,44 @@ namespace stfx {
}
// When we want to ignore parameter info (covers both range and stepped)
struct PInfoPlaceholder {
PInfoPlaceholder & info(const char*, const char*) {
struct RangeParamIgnore {
RangeParamIgnore & info(const char*, const char*) {
return *this;
}
PInfoPlaceholder & info(std::string, std::string) {
RangeParamIgnore & range(double low, double high) {
return *this;
}
template<typename V1, typename V2>
PInfoPlaceholder & range(V1, V2) {
return *this;
}
template<typename V1, typename V2, typename V3>
PInfoPlaceholder & range(V1, V2, V3) {
RangeParamIgnore & range(double low, double mid, double high) {
return *this;
}
/* Always takes a suffix. Units registered first are preferred when formatting values
Optional arguments (any can be omitted if the order is correct):
precision:
int: decimalDigits
display mapping (e.g. for value in Hz, display in kHz):
double displayToValue(double)
double valueToDisplay(double)
valid range:
double low
double high
*/
template<class ...Args>
PInfoPlaceholder & unit(Args...) {
RangeParamIgnore & unit(const char *suffix, Args...) {
return *this;
}
PInfoPlaceholder & exact(double, const char *) {
RangeParamIgnore & exact(double, const char *) {
return *this;
}
};
struct SteppedParamIgnore {
SteppedParamIgnore & info(const char*, const char*) {
return *this;
}
SteppedParamIgnore & range(int low, int high) {
return *this;
}
template<typename ...Args>
PInfoPlaceholder & label(Args ...) {
SteppedParamIgnore & label(Args ...) {
return *this;
}
};
@ -353,12 +367,12 @@ namespace stfx {
std::vector<LibraryParam<int> *> stepParams;
// Add registered parameters to the list
PInfoPlaceholder range(const char *, LibraryParam<double> &param, const char *codeExpr=nullptr) {
RangeParamIgnore range(const char *, LibraryParam<double> &param, const char *codeExpr=nullptr) {
(void)codeExpr;
rangeParams.push_back(&param);
return {};
}
PInfoPlaceholder stepped(const char *, LibraryParam<int> &param, const char *codeExpr=nullptr) {
SteppedParamIgnore stepped(const char *, LibraryParam<int> &param, const char *codeExpr=nullptr) {
(void)codeExpr;
stepParams.push_back(&param);
return {};