44template <
class SelectableItemType>
51 using ParameterType =
typename TypeHelpers::ParameterType<SelectableItemType>::type;
59 : selectedItems (items)
72 if (selectedItems !=
other.selectedItems)
76 for (
int i = selectedItems.
size(); --i >= 0;)
80 for (
auto& i :
other.selectedItems)
84 selectedItems.
add (i);
105 for (
int i = selectedItems.
size(); --i >= 0;)
119 selectedItems.
add (item);
134 selectedItems.
add (item);
233 const int i = selectedItems.
indexOf (item);
245 if (selectedItems.
size() > 0)
249 for (
int i = selectedItems.
size(); --i >= 0;)
322 ItemArray selectedItems;
ElementType getUnchecked(int index) const
Returns one of the elements in the array, without checking the index passed in.
int size() const noexcept
Returns the current number of elements in the array.
ElementType * begin() noexcept
Returns a pointer to the first element in the array.
ElementType * end() noexcept
Returns a pointer to the element which follows the last element in the array.
int indexOf(ParameterType elementToLookFor) const
Finds the index of the first element which matches the value passed in.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
ElementType removeAndReturn(int indexToRemove)
Removes an element from the array.
bool contains(ParameterType elementToLookFor) const
Returns true if the array contains at least one occurrence of an object.
ElementType & getReference(int index) noexcept
Returns a direct reference to one of the elements in the array, without checking the index passed in.
Holds a list of ChangeListeners, and sends messages to them when instructed.
void sendChangeMessage()
Causes an asynchronous change message to be sent to all the registered listeners.
void sendSynchronousChangeMessage()
Sends a synchronous change message to all the registered listeners.
Represents the state of the mouse buttons and modifier keys.
Manages a list of selectable items.
void addToSelectionOnMouseUp(ParameterType item, ModifierKeys modifiers, const bool wasItemDragged, const bool resultOfMouseDownSelectMethod)
Selects or deselects items that can also be dragged, based on a mouse-up event.
void addToSelection(ParameterType item)
Selects an item.
bool addToSelectionOnMouseDown(ParameterType item, ModifierKeys modifiers)
Selects or deselects items that can also be dragged, based on a mouse-down event.
int getNumSelected() const noexcept
Returns the number of currently selected items.
bool isSelected(ParameterType item) const noexcept
True if this item is currently selected.
SelectedItemSet(const ItemArray &items)
Creates a set based on an array of items.
const SelectableItemType * end() const noexcept
Provides iterator access to the array of items.
SelectedItemSet()=default
Creates an empty set.
void deselectAll()
Deselects all items.
void selectOnly(ParameterType item)
Clears any other currently selected items, and selects this item.
void changed()
Used internally, but can be called to force a change message to be sent to the ChangeListeners.
SelectableItemType getSelectedItem(const int index) const
Returns one of the currently selected items.
SelectableItemType * begin() noexcept
Provides iterator access to the array of items.
void changed(const bool synchronous)
Used internally, but can be called to force a change message to be sent to the ChangeListeners.
SelectedItemSet(const SelectedItemSet &other)
Creates a copy of another set.
SelectedItemSet & operator=(const SelectedItemSet &other)
Creates a copy of another set.
virtual void itemSelected(SelectableItemType)
Can be overridden to do special handling when an item is selected.
virtual void itemDeselected(SelectableItemType)
Can be overridden to do special handling when an item is deselected.
const ItemArray & getItemArray() const noexcept
Provides access to the array of items.
void addToSelectionBasedOnModifiers(ParameterType item, ModifierKeys modifiers)
Selects or deselects an item.
void deselect(ParameterType item)
Deselects an item.
SelectableItemType * end() noexcept
Provides iterator access to the array of items.
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...