ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToControl,
                                                  const String& name)
    : PropertyComponent (name),
      choices ({ "Enabled", "Disabled" })
{
    valueWithDefault = &valueToControl;

    createComboBoxWithDefault (valueWithDefault->getDefault() ? "Enabled" : "Disabled");

    comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueWithDefault,
                                                                                       { true, false })));

    valueWithDefault->onDefaultChange = [this]
    {
        auto selectedId = comboBox.getSelectedId();

        comboBox.clear();
        createComboBoxWithDefault (valueWithDefault->getDefault() ? "Enabled" : "Disabled");

        comboBox.setSelectedId (selectedId);
    };
}
ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToControl,
                                                  const String& name,
                                                  const StringArray& choiceList,
                                                  const Array<var>& correspondingValues)
    : ChoicePropertyComponent (name, choiceList, correspondingValues)
{
    valueWithDefault = &valueToControl;

    createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueWithDefault->getDefault())]);

    comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueWithDefault,
                                                                                        correspondingValues)));

    valueWithDefault->onDefaultChange = [this, choiceList, correspondingValues]
    {
        auto selectedId = comboBox.getSelectedId();

        comboBox.clear();
        createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueWithDefault->getDefault())]);

        comboBox.setSelectedId (selectedId);
    };
}