upgrade to JUCE 5.4.3. Remove (probably) unused JUCE modules. Remove VST2 target (it's been end-of-life'd by Steinberg and by JUCE)
This commit is contained in:
@ -71,7 +71,7 @@ public:
|
||||
const String& buttonText);
|
||||
|
||||
/** Destructor. */
|
||||
~BooleanPropertyComponent();
|
||||
~BooleanPropertyComponent() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Called to change the state of the boolean value. */
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
bool triggerOnMouseDown);
|
||||
|
||||
/** Destructor. */
|
||||
~ButtonPropertyComponent();
|
||||
~ButtonPropertyComponent() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Called when the user clicks the button.
|
||||
@ -66,7 +66,7 @@ public:
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void refresh();
|
||||
void refresh() override;
|
||||
|
||||
private:
|
||||
TextButton button;
|
||||
|
@ -73,9 +73,9 @@ class ChoicePropertyComponent::RemapperValueSourceWithDefault : public Value:
|
||||
private Value::Listener
|
||||
{
|
||||
public:
|
||||
RemapperValueSourceWithDefault (ValueWithDefault& vwd, const Array<var>& map)
|
||||
RemapperValueSourceWithDefault (ValueWithDefault* vwd, const Array<var>& map)
|
||||
: valueWithDefault (vwd),
|
||||
sourceValue (valueWithDefault.getPropertyAsValue()),
|
||||
sourceValue (valueWithDefault->getPropertyAsValue()),
|
||||
mappings (map)
|
||||
{
|
||||
sourceValue.addListener (this);
|
||||
@ -83,7 +83,10 @@ public:
|
||||
|
||||
var getValue() const override
|
||||
{
|
||||
if (valueWithDefault.isUsingDefault())
|
||||
if (valueWithDefault == nullptr)
|
||||
return {};
|
||||
|
||||
if (valueWithDefault->isUsingDefault())
|
||||
return -1;
|
||||
|
||||
auto targetValue = sourceValue.getValue();
|
||||
@ -97,28 +100,31 @@ public:
|
||||
|
||||
void setValue (const var& newValue) override
|
||||
{
|
||||
if (valueWithDefault == nullptr)
|
||||
return;
|
||||
|
||||
auto newValueInt = static_cast<int> (newValue);
|
||||
|
||||
if (newValueInt == -1)
|
||||
{
|
||||
valueWithDefault.resetToDefault();
|
||||
valueWithDefault->resetToDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto remappedVal = mappings [newValueInt - 1];
|
||||
|
||||
if (! remappedVal.equalsWithSameType (sourceValue))
|
||||
valueWithDefault = remappedVal;
|
||||
*valueWithDefault = remappedVal;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ValueWithDefault& valueWithDefault;
|
||||
void valueChanged (Value&) override { sendChangeMessage (true); }
|
||||
|
||||
WeakReference<ValueWithDefault> valueWithDefault;
|
||||
Value sourceValue;
|
||||
Array<var> mappings;
|
||||
|
||||
void valueChanged (Value&) override { sendChangeMessage (true); }
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RemapperValueSourceWithDefault)
|
||||
};
|
||||
@ -161,17 +167,19 @@ ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToContr
|
||||
const Array<var>& correspondingValues)
|
||||
: ChoicePropertyComponent (name, choiceList, correspondingValues)
|
||||
{
|
||||
createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueToControl.getDefault())]);
|
||||
valueWithDefault = &valueToControl;
|
||||
|
||||
comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueToControl,
|
||||
createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueWithDefault->getDefault())]);
|
||||
|
||||
comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueWithDefault,
|
||||
correspondingValues)));
|
||||
|
||||
valueToControl.onDefaultChange = [this, &valueToControl, choiceList, correspondingValues]
|
||||
valueWithDefault->onDefaultChange = [this, choiceList, correspondingValues]
|
||||
{
|
||||
auto selectedId = comboBox.getSelectedId();
|
||||
|
||||
comboBox.clear();
|
||||
createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueToControl.getDefault())]);
|
||||
createComboBoxWithDefault (choiceList [correspondingValues.indexOf (valueWithDefault->getDefault())]);
|
||||
|
||||
comboBox.setSelectedId (selectedId);
|
||||
};
|
||||
@ -182,17 +190,19 @@ ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToContr
|
||||
: PropertyComponent (name),
|
||||
choices ({ "Enabled", "Disabled" })
|
||||
{
|
||||
createComboBoxWithDefault (valueToControl.getDefault() ? "Enabled" : "Disabled");
|
||||
valueWithDefault = &valueToControl;
|
||||
|
||||
comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueToControl,
|
||||
createComboBoxWithDefault (valueWithDefault->getDefault() ? "Enabled" : "Disabled");
|
||||
|
||||
comboBox.getSelectedIdAsValue().referTo (Value (new RemapperValueSourceWithDefault (valueWithDefault,
|
||||
{ true, false })));
|
||||
|
||||
valueToControl.onDefaultChange = [this, &valueToControl]
|
||||
valueWithDefault->onDefaultChange = [this]
|
||||
{
|
||||
auto selectedId = comboBox.getSelectedId();
|
||||
|
||||
comboBox.clear();
|
||||
createComboBoxWithDefault (valueToControl.getDefault() ? "Enabled" : "Disabled");
|
||||
createComboBoxWithDefault (valueWithDefault->getDefault() ? "Enabled" : "Disabled");
|
||||
|
||||
comboBox.setSelectedId (selectedId);
|
||||
};
|
||||
@ -200,6 +210,8 @@ ChoicePropertyComponent::ChoicePropertyComponent (ValueWithDefault& valueToContr
|
||||
|
||||
ChoicePropertyComponent::~ChoicePropertyComponent()
|
||||
{
|
||||
if (valueWithDefault != nullptr)
|
||||
valueWithDefault->onDefaultChange = nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
@ -50,6 +50,10 @@ namespace juce
|
||||
*/
|
||||
class JUCE_API ChoicePropertyComponent : public PropertyComponent
|
||||
{
|
||||
private:
|
||||
/** Delegating constructor. */
|
||||
ChoicePropertyComponent (const String&, const StringArray&, const Array<var>&);
|
||||
|
||||
protected:
|
||||
/** Creates the component.
|
||||
Your subclass's constructor must add a list of options to the choices member variable.
|
||||
@ -79,7 +83,7 @@ public:
|
||||
/** Creates the component using a ValueWithDefault object. This will add an item to the ComboBox for the
|
||||
default value with an ID of -1.
|
||||
|
||||
@param valueToControl the ValueWithDefault object that contains the Value object that the combo box will read and control
|
||||
@param valueToControl the ValueWithDefault object that contains the Value object that the combo box will read and control.
|
||||
@param propertyName the name of the property
|
||||
@param choices the list of possible values that the drop-down list will contain
|
||||
@param correspondingValues a list of values corresponding to each item in the 'choices' StringArray.
|
||||
@ -102,7 +106,7 @@ public:
|
||||
const String& propertyName);
|
||||
|
||||
/** Destructor. */
|
||||
~ChoicePropertyComponent();
|
||||
~ChoicePropertyComponent() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Called when the user selects an item from the combo box.
|
||||
@ -135,20 +139,23 @@ protected:
|
||||
StringArray choices;
|
||||
|
||||
private:
|
||||
/** Delegating constructor. */
|
||||
ChoicePropertyComponent (const String&, const StringArray&, const Array<var>&);
|
||||
|
||||
ComboBox comboBox;
|
||||
bool isCustomClass = false;
|
||||
|
||||
//==============================================================================
|
||||
class RemapperValueSource;
|
||||
class RemapperValueSourceWithDefault;
|
||||
|
||||
//==============================================================================
|
||||
void createComboBox();
|
||||
void createComboBoxWithDefault (const String&);
|
||||
|
||||
void changeIndex();
|
||||
|
||||
//==============================================================================
|
||||
ComboBox comboBox;
|
||||
bool isCustomClass = false;
|
||||
|
||||
WeakReference<ValueWithDefault> valueWithDefault;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChoicePropertyComponent)
|
||||
};
|
||||
|
||||
|
@ -106,10 +106,10 @@ class MultiChoicePropertyComponent::MultiChoiceRemapperSourceWithDefault : pu
|
||||
private Value::Listener
|
||||
{
|
||||
public:
|
||||
MultiChoiceRemapperSourceWithDefault (ValueWithDefault& vwd, var v, int c, ToggleButton* b)
|
||||
MultiChoiceRemapperSourceWithDefault (ValueWithDefault* vwd, var v, int c, ToggleButton* b)
|
||||
: valueWithDefault (vwd),
|
||||
varToControl (v),
|
||||
sourceValue (valueWithDefault.getPropertyAsValue()),
|
||||
sourceValue (valueWithDefault->getPropertyAsValue()),
|
||||
maxChoices (c),
|
||||
buttonToControl (b)
|
||||
{
|
||||
@ -118,7 +118,10 @@ public:
|
||||
|
||||
var getValue() const override
|
||||
{
|
||||
auto v = valueWithDefault.get();
|
||||
if (valueWithDefault == nullptr)
|
||||
return {};
|
||||
|
||||
auto v = valueWithDefault->get();
|
||||
|
||||
if (auto* arr = v.getArray())
|
||||
{
|
||||
@ -134,11 +137,14 @@ public:
|
||||
|
||||
void setValue (const var& newValue) override
|
||||
{
|
||||
auto v = valueWithDefault.get();
|
||||
if (valueWithDefault == nullptr)
|
||||
return;
|
||||
|
||||
auto v = valueWithDefault->get();
|
||||
|
||||
OptionalScopedPointer<Array<var>> arrayToControl;
|
||||
|
||||
if (valueWithDefault.isUsingDefault())
|
||||
if (valueWithDefault->isUsingDefault())
|
||||
arrayToControl.set (new Array<var>(), true); // use an empty array so the default values are overwritten
|
||||
else
|
||||
arrayToControl.set (v.getArray(), false);
|
||||
@ -149,7 +155,7 @@ public:
|
||||
|
||||
bool newState = newValue;
|
||||
|
||||
if (valueWithDefault.isUsingDefault())
|
||||
if (valueWithDefault->isUsingDefault())
|
||||
{
|
||||
if (auto* defaultArray = v.getArray())
|
||||
{
|
||||
@ -171,15 +177,27 @@ public:
|
||||
StringComparator c;
|
||||
temp.sort (c);
|
||||
|
||||
valueWithDefault = temp;
|
||||
*valueWithDefault = temp;
|
||||
|
||||
if (temp.size() == 0)
|
||||
valueWithDefault.resetToDefault();
|
||||
valueWithDefault->resetToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ValueWithDefault& valueWithDefault;
|
||||
//==============================================================================
|
||||
void valueChanged (Value&) override { sendChangeMessage (true); }
|
||||
|
||||
void updateButtonTickColour() const noexcept
|
||||
{
|
||||
auto alpha = valueWithDefault->isUsingDefault() ? 0.4f : 1.0f;
|
||||
auto baseColour = buttonToControl->findColour (ToggleButton::tickColourId);
|
||||
|
||||
buttonToControl->setColour (ToggleButton::tickColourId, baseColour.withAlpha (alpha));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
WeakReference<ValueWithDefault> valueWithDefault;
|
||||
var varToControl;
|
||||
Value sourceValue;
|
||||
|
||||
@ -187,17 +205,6 @@ private:
|
||||
|
||||
ToggleButton* buttonToControl;
|
||||
|
||||
//==============================================================================
|
||||
void valueChanged (Value&) override { sendChangeMessage (true); }
|
||||
|
||||
void updateButtonTickColour() const noexcept
|
||||
{
|
||||
auto alpha = valueWithDefault.isUsingDefault() ? 0.4f : 1.0f;
|
||||
auto baseColour = buttonToControl->findColour (ToggleButton::tickColourId);
|
||||
|
||||
buttonToControl->setColour (ToggleButton::tickColourId, baseColour.withAlpha (alpha));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MultiChoiceRemapperSourceWithDefault)
|
||||
};
|
||||
@ -254,16 +261,24 @@ MultiChoicePropertyComponent::MultiChoicePropertyComponent (ValueWithDefault& va
|
||||
int maxChoices)
|
||||
: MultiChoicePropertyComponent (propertyName, choices, correspondingValues)
|
||||
{
|
||||
valueWithDefault = &valueToControl;
|
||||
|
||||
// The value to control must be an array!
|
||||
jassert (valueToControl.get().isArray());
|
||||
jassert (valueWithDefault->get().isArray());
|
||||
|
||||
for (int i = 0; i < choiceButtons.size(); ++i)
|
||||
choiceButtons[i]->getToggleStateValue().referTo (Value (new MultiChoiceRemapperSourceWithDefault (valueToControl,
|
||||
choiceButtons[i]->getToggleStateValue().referTo (Value (new MultiChoiceRemapperSourceWithDefault (valueWithDefault,
|
||||
correspondingValues[i],
|
||||
maxChoices,
|
||||
choiceButtons[i])));
|
||||
|
||||
valueToControl.onDefaultChange = [this] { repaint(); };
|
||||
valueWithDefault->onDefaultChange = [this] { repaint(); };
|
||||
}
|
||||
|
||||
MultiChoicePropertyComponent::~MultiChoicePropertyComponent()
|
||||
{
|
||||
if (valueWithDefault != nullptr)
|
||||
valueWithDefault->onDefaultChange = nullptr;
|
||||
}
|
||||
|
||||
void MultiChoicePropertyComponent::paint (Graphics& g)
|
||||
|
@ -41,6 +41,10 @@ namespace juce
|
||||
*/
|
||||
class MultiChoicePropertyComponent : public PropertyComponent
|
||||
{
|
||||
private:
|
||||
/** Delegating constructor. */
|
||||
MultiChoicePropertyComponent (const String&, const StringArray&, const Array<var>&);
|
||||
|
||||
public:
|
||||
/** Creates the component. Note that the underlying var object that the Value refers to must be an array.
|
||||
|
||||
@ -62,7 +66,7 @@ public:
|
||||
|
||||
/** Creates the component using a ValueWithDefault object. This will select the default options.
|
||||
|
||||
@param valueToControl the ValueWithDefault object that contains the Value object that the ToggleButtons will read and control
|
||||
@param valueToControl the ValueWithDefault object that contains the Value object that the ToggleButtons will read and control.
|
||||
@param propertyName the name of the property
|
||||
@param choices the list of possible values that will be represented
|
||||
@param correspondingValues a list of values corresponding to each item in the 'choices' StringArray.
|
||||
@ -78,6 +82,8 @@ public:
|
||||
const Array<var>& correspondingValues,
|
||||
int maxChoices = -1);
|
||||
|
||||
~MultiChoicePropertyComponent() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if the list of options is expanded. */
|
||||
bool isExpanded() const noexcept { return expanded; }
|
||||
@ -104,8 +110,7 @@ public:
|
||||
void refresh() override {}
|
||||
|
||||
private:
|
||||
MultiChoicePropertyComponent (const String&, const StringArray&, const Array<var>&);
|
||||
|
||||
//==============================================================================
|
||||
class MultiChoiceRemapperSource;
|
||||
class MultiChoiceRemapperSourceWithDefault;
|
||||
|
||||
@ -113,6 +118,8 @@ private:
|
||||
void lookAndFeelChanged() override;
|
||||
|
||||
//==============================================================================
|
||||
WeakReference<ValueWithDefault> valueWithDefault;
|
||||
|
||||
int maxHeight = 0;
|
||||
int numHidden = 0;
|
||||
bool expanded = false;
|
||||
|
@ -27,8 +27,8 @@
|
||||
namespace juce
|
||||
{
|
||||
|
||||
PropertyComponent::PropertyComponent (const String& name, const int preferredHeight_)
|
||||
: Component (name), preferredHeight (preferredHeight_)
|
||||
PropertyComponent::PropertyComponent (const String& name, int height)
|
||||
: Component (name), preferredHeight (height)
|
||||
{
|
||||
jassert (name.isNotEmpty());
|
||||
}
|
||||
@ -37,7 +37,7 @@ PropertyComponent::~PropertyComponent() {}
|
||||
|
||||
void PropertyComponent::paint (Graphics& g)
|
||||
{
|
||||
LookAndFeel& lf = getLookAndFeel();
|
||||
auto& lf = getLookAndFeel();
|
||||
|
||||
lf.drawPropertyComponentBackground (g, getWidth(), getHeight(), *this);
|
||||
lf.drawPropertyComponentLabel (g, getWidth(), getHeight(), *this);
|
||||
@ -45,7 +45,7 @@ void PropertyComponent::paint (Graphics& g)
|
||||
|
||||
void PropertyComponent::resized()
|
||||
{
|
||||
if (Component* const c = getChildComponent(0))
|
||||
if (auto c = getChildComponent(0))
|
||||
c->setBounds (getLookAndFeel().getPropertyComponentContentPosition (*this));
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
int preferredHeight = 25);
|
||||
|
||||
/** Destructor. */
|
||||
~PropertyComponent();
|
||||
~PropertyComponent() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns this item's preferred height.
|
||||
@ -123,7 +123,7 @@ public:
|
||||
/** This abstract base class is implemented by LookAndFeel classes. */
|
||||
struct JUCE_API LookAndFeelMethods
|
||||
{
|
||||
virtual ~LookAndFeelMethods() {}
|
||||
virtual ~LookAndFeelMethods() = default;
|
||||
|
||||
virtual void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) = 0;
|
||||
virtual void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) = 0;
|
||||
|
@ -45,7 +45,7 @@ struct PropertyPanel::SectionComponent : public Component
|
||||
}
|
||||
}
|
||||
|
||||
~SectionComponent()
|
||||
~SectionComponent() override
|
||||
{
|
||||
propertyComps.clear();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
PropertyPanel (const String& name);
|
||||
|
||||
/** Destructor. */
|
||||
~PropertyPanel();
|
||||
~PropertyPanel() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Deletes all property components from the panel. */
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
bool symmetricSkew = false);
|
||||
|
||||
/** Destructor. */
|
||||
~SliderPropertyComponent();
|
||||
~SliderPropertyComponent() override;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@ -92,7 +92,7 @@ public:
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void refresh();
|
||||
void refresh() override;
|
||||
|
||||
protected:
|
||||
/** The slider component being used in this component.
|
||||
|
@ -96,8 +96,9 @@ public:
|
||||
{
|
||||
if (getText().isEmpty() && ! isBeingEdited())
|
||||
{
|
||||
auto textArea = getBorderSize().subtractedFrom (getLocalBounds());
|
||||
auto labelFont = owner.getLookAndFeel().getLabelFont (*this);
|
||||
auto& lf = owner.getLookAndFeel();
|
||||
auto textArea = lf.getLabelBorderSize (*this).subtractedFrom (getLocalBounds());
|
||||
auto labelFont = lf.getLabelFont (*this);
|
||||
|
||||
g.setColour (owner.findColour (TextPropertyComponent::textColourId).withAlpha (alphaToUseForEmptyText));
|
||||
g.setFont (labelFont);
|
||||
@ -123,26 +124,32 @@ private:
|
||||
class TextPropertyComponent::RemapperValueSourceWithDefault : public Value::ValueSource
|
||||
{
|
||||
public:
|
||||
RemapperValueSourceWithDefault (const ValueWithDefault& vwd)
|
||||
RemapperValueSourceWithDefault (ValueWithDefault* vwd)
|
||||
: valueWithDefault (vwd)
|
||||
{
|
||||
}
|
||||
|
||||
var getValue() const override
|
||||
{
|
||||
return valueWithDefault.isUsingDefault() ? var() : valueWithDefault.get();
|
||||
if (valueWithDefault == nullptr || valueWithDefault->isUsingDefault())
|
||||
return {};
|
||||
|
||||
return valueWithDefault->get();
|
||||
}
|
||||
|
||||
void setValue (const var& newValue) override
|
||||
{
|
||||
if (valueWithDefault == nullptr)
|
||||
return;
|
||||
|
||||
if (newValue.toString().isEmpty())
|
||||
valueWithDefault.resetToDefault();
|
||||
valueWithDefault->resetToDefault();
|
||||
else
|
||||
valueWithDefault = newValue;
|
||||
*valueWithDefault = newValue;
|
||||
}
|
||||
|
||||
private:
|
||||
ValueWithDefault valueWithDefault;
|
||||
WeakReference<ValueWithDefault> valueWithDefault;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RemapperValueSourceWithDefault)
|
||||
@ -159,35 +166,33 @@ TextPropertyComponent::TextPropertyComponent (const String& name,
|
||||
createEditor (maxNumChars, isEditable);
|
||||
}
|
||||
|
||||
TextPropertyComponent::TextPropertyComponent (const Value& valueToControl,
|
||||
const String& name,
|
||||
int maxNumChars,
|
||||
bool isMultiLine,
|
||||
bool isEditable)
|
||||
: TextPropertyComponent (name, maxNumChars, isMultiLine, isEditable)
|
||||
TextPropertyComponent::TextPropertyComponent (const Value& valueToControl, const String& name,
|
||||
int maxNumChars, bool multiLine, bool isEditable)
|
||||
: TextPropertyComponent (name, maxNumChars, multiLine, isEditable)
|
||||
{
|
||||
textEditor->getTextValue().referTo (valueToControl);
|
||||
}
|
||||
|
||||
TextPropertyComponent::TextPropertyComponent (ValueWithDefault& valueToControl,
|
||||
const String& name,
|
||||
int maxNumChars,
|
||||
bool isMultiLine,
|
||||
bool isEditable)
|
||||
: TextPropertyComponent (name, maxNumChars, isMultiLine, isEditable)
|
||||
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);
|
||||
valueWithDefault = &valueToControl;
|
||||
|
||||
valueToControl.onDefaultChange = [this, &valueToControl]
|
||||
textEditor->getTextValue().referTo (Value (new RemapperValueSourceWithDefault (valueWithDefault)));
|
||||
textEditor->setTextToDisplayWhenEmpty (valueWithDefault->getDefault(), 0.5f);
|
||||
|
||||
valueWithDefault->onDefaultChange = [this]
|
||||
{
|
||||
textEditor->setTextToDisplayWhenEmpty (valueToControl.getDefault(), 0.5f);
|
||||
textEditor->setTextToDisplayWhenEmpty (valueWithDefault->getDefault(), 0.5f);
|
||||
repaint();
|
||||
};
|
||||
}
|
||||
|
||||
TextPropertyComponent::~TextPropertyComponent()
|
||||
{
|
||||
if (valueWithDefault != nullptr)
|
||||
valueWithDefault->onDefaultChange = nullptr;
|
||||
}
|
||||
|
||||
void TextPropertyComponent::setText (const String& newText)
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
|
||||
/** Creates a text property component with a default value.
|
||||
|
||||
@param valueToControl The ValueWithDefault that is controlled by the TextPropertyComponent
|
||||
@param valueToControl The ValueWithDefault that is controlled by the TextPropertyComponent.
|
||||
@param propertyName The name of the property
|
||||
@param maxNumChars If not zero, then this specifies the maximum allowable length of
|
||||
the string. If zero, then the string will have no length limit.
|
||||
@ -90,7 +90,7 @@ public:
|
||||
bool isEditable = true);
|
||||
|
||||
/** Destructor. */
|
||||
~TextPropertyComponent();
|
||||
~TextPropertyComponent() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Called when the user edits the text.
|
||||
@ -133,7 +133,7 @@ public:
|
||||
{
|
||||
public:
|
||||
/** Destructor. */
|
||||
virtual ~Listener() {}
|
||||
virtual ~Listener() = default;
|
||||
|
||||
/** Called when text has finished being entered (i.e. not per keypress) has changed. */
|
||||
virtual void textPropertyComponentChanged (TextPropertyComponent*) = 0;
|
||||
@ -168,19 +168,23 @@ public:
|
||||
virtual void textWasEdited();
|
||||
|
||||
private:
|
||||
bool isMultiLine;
|
||||
|
||||
class RemapperValueSourceWithDefault;
|
||||
|
||||
class LabelComp;
|
||||
friend class LabelComp;
|
||||
|
||||
//==============================================================================
|
||||
void callListeners();
|
||||
void createEditor (int maxNumChars, bool isEditable);
|
||||
|
||||
//==============================================================================
|
||||
bool isMultiLine;
|
||||
|
||||
std::unique_ptr<LabelComp> textEditor;
|
||||
ListenerList<Listener> listenerList;
|
||||
|
||||
void callListeners();
|
||||
void createEditor (int maxNumChars, bool isEditable);
|
||||
WeakReference<ValueWithDefault> valueWithDefault;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextPropertyComponent)
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user