43 markers.addCopiesOf (
other.markers);
52 listeners.call ([
this] (
Listener&
l) {
l.markerListBeingDeleted (
this); });
57 if (
other.markers.size() != markers.size())
60 for (
int i = markers.size(); --i >= 0;)
62 const Marker*
const m1 = markers.getUnchecked (i);
67 if (
m2 ==
nullptr || *
m1 != *
m2)
76 return ! operator== (
other);
82 return markers.size();
87 return markers [index];
92 return getMarkerByName (name);
97 for (
int i = 0; i < markers.size(); ++i)
99 Marker*
const m = markers.getUnchecked (i);
110 if (
Marker*
const m = getMarkerByName (name))
112 if (m->position != position)
121 markers.add (
new Marker (name, position));
129 markers.remove (index);
136 for (
int i = 0; i < markers.size(); ++i)
138 const Marker*
const m = markers.getUnchecked (i);
150 listeners.call ([
this] (
Listener&
l) {
l.markersChanged (
this); });
159 listeners.add (listener);
164 listeners.remove (listener);
169 : name (
other.name), position (
other.position)
180 return name ==
other.name && position ==
other.position;
189const Identifier MarkerList::ValueTreeWrapper::markerTag (
"Marker");
190const Identifier MarkerList::ValueTreeWrapper::nameProperty (
"name");
191const Identifier MarkerList::ValueTreeWrapper::posProperty (
"position");
193MarkerList::ValueTreeWrapper::ValueTreeWrapper (
const ValueTree&
state_)
198int MarkerList::ValueTreeWrapper::getNumMarkers()
const
200 return state.getNumChildren();
203ValueTree MarkerList::ValueTreeWrapper::getMarkerState (
int index)
const
205 return state.getChild (index);
208ValueTree MarkerList::ValueTreeWrapper::getMarkerState (
const String& name)
const
210 return state.getChildWithProperty (nameProperty, name);
213bool MarkerList::ValueTreeWrapper::containsMarker (
const ValueTree& marker)
const
215 return marker.isAChildOf (state);
218MarkerList::Marker MarkerList::ValueTreeWrapper::getMarker (
const ValueTree& marker)
const
220 jassert (containsMarker (marker));
222 return MarkerList::Marker (marker [nameProperty], RelativeCoordinate (marker [posProperty].
toString()));
225void MarkerList::ValueTreeWrapper::setMarker (
const MarkerList::Marker& m, UndoManager* undoManager)
227 ValueTree marker (state.getChildWithProperty (nameProperty, m.name));
229 if (marker.isValid())
231 marker.setProperty (posProperty, m.position.toString(), undoManager);
235 marker = ValueTree (markerTag);
236 marker.setProperty (nameProperty, m.name,
nullptr);
237 marker.setProperty (posProperty, m.position.toString(),
nullptr);
238 state.appendChild (marker, undoManager);
242void MarkerList::ValueTreeWrapper::removeMarker (
const ValueTree& marker, UndoManager* undoManager)
244 state.removeChild (marker, undoManager);
249 if (parentComponent ==
nullptr)
265 const ValueTree marker (state.getChild (i));
266 const String name (marker [nameProperty].toString());
271 for (
int i =
markerList.getNumMarkers(); --i >= 0;)
276void MarkerList::ValueTreeWrapper::readFrom (
const MarkerList&
markerList, UndoManager* undoManager)
278 state.removeAllChildren (undoManager);
280 for (
int i = 0; i <
markerList.getNumMarkers(); ++i)
The base class for all JUCE user-interface objects.
Represents a string identifier, designed for accessing properties by name.
A class for receiving events when changes are made to a MarkerList.
virtual void markerListBeingDeleted(MarkerList *markerList)
Called when the given marker list is being deleted.
Represents a marker in a MarkerList.
bool operator==(const Marker &) const noexcept
Returns true if both the names and positions of these two markers match.
String name
The marker's name.
Marker(const Marker &)
Creates a copy of another Marker.
RelativeCoordinate position
The marker's position.
bool operator!=(const Marker &) const noexcept
Returns true if either the name or position of these two markers differ.
Holds a set of named marker points along a one-dimensional axis.
void setMarker(const String &name, const RelativeCoordinate &position)
Sets the position of a marker.
bool operator!=(const MarkerList &) const noexcept
Returns true if not all the markers in these two lists match exactly.
MarkerList()
Creates an empty marker list.
const Marker * getMarker(int index) const noexcept
Returns one of the markers in the list, by its index.
void markersHaveChanged()
Synchronously calls markersChanged() on all the registered listeners.
void removeListener(Listener *listener)
Deregisters a previously-registered listener.
bool operator==(const MarkerList &) const noexcept
Returns true if all the markers in these two lists match exactly.
double getMarkerPosition(const Marker &marker, Component *parentComponent) const
Evaluates the given marker and returns its absolute position.
void removeMarker(int index)
Deletes the marker at the given list index.
void addListener(Listener *listener)
Registers a listener that will be called when the markers are changed.
int getNumMarkers() const noexcept
Returns the number of markers in the list.
MarkerList & operator=(const MarkerList &)
Copies another marker list to this one.
Used for resolving a RelativeCoordinate expression in the context of a component.
Expresses a coordinate as a dynamically evaluated expression.
double resolve(const Expression::Scope *evaluationScope) const
Calculates the absolute position of this coordinate.
A special array for holding a list of strings.
A powerful tree structure that can be used to hold free-form data, and which can handle its own undo ...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
std::u16string toString(NumberT value)
convert an number to an UTF-16 string