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 DefaultPlayOptions(), 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 197 of file ViewInfo.cpp.

198{
200}
void SetAllTimes(double start, double end)
Definition: ViewInfo.cpp:191
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 DefaultPlayOptions(), 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 202 of file ViewInfo.cpp.

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

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 207 of file ViewInfo.cpp.

208{
210}
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 222 of file ViewInfo.cpp.

223{
224 Publish({});
225}
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 212 of file ViewInfo.cpp.

213{
214 if ( mStart >= 0 && mEnd >= 0 && mStart > mEnd) {
216 if (mActive)
218 Notify();
219 }
220}
void Notify()
Definition: ViewInfo.cpp:222
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:753

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 146 of file ViewInfo.cpp.

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

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 191 of file ViewInfo.cpp.

192{
193 SetTimes(start, end);
195}
void SetTimes(double start, double end)
Definition: ViewInfo.cpp:181
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 171 of file ViewInfo.cpp.

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

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 161 of file ViewInfo.cpp.

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

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 181 of file ViewInfo.cpp.

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

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: