コード例 #1
0
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();
    };
}
コード例 #2
0
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);
    };
}
コード例 #3
0
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);
    };
}