From d28ae00d8816ec4f80e822e7453f716410f7141b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 24 May 2019 11:12:07 -0400 Subject: [PATCH] Remove friends from Envelope --- src/Envelope.h | 15 +++++++-------- src/commands/GetInfoCommand.cpp | 8 ++++---- src/commands/SetEnvelopeCommand.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Envelope.h b/src/Envelope.h index cb0f53420..aae010336 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -173,6 +173,8 @@ public: bool IsDirty() const; + void Clear() { mEnv.clear(); } + /** \brief Add a point at a particular absolute time coordinate */ int InsertOrReplace(double when, double value) { return InsertOrReplaceRelative( when - mOffset, value ); } @@ -191,16 +193,15 @@ public: /** \brief Return number of points */ size_t GetNumberOfPoints() const; -private: - int InsertOrReplaceRelative(double when, double value); - - friend class EnvelopeEditor; /** \brief Accessor for points */ const EnvPoint &operator[] (int index) const { return mEnv[index]; } +private: + int InsertOrReplaceRelative(double when, double value); + std::pair EqualRange( double when, double sampleDur ) const; public: @@ -219,11 +220,11 @@ public: bool GetDragPointValid() const { return mDragPointValid; } // Modify the dragged point and change its value. // But consistency constraints may move it less then you ask for. - -private: void MoveDragPoint(double newWhen, double value); // May delete the drag point. Restores envelope consistency. void ClearDragPoint(); + +private: void AddPointAtEnd( double t, double val ); void CopyRange(const Envelope &orig, size_t begin, size_t end); // relative time @@ -254,8 +255,6 @@ private: int mDragPoint { -1 }; mutable int mSearchGuess { -2 }; - friend class GetInfoCommand; - friend class SetEnvelopeCommand; }; inline void EnvPoint::SetVal( Envelope *pEnvelope, double val ) diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index 25574dec4..3223d6a04 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -567,12 +567,12 @@ bool GetInfoCommand::SendEnvelopes(const CommandContext &context) Envelope * pEnv = pClip->GetEnvelope(); context.StartField( "points" ); context.StartArray(); - double offset = pEnv->mOffset; - for( size_t k=0;kmEnv.size(); k++) + double offset = pEnv->GetOffset(); + for( size_t k = 0; k < pEnv->GetNumberOfPoints(); k++) { context.StartStruct( ); - context.AddItem( pEnv->mEnv[k].GetT()+offset, "t" ); - context.AddItem( pEnv->mEnv[k].GetVal(), "y" ); + context.AddItem( (*pEnv)[k].GetT()+offset, "t" ); + context.AddItem( (*pEnv)[k].GetVal(), "y" ); context.EndStruct(); } context.EndArray(); diff --git a/src/commands/SetEnvelopeCommand.cpp b/src/commands/SetEnvelopeCommand.cpp index 97df931cd..d9c7ce498 100644 --- a/src/commands/SetEnvelopeCommand.cpp +++ b/src/commands/SetEnvelopeCommand.cpp @@ -69,7 +69,7 @@ bool SetEnvelopeCommand::ApplyInner( const CommandContext &, Track * t ) // Inside this IF is where we actually apply the command Envelope* pEnv = pClip->GetEnvelope(); if( bHasDelete && mbDelete ) - pEnv->mEnv.clear(); + pEnv->Clear(); if( bHasT && bHasV ) pEnv->InsertOrReplace( mT, pEnv->ClampValue( mV ) ); }