From 2924dd4ac3427245ce541f326c2765ec0d9126b6 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 5 Sep 2023 03:26:12 -0400 Subject: [PATCH] Generate range labels programmatically in createRangeItem(). --- src/plugin.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/plugin.cpp b/src/plugin.cpp index 3affe5a..289564b 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -66,14 +66,12 @@ MenuItem* createRangeItem(std::string label, float* gain, float* offset) { {10.f, -5.f}, {2.f, -1.f}, }; - static const std::vector labels = { - "0V to 10V", - "0V to 5V", - "0V to 1V", - "-10V to 10V", - "-5V to 5V", - "-1V to 1V", - }; + static std::vector labels; + if (labels.empty()) { + for (const Range& range : ranges) { + labels.push_back(string::f("%gV to %gV", range.offset, range.offset + range.gain)); + } + } return createIndexSubmenuItem(label, labels, [=]() {