| @@ -2139,12 +2139,6 @@ void Component::copyAllExplicitColoursTo (Component& target) const | |||||
| target.colourChanged(); | target.colourChanged(); | ||||
| } | } | ||||
| //============================================================================== | |||||
| MarkerList* Component::getMarkers (bool /*xAxis*/) | |||||
| { | |||||
| return nullptr; | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| Component::Positioner::Positioner (Component& c) noexcept | Component::Positioner::Positioner (Component& c) noexcept | ||||
| : component (c) | : component (c) | ||||
| @@ -2105,14 +2105,6 @@ public: | |||||
| */ | */ | ||||
| virtual void colourChanged(); | virtual void colourChanged(); | ||||
| //============================================================================== | |||||
| /** Components can implement this method to provide a MarkerList. | |||||
| The default implementation of this method returns nullptr, but you can override | |||||
| it to return a pointer to the component's marker list. If xAxis is true, it should | |||||
| return the X marker list; if false, it should return the Y markers. | |||||
| */ | |||||
| virtual MarkerList* getMarkers (bool xAxis); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the underlying native window handle for this component. | /** Returns the underlying native window handle for this component. | ||||
| @@ -33,7 +33,8 @@ namespace juce | |||||
| @see DrawableComposite, DrawableImage, DrawablePath, DrawableText | @see DrawableComposite, DrawableImage, DrawablePath, DrawableText | ||||
| */ | */ | ||||
| class JUCE_API Drawable : public Component | |||||
| class JUCE_API Drawable : public Component, | |||||
| public MarkerList::MarkerListHolder | |||||
| { | { | ||||
| protected: | protected: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -225,6 +226,8 @@ public: | |||||
| */ | */ | ||||
| static void registerDrawableTypeHandlers (ComponentBuilder& componentBuilder); | static void registerDrawableTypeHandlers (ComponentBuilder& componentBuilder); | ||||
| MarkerList* getMarkers (bool) override { return nullptr; } | |||||
| protected: | protected: | ||||
| //============================================================================== | //============================================================================== | ||||
| friend class DrawableComposite; | friend class DrawableComposite; | ||||
| @@ -146,6 +146,16 @@ public: | |||||
| /** Synchronously calls markersChanged() on all the registered listeners. */ | /** Synchronously calls markersChanged() on all the registered listeners. */ | ||||
| void markersHaveChanged(); | void markersHaveChanged(); | ||||
| //============================================================================== | |||||
| /** A base class for objects that want to provide a MarkerList. */ | |||||
| struct MarkerListHolder | |||||
| { | |||||
| virtual ~MarkerListHolder() {} | |||||
| /** Objects can implement this method to provide a MarkerList. */ | |||||
| virtual MarkerList* getMarkers (bool xAxis) = 0; | |||||
| }; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Forms a wrapper around a ValueTree that can be used for storing a MarkerList. */ | /** Forms a wrapper around a ValueTree that can be used for storing a MarkerList. */ | ||||
| class ValueTreeWrapper | class ValueTreeWrapper | ||||
| @@ -73,19 +73,28 @@ struct MarkerListScope : public Expression::Scope | |||||
| static const MarkerList::Marker* findMarker (Component& component, const String& name, MarkerList*& list) | static const MarkerList::Marker* findMarker (Component& component, const String& name, MarkerList*& list) | ||||
| { | { | ||||
| const MarkerList::Marker* marker = nullptr; | const MarkerList::Marker* marker = nullptr; | ||||
| list = component.getMarkers (true); | |||||
| if (list != nullptr) | |||||
| marker = list->getMarker (name); | |||||
| auto* mlh = dynamic_cast<MarkerList::MarkerListHolder*> (&component); | |||||
| if (marker == nullptr) | |||||
| if (mlh != nullptr) | |||||
| { | { | ||||
| list = component.getMarkers (false); | |||||
| list = mlh->getMarkers (true); | |||||
| if (list != nullptr) | if (list != nullptr) | ||||
| marker = list->getMarker (name); | marker = list->getMarker (name); | ||||
| } | } | ||||
| if (marker == nullptr) | |||||
| { | |||||
| if (mlh != nullptr) | |||||
| { | |||||
| list = mlh->getMarkers (false); | |||||
| if (list != nullptr) | |||||
| marker = list->getMarker (name); | |||||
| } | |||||
| } | |||||
| return marker; | return marker; | ||||
| } | } | ||||
| @@ -117,7 +126,7 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con | |||||
| { | { | ||||
| MarkerList* list; | MarkerList* list; | ||||
| if (const MarkerList::Marker* const marker = MarkerListScope::findMarker (*parent, symbol, list)) | |||||
| if (auto* marker = MarkerListScope::findMarker (*parent, symbol, list)) | |||||
| { | { | ||||
| MarkerListScope scope (*parent); | MarkerListScope scope (*parent); | ||||
| return Expression (marker->position.getExpression().evaluate (scope)); | return Expression (marker->position.getExpression().evaluate (scope)); | ||||
| @@ -175,7 +184,7 @@ public: | |||||
| break; | break; | ||||
| default: | default: | ||||
| if (Component* const parent = component.getParentComponent()) | |||||
| if (auto* parent = component.getParentComponent()) | |||||
| { | { | ||||
| MarkerList* list; | MarkerList* list; | ||||
| @@ -186,8 +195,12 @@ public: | |||||
| else | else | ||||
| { | { | ||||
| // The marker we want doesn't exist, so watch all lists in case they change and the marker appears later.. | // The marker we want doesn't exist, so watch all lists in case they change and the marker appears later.. | ||||
| positioner.registerMarkerListListener (parent->getMarkers (true)); | |||||
| positioner.registerMarkerListListener (parent->getMarkers (false)); | |||||
| if (auto* mlh = dynamic_cast<MarkerList::MarkerListHolder*> (parent)) | |||||
| { | |||||
| positioner.registerMarkerListListener (mlh->getMarkers (true)); | |||||
| positioner.registerMarkerListListener (mlh->getMarkers (false)); | |||||
| } | |||||
| ok = false; | ok = false; | ||||
| } | } | ||||
| } | } | ||||