From e5c4ecc6700b52d6eafd11edd83bf3519e5e0f2a Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 3 Jan 2011 19:03:49 +0000 Subject: [PATCH] Drawable fixes. --- juce_amalgamated.cpp | 27 +++++++++---------- juce_amalgamated.h | 17 +++++++----- .../juce_RelativeCoordinatePositioner.h | 8 +++--- .../positioning/juce_RelativePointPath.cpp | 13 +++++---- .../positioning/juce_RelativePointPath.h | 2 +- .../drawables/juce_DrawableComposite.cpp | 2 +- .../graphics/drawables/juce_DrawablePath.cpp | 12 ++++----- .../graphics/drawables/juce_DrawablePath.h | 7 +++-- 8 files changed, 46 insertions(+), 42 deletions(-) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 716c04f8c5..eb045ba751 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -80109,12 +80109,10 @@ RelativePointPath::RelativePointPath (const RelativePointPath& other) } RelativePointPath::RelativePointPath (const Path& path) + : usesNonZeroWinding (path.isUsingNonZeroWinding()), + containsDynamicPoints (false) { - usesNonZeroWinding = path.isUsingNonZeroWinding(); - - Path::Iterator i (path); - - while (i.next()) + for (Path::Iterator i (path); i.next();) { switch (i.elementType) { @@ -80148,8 +80146,8 @@ bool RelativePointPath::operator== (const RelativePointPath& other) const throw( return false; int numPoints1, numPoints2; - RelativePoint* const points1 = e1->getControlPoints (numPoints1); - RelativePoint* const points2 = e2->getControlPoints (numPoints2); + const RelativePoint* const points1 = e1->getControlPoints (numPoints1); + const RelativePoint* const points2 = e2->getControlPoints (numPoints2); jassert (numPoints1 == numPoints2); @@ -80170,6 +80168,7 @@ void RelativePointPath::swapWith (RelativePointPath& other) throw() { elements.swapWithArray (other.elements); swapVariables (usesNonZeroWinding, other.usesNonZeroWinding); + swapVariables (containsDynamicPoints, other.containsDynamicPoints); } void RelativePointPath::createPath (Path& path, Expression::EvaluationContext* coordFinder) const @@ -86955,7 +86954,7 @@ DrawableComposite::DrawableComposite (const DrawableComposite& other) { for (int i = 0; i < other.getNumChildComponents(); ++i) { - const Drawable* const d = dynamic_cast (getChildComponent(i)); + const Drawable* const d = dynamic_cast (other.getChildComponent(i)); if (d != 0) addAndMakeVisible (d->createCopy()); @@ -87551,7 +87550,7 @@ const Path& DrawablePath::getStrokePath() const return strokePath; } -bool DrawablePath::rebuildPath (Path& path) const +bool DrawablePath::rebuildPath (Path&) const { return false; } @@ -87618,22 +87617,22 @@ const RelativePointPath* DrawablePath::getRelativePath() const return current != 0 ? &(current->path) : 0; } -void DrawablePath::setPath (const RelativePointPath& source) +void DrawablePath::setPath (const RelativePointPath& newRelativePath) { - if (source.containsAnyDynamicPoints()) + if (newRelativePath.containsAnyDynamicPoints()) { const RelativePointPath* current = getRelativePath(); - if (current == 0 || source != *current) + if (current == 0 || newRelativePath != *current) { - RelativePositioner* const p = new RelativePositioner (*this, source); + RelativePositioner* const p = new RelativePositioner (*this, newRelativePath); setPositioner (p); p->apply(); } } else { - applyRelativePath (source); + applyRelativePath (newRelativePath); } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 556415f142..fd82dfd416 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -57571,10 +57571,10 @@ private: /** Base class for Component::Positioners that are based upon relative coordinates. */ -class RelativeCoordinatePositionerBase : public Component::Positioner, - public ComponentListener, - public MarkerList::Listener, - public Expression::EvaluationContext +class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner, + public ComponentListener, + public MarkerList::Listener, + public Expression::EvaluationContext { public: RelativeCoordinatePositionerBase (Component& component_); @@ -57758,7 +57758,7 @@ public: RelativePointPath(); RelativePointPath (const RelativePointPath& other); - RelativePointPath (const Path& path); + explicit RelativePointPath (const Path& path); ~RelativePointPath(); bool operator== (const RelativePointPath& other) const throw(); @@ -62144,8 +62144,11 @@ public: */ void setPath (const Path& newPath); - /** */ - void setPath (const RelativePointPath& source); + /** Sets the path using a RelativePointPath. + Calling this will set up a Component::Positioner to automatically update the path + if any of the points in the source path are dynamic. + */ + void setPath (const RelativePointPath& newPath); /** Returns the current path. */ const Path& getPath() const; diff --git a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h index 826679bf99..b1043fd55f 100644 --- a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h +++ b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h @@ -35,10 +35,10 @@ /** Base class for Component::Positioners that are based upon relative coordinates. */ -class RelativeCoordinatePositionerBase : public Component::Positioner, - public ComponentListener, - public MarkerList::Listener, - public Expression::EvaluationContext +class JUCE_API RelativeCoordinatePositionerBase : public Component::Positioner, + public ComponentListener, + public MarkerList::Listener, + public Expression::EvaluationContext { public: RelativeCoordinatePositionerBase (Component& component_); diff --git a/src/gui/components/positioning/juce_RelativePointPath.cpp b/src/gui/components/positioning/juce_RelativePointPath.cpp index 902499d688..629fafc58b 100644 --- a/src/gui/components/positioning/juce_RelativePointPath.cpp +++ b/src/gui/components/positioning/juce_RelativePointPath.cpp @@ -47,12 +47,10 @@ RelativePointPath::RelativePointPath (const RelativePointPath& other) } RelativePointPath::RelativePointPath (const Path& path) + : usesNonZeroWinding (path.isUsingNonZeroWinding()), + containsDynamicPoints (false) { - usesNonZeroWinding = path.isUsingNonZeroWinding(); - - Path::Iterator i (path); - - while (i.next()) + for (Path::Iterator i (path); i.next();) { switch (i.elementType) { @@ -86,8 +84,8 @@ bool RelativePointPath::operator== (const RelativePointPath& other) const throw( return false; int numPoints1, numPoints2; - RelativePoint* const points1 = e1->getControlPoints (numPoints1); - RelativePoint* const points2 = e2->getControlPoints (numPoints2); + const RelativePoint* const points1 = e1->getControlPoints (numPoints1); + const RelativePoint* const points2 = e2->getControlPoints (numPoints2); jassert (numPoints1 == numPoints2); @@ -108,6 +106,7 @@ void RelativePointPath::swapWith (RelativePointPath& other) throw() { elements.swapWithArray (other.elements); swapVariables (usesNonZeroWinding, other.usesNonZeroWinding); + swapVariables (containsDynamicPoints, other.containsDynamicPoints); } void RelativePointPath::createPath (Path& path, Expression::EvaluationContext* coordFinder) const diff --git a/src/gui/components/positioning/juce_RelativePointPath.h b/src/gui/components/positioning/juce_RelativePointPath.h index a1cf98b89f..ff9ba1c8b9 100644 --- a/src/gui/components/positioning/juce_RelativePointPath.h +++ b/src/gui/components/positioning/juce_RelativePointPath.h @@ -46,7 +46,7 @@ public: //============================================================================== RelativePointPath(); RelativePointPath (const RelativePointPath& other); - RelativePointPath (const Path& path); + explicit RelativePointPath (const Path& path); ~RelativePointPath(); bool operator== (const RelativePointPath& other) const throw(); diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.cpp b/src/gui/graphics/drawables/juce_DrawableComposite.cpp index ec07e85cfb..83759b064d 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.cpp +++ b/src/gui/graphics/drawables/juce_DrawableComposite.cpp @@ -49,7 +49,7 @@ DrawableComposite::DrawableComposite (const DrawableComposite& other) { for (int i = 0; i < other.getNumChildComponents(); ++i) { - const Drawable* const d = dynamic_cast (getChildComponent(i)); + const Drawable* const d = dynamic_cast (other.getChildComponent(i)); if (d != 0) addAndMakeVisible (d->createCopy()); diff --git a/src/gui/graphics/drawables/juce_DrawablePath.cpp b/src/gui/graphics/drawables/juce_DrawablePath.cpp index f48836d9ec..8440ae44ed 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.cpp +++ b/src/gui/graphics/drawables/juce_DrawablePath.cpp @@ -74,7 +74,7 @@ const Path& DrawablePath::getStrokePath() const return strokePath; } -bool DrawablePath::rebuildPath (Path& path) const +bool DrawablePath::rebuildPath (Path&) const { return false; } @@ -142,22 +142,22 @@ const RelativePointPath* DrawablePath::getRelativePath() const return current != 0 ? &(current->path) : 0; } -void DrawablePath::setPath (const RelativePointPath& source) +void DrawablePath::setPath (const RelativePointPath& newRelativePath) { - if (source.containsAnyDynamicPoints()) + if (newRelativePath.containsAnyDynamicPoints()) { const RelativePointPath* current = getRelativePath(); - if (current == 0 || source != *current) + if (current == 0 || newRelativePath != *current) { - RelativePositioner* const p = new RelativePositioner (*this, source); + RelativePositioner* const p = new RelativePositioner (*this, newRelativePath); setPositioner (p); p->apply(); } } else { - applyRelativePath (source); + applyRelativePath (newRelativePath); } } diff --git a/src/gui/graphics/drawables/juce_DrawablePath.h b/src/gui/graphics/drawables/juce_DrawablePath.h index fd21612703..16dc035331 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.h +++ b/src/gui/graphics/drawables/juce_DrawablePath.h @@ -55,8 +55,11 @@ public: */ void setPath (const Path& newPath); - /** */ - void setPath (const RelativePointPath& source); + /** Sets the path using a RelativePointPath. + Calling this will set up a Component::Positioner to automatically update the path + if any of the points in the source path are dynamic. + */ + void setPath (const RelativePointPath& newPath); /** Returns the current path. */ const Path& getPath() const;