Skip to content

Commit 42676cd

Browse files
authored
Add context menu options to restrict the minimum and maximum value of FX parameters in OSARA's FX Parameters dialog. (issue #1195, PR #1212)
1 parent c3529a3 commit 42676cd

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

Diff for: src/paramsUi.cpp

+47-2
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ class ParamsDialog {
685685
} else if (after == Param::AfterOption::invalidateParams) {
686686
this->source->rebuildParams();
687687
this->updateParamList();
688-
} else {
688+
} else if (after == Param::AfterOption::dismiss) {
689689
SendMessage(this->dialog, WM_CLOSE, 0, 0);
690690
}
691691
}
@@ -835,11 +835,16 @@ class FxParam: public Param {
835835
FxParams<ReaperObj>& source;
836836
int fx;
837837
int param;
838+
double unrestrictedMin = 0;
839+
double unrestrictedMax = 0;
838840

839841
public:
840842
FxParam(FxParams<ReaperObj>& source, int fx, int param):
841843
Param(), source(source), fx(fx), param(param) {
842-
source._GetParam(source.obj, fx, param, &this->min, &this->max);
844+
source._GetParam(source.obj, fx, param, &this->unrestrictedMin,
845+
&this->unrestrictedMax);
846+
this->min = this->unrestrictedMin;
847+
this->max = this->unrestrictedMax;
843848
// *FX_GetParameterStepSizes doesn't set these to 0 if it can't fetch them,
844849
// even if it returns true.
845850
this->step = 0;
@@ -895,6 +900,46 @@ class FxParam: public Param {
895900
void setValueFromEdited(const string& text) final {
896901
this->setValue(atof(text.c_str()));
897902
}
903+
904+
Param::MoreOptions getMoreOptions() final {
905+
Param::MoreOptions options;
906+
double val = this->getValue();
907+
if (val == this->min) {
908+
options.push_back({
909+
translate("Unrestrict minimum"),
910+
[this] {
911+
this->min = this->unrestrictedMin;
912+
return Param::AfterOption::nothing;
913+
}
914+
});
915+
} else {
916+
options.push_back({
917+
translate("Restrict minimum to current value"),
918+
[this] {
919+
this->min = this->getValue();
920+
return Param::AfterOption::nothing;
921+
}
922+
});
923+
}
924+
if (val == this->max) {
925+
options.push_back({
926+
translate("Unrestrict maximum"),
927+
[this] {
928+
this->max = this->unrestrictedMax;
929+
return Param::AfterOption::nothing;
930+
}
931+
});
932+
} else {
933+
options.push_back({
934+
translate("Restrict maximum to current value"),
935+
[this] {
936+
this->max = this->getValue();
937+
return Param::AfterOption::nothing;
938+
}
939+
});
940+
}
941+
return options;
942+
}
898943
};
899944

900945
// The possible values for an FX named config param. The first string is the

0 commit comments

Comments
 (0)