Question on dynamic param labels

I have a slider and based on some conditions I"d like to present the label of mouse-over-param event as an integer (1 to 16) or sometimes as a float number (-10.0f to 10.0f or 0.0f to 10.0f). So I want to change the display formatting on the fly.

image

configParam(SLIDER1_PARAM, 1.f, 16.f, 1.f, "Pick channel B");
paramQuantities[SLIDER1_PARAM]->snapEnabled = false;

I just can’t find the way… was it a paramQuantities trick?

If you make a custom param quantity you can have it display whatever you want. That’s the “old” way of changing the display:

    const auto numModes = Comp::modes().size();
    class ModeParam : public ParamQuantity {
    public:
        std::string getDisplayValueString() override {
            int value = int((std::round(getValue())));
            return ((value >= 0) && value < int(labels.size())) ? labels[value] : "";
        }

    private:
        std::vector<std::string> labels = Comp::modes();
    };
    this->configParam<ModeParam>(Comp::MODE_PARAM, 0, numModes - 1, 0, "Arpeggiator Mode");

I’m sure your existing module has some calls to configParam - just make your own and use that as the template argument.

Looks fine but you don’t need to store Comp::modes() in a member field. Static storage is fine.

oh, for sure. I don’t know if that’s old code… lots of times I do it like that because I have unit tests for Comp, but the way I do it I can’t unit test the module or the widget. I think Comp::modes is a static function on the class, so kind of same thing?