TextPropertyComponent::TextPropertyComponent (ValueWithDefault& valueToControl, const String& name, int maxNumChars, bool multiLine, bool isEditable) : TextPropertyComponent (name, maxNumChars, multiLine, isEditable) { textEditor->getTextValue().referTo (Value (new RemapperValueSourceWithDefault (valueToControl))); textEditor->setTextToDisplayWhenEmpty (valueToControl.getDefault(), 0.5f); valueToControl.onDefaultChange = [this, &valueToControl] { textEditor->setTextToDisplayWhenEmpty (valueToControl.getDefault(), 0.5f); repaint(); }; }
ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToControl, const String& name) : PropertyComponent (name), choices ({ "Enabled", "Disabled" }) { createComboBoxWithDefault (valueToControl.getDefault() ? "Enabled" : "Disabled"); comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueToControl, { true, false }))); valueToControl.onDefaultChange = [this, &valueToControl] { auto selectedId = comboBox.getSelectedId(); comboBox.clear(); createComboBoxWithDefault (valueToControl.getDefault() ? "Enabled" : "Disabled"); comboBox.setSelectedId (selectedId); }; }
ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToControl, const String& name, const StringArray& choiceList, const Array<var>& correspondingValues) : ChoicePropertyComponent (name, choiceList, correspondingValues) { createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueToControl.getDefault())]); comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueToControl, correspondingValues))); valueToControl.onDefaultChange = [this, &valueToControl, choiceList, correspondingValues] { auto selectedId = comboBox.getSelectedId(); comboBox.clear(); createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueToControl.getDefault())]); comboBox.setSelectedId (selectedId); }; }