35 : sourceValue (source),
45 for (
auto& map : mappings)
47 return mappings.indexOf (map) + 1;
54 auto remappedVal = mappings [
static_cast<int> (newValue) - 1];
77 sourceValue (value.getPropertyAsValue()),
87 const auto target = sourceValue.
getValue();
88 const auto equalsWithSameType = [&target] (
const var& map) {
return map.equalsWithSameType (target); };
90 auto iter =
std::find_if (mappings.begin(), mappings.end(), equalsWithSameType);
92 if (iter == mappings.end())
93 iter =
std::find (mappings.begin(), mappings.end(), target);
95 if (iter != mappings.end())
114 if (!
remappedVal.equalsWithSameType (sourceValue))
122 ValueTreePropertyWithDefault value;
131ChoicePropertyComponent::ChoicePropertyComponent (
const String& name)
137ChoicePropertyComponent::ChoicePropertyComponent (
const String& name,
182 choices ({
"Enabled",
"Disabled" })
186 auto getDefaultString = [
this] {
return value.getDefault() ?
"Enabled" :
"Disabled"; };
189 initialiseComboBox (Value (
new ChoiceRemapperValueSourceWithDefault (value, {
true,
false })));
200void ChoicePropertyComponent::initialiseComboBox (
const Value& v)
210void ChoicePropertyComponent::refreshChoices()
225void ChoicePropertyComponent::refreshChoices (
const String&
defaultString)
256 initialiseComboBox ({});
257 comboBox.
onChange = [
this] { changeIndex(); };
264void ChoicePropertyComponent::changeIndex()
Holds a resizable array of primitive or copy-by-value objects.
A PropertyComponent that shows its value as a combo box.
StringArray choices
The list of options that will be shown in the combo box.
virtual int getIndex() const
Returns the index of the item that should currently be shown.
void refresh() override
Updates the property component if the item it refers to has changed.
virtual void setIndex(int newIndex)
Called when the user selects an item from the combo box.
const StringArray & getChoices() const
Returns the list of options.
var getValue() const override
Returns the current value of this object.
void setValue(const var &newValue) override
Changes the current value.
void setValue(const var &newValue) override
Changes the current value.
var getValue() const override
Returns the current value of this object.
void valueChanged(Value &) override
Called when a Value object is changed.
void clear(NotificationType notification=sendNotificationAsync)
Removes all the items from the drop-down list.
Value & getSelectedIdAsValue()
Returns a Value object that can be used to get or set the selected item's ID.
void setSelectedId(int newItemId, NotificationType notification=sendNotificationAsync)
Sets one of the items to be the current selection.
std::function< void()> onChange
You can assign a lambda to this callback object to have it called when the selected ID is changed.
void setEditableText(bool isEditable)
Sets whether the text in the combo-box is editable.
void addSeparator()
Adds a separator line to the drop-down list.
int getSelectedId() const noexcept
Returns the ID of the item that's currently shown in the box.
void addItem(const String &newItemText, int newItemId)
Adds an item to be shown in the drop-down list.
bool isVisible() const noexcept
Tests whether the component is visible or not.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
A base class for a component that goes in a PropertyPanel and displays one of an item's properties.
A special array for holding a list of strings.
int size() const noexcept
Returns the number of strings in the array.
This class acts as a wrapper around a property inside a ValueTree.
bool isUsingDefault() const
Returns true if the property does not exist in the referenced ValueTree.
var getDefault() const
Returns the current default value.
std::function< void()> onDefaultChange
You can assign a lambda to this callback and it will called when the default value is changed.
void resetToDefault() noexcept
Removes the property from the referenced ValueTree.
Receives callbacks when a Value object changes.
Used internally by the Value class as the base class for its shared value objects.
void sendChangeMessage(bool dispatchSynchronously)
Delivers a change message to all the listeners that are registered with this value.
Represents a shared variant value.
void addListener(Listener *listener)
Adds a listener to receive callbacks when the value changes.
void referTo(const Value &valueToReferTo)
Makes this object refer to the same underlying ValueSource as another one.
var getValue() const
Returns the current value.
A variant class, that can be used to hold a range of primitive values.
@ valueChanged
Indicates that the UI element's value has changed.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...