Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
PlayRegion Class Reference

#include <ViewInfo.h>

Inheritance diagram for PlayRegion:
[legend]
Collaboration diagram for PlayRegion:
[legend]

Public Member Functions

 PlayRegion ()=default
 
 PlayRegion (const PlayRegion &)=delete
 
PlayRegionoperator= (const PlayRegion &that)
 
bool Active () const
 
void SetActive (bool active)
 
bool Empty () const
 
double GetStart () const
 
double GetEnd () const
 
double GetLastActiveStart () const
 
double GetLastActiveEnd () const
 
void SetStart (double start)
 
void SetEnd (double end)
 
void SetTimes (double start, double end)
 
void SetAllTimes (double start, double end)
 
void Clear ()
 Set to an invalid state. More...
 
bool IsClear () const
 Test whether in invalid state. More...
 
bool IsLastActiveRegionClear () const
 Test whether last active region is in invalid state. More...
 
void Order ()
 
- Public Member Functions inherited from Observer::Publisher< PlayRegionMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Private Member Functions

void Notify ()
 

Private Attributes

double mStart { invalidValue }
 
double mEnd { invalidValue }
 
double mLastActiveStart { invalidValue }
 
double mLastActiveEnd { invalidValue }
 
bool mActive { false }
 

Static Private Attributes

static constexpr auto invalidValue = std::numeric_limits<double>::min()
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< PlayRegionMessage >
using message_type = PlayRegionMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const PlayRegionMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< PlayRegionMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< PlayRegionMessage >
CallbackReturn Publish (const PlayRegionMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Definition at line 105 of file ViewInfo.h.

Constructor & Destructor Documentation

◆ PlayRegion() [1/2]

PlayRegion::PlayRegion ( )
default

◆ PlayRegion() [2/2]

PlayRegion::PlayRegion ( const PlayRegion )
delete

Member Function Documentation

◆ Active()

bool PlayRegion::Active ( ) const
inline

Definition at line 123 of file ViewInfo.h.

123{ return mActive; }
bool mActive
Definition: ViewInfo.h:182

Referenced by AdornedRulerPanel::DoSelectionChange(), and anonymous_namespace{TransportMenus.cpp}::IsLoopingEnabled().

Here is the caller graph for this function:

◆ Clear()

void PlayRegion::Clear ( )

Set to an invalid state.

Definition at line 196 of file ViewInfo.cpp.

197{
199}
void SetAllTimes(double start, double end)
Definition: ViewInfo.cpp:190
static constexpr auto invalidValue
Definition: ViewInfo.h:175

References invalidValue, and SetAllTimes().

Here is the call graph for this function:

◆ Empty()

bool PlayRegion::Empty ( ) const
inline

Definition at line 126 of file ViewInfo.h.

126{ return GetStart() == GetEnd(); }
double GetStart() const
Definition: ViewInfo.h:127
double GetEnd() const
Definition: ViewInfo.h:134

◆ GetEnd()

double PlayRegion::GetEnd ( ) const
inline

Definition at line 134 of file ViewInfo.h.

135 {
136 if ( mStart < 0 )
137 return mEnd;
138 else
139 return std::max( mStart, mEnd );
140 }
double mEnd
Definition: ViewInfo.h:178
double mStart
Definition: ViewInfo.h:177

Referenced by IsClear(), and operator=().

Here is the caller graph for this function:

◆ GetLastActiveEnd()

double PlayRegion::GetLastActiveEnd ( ) const
inline

Definition at line 148 of file ViewInfo.h.

149 {
150 if ( mLastActiveStart < 0 )
151 return mLastActiveEnd;
152 else
153 return std::max( mLastActiveStart, mLastActiveEnd );
154 }
double mLastActiveStart
Definition: ViewInfo.h:179
double mLastActiveEnd
Definition: ViewInfo.h:180

Referenced by IsLastActiveRegionClear(), and operator=().

Here is the caller graph for this function:

◆ GetLastActiveStart()

double PlayRegion::GetLastActiveStart ( ) const
inline

Definition at line 141 of file ViewInfo.h.

142 {
143 if ( mLastActiveEnd < 0 )
144 return mLastActiveStart;
145 else
147 }
int min(int a, int b)

References min().

Referenced by IsLastActiveRegionClear(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStart()

double PlayRegion::GetStart ( ) const
inline

Definition at line 127 of file ViewInfo.h.

128 {
129 if ( mEnd < 0 )
130 return mStart;
131 else
132 return std::min( mStart, mEnd );
133 }

References min().

Referenced by IsClear(), SelectionBar::OnIdle(), TimeToolBar::OnIdle(), operator=(), and TransportUtilities::PlayCurrentRegionAndWait().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsClear()

bool PlayRegion::IsClear ( ) const

Test whether in invalid state.

Definition at line 201 of file ViewInfo.cpp.

202{
203 return GetStart() == invalidValue && GetEnd() == invalidValue;
204}

References GetEnd(), GetStart(), and invalidValue.

Here is the call graph for this function:

◆ IsLastActiveRegionClear()

bool PlayRegion::IsLastActiveRegionClear ( ) const

Test whether last active region is in invalid state.

Definition at line 206 of file ViewInfo.cpp.

207{
209}
double GetLastActiveStart() const
Definition: ViewInfo.h:141
double GetLastActiveEnd() const
Definition: ViewInfo.h:148

References GetLastActiveEnd(), GetLastActiveStart(), and invalidValue.

Here is the call graph for this function:

◆ Notify()

void PlayRegion::Notify ( )
private

Definition at line 221 of file ViewInfo.cpp.

222{
223 Publish({});
224}
CallbackReturn Publish(const PlayRegionMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References Observer::Publisher< PlayRegionMessage >::Publish().

Referenced by Order(), SetActive(), SetEnd(), SetStart(), and SetTimes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

PlayRegion & PlayRegion::operator= ( const PlayRegion that)
inline

Definition at line 112 of file ViewInfo.h.

113 {
114 mActive = that.mActive;
115 // Guarantee the equivalent un-swapped order of endpoints
116 mStart = that.GetStart();
117 mEnd = that.GetEnd();
120 return *this;
121 }

References GetEnd(), GetLastActiveEnd(), GetLastActiveStart(), GetStart(), and mActive.

Here is the call graph for this function:

◆ Order()

void PlayRegion::Order ( )

Definition at line 211 of file ViewInfo.cpp.

212{
213 if ( mStart >= 0 && mEnd >= 0 && mStart > mEnd) {
215 if (mActive)
217 Notify();
218 }
219}
void Notify()
Definition: ViewInfo.cpp:221
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:752

References mActive, mEnd, mLastActiveEnd, mLastActiveStart, mStart, Notify(), and anonymous_namespace{NoteTrack.cpp}::swap().

Here is the call graph for this function:

◆ SetActive()

void PlayRegion::SetActive ( bool  active)

Definition at line 145 of file ViewInfo.cpp.

146{
147 if (mActive != active) {
148 mActive = active;
149 if (mActive) {
150 // Restore values
154 }
155 }
156 Notify();
157 }
158}

References mActive, mEnd, mLastActiveEnd, mLastActiveStart, mStart, and Notify().

Here is the call graph for this function:

◆ SetAllTimes()

void PlayRegion::SetAllTimes ( double  start,
double  end 
)

Definition at line 190 of file ViewInfo.cpp.

191{
192 SetTimes(start, end);
194}
void SetTimes(double start, double end)
Definition: ViewInfo.cpp:180
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), mLastActiveEnd, mLastActiveStart, and SetTimes().

Referenced by Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetEnd()

void PlayRegion::SetEnd ( double  end)

Definition at line 170 of file ViewInfo.cpp.

171{
172 if (mEnd != end) {
173 if (mActive)
175 mEnd = end;
176 Notify();
177 }
178}

References PackedArray::end(), mActive, mEnd, mLastActiveEnd, and Notify().

Referenced by AdornedRulerPanel::NewPlayRegionHandle::DoAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetStart()

void PlayRegion::SetStart ( double  start)

Definition at line 160 of file ViewInfo.cpp.

161{
162 if (mStart != start) {
163 if (mActive)
164 mLastActiveStart = start;
165 mStart = start;
166 Notify();
167 }
168}

References mActive, mLastActiveStart, mStart, and Notify().

Referenced by AdornedRulerPanel::ResizePlayRegionHandle::DoAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTimes()

void PlayRegion::SetTimes ( double  start,
double  end 
)

Definition at line 180 of file ViewInfo.cpp.

181{
182 if (mStart != start || mEnd != end) {
183 if (mActive)
185 mStart = start, mEnd = end;
186 Notify();
187 }
188}

References PackedArray::end(), mActive, mEnd, mLastActiveEnd, mLastActiveStart, mStart, and Notify().

Referenced by AdornedRulerPanel::MovePlayRegionHandle::DoAdjust(), AdornedRulerPanel::NewPlayRegionHandle::DoStartAdjust(), and SetAllTimes().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ invalidValue

constexpr auto PlayRegion::invalidValue = std::numeric_limits<double>::min()
staticconstexprprivate

Definition at line 175 of file ViewInfo.h.

Referenced by Clear(), IsClear(), and IsLastActiveRegionClear().

◆ mActive

bool PlayRegion::mActive { false }
private

Definition at line 182 of file ViewInfo.h.

Referenced by operator=(), Order(), SetActive(), SetEnd(), SetStart(), and SetTimes().

◆ mEnd

double PlayRegion::mEnd { invalidValue }
private

Definition at line 178 of file ViewInfo.h.

Referenced by Order(), SetActive(), SetEnd(), and SetTimes().

◆ mLastActiveEnd

double PlayRegion::mLastActiveEnd { invalidValue }
private

Definition at line 180 of file ViewInfo.h.

Referenced by Order(), SetActive(), SetAllTimes(), SetEnd(), and SetTimes().

◆ mLastActiveStart

double PlayRegion::mLastActiveStart { invalidValue }
private

Definition at line 179 of file ViewInfo.h.

Referenced by Order(), SetActive(), SetAllTimes(), SetStart(), and SetTimes().

◆ mStart

double PlayRegion::mStart { invalidValue }
private

Definition at line 177 of file ViewInfo.h.

Referenced by Order(), SetActive(), SetStart(), and SetTimes().


The documentation for this class was generated from the following files: