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>::infinity()
 

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 106 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 124 of file ViewInfo.h.

124{ return mActive; }
bool mActive
Definition: ViewInfo.h:183

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

198{
200}
void SetAllTimes(double start, double end)
Definition: ViewInfo.cpp:191
static constexpr auto invalidValue
Definition: ViewInfo.h:176

References invalidValue, and SetAllTimes().

Here is the call graph for this function:

◆ Empty()

bool PlayRegion::Empty ( ) const
inline

Definition at line 127 of file ViewInfo.h.

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

Referenced by ProjectTempoListener::OnProjectTempoChange().

Here is the caller graph for this function:

◆ GetEnd()

double PlayRegion::GetEnd ( ) const
inline

Definition at line 135 of file ViewInfo.h.

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

Referenced by IsClear(), ProjectTempoListener::OnProjectTempoChange(), and operator=().

Here is the caller graph for this function:

◆ GetLastActiveEnd()

double PlayRegion::GetLastActiveEnd ( ) const
inline

Definition at line 149 of file ViewInfo.h.

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

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

Here is the caller graph for this function:

◆ GetLastActiveStart()

double PlayRegion::GetLastActiveStart ( ) const
inline

Definition at line 142 of file ViewInfo.h.

143 {
144 if ( mLastActiveEnd < 0 )
145 return mLastActiveStart;
146 else
148 }
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 128 of file ViewInfo.h.

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

References min().

Referenced by IsClear(), TimeToolBar::OnIdle(), ProjectTempoListener::OnProjectTempoChange(), 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:142
double GetLastActiveEnd() const
Definition: ViewInfo.h:149

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 113 of file ViewInfo.h.

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

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:628

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
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::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 details::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 details::end(), mActive, mEnd, mLastActiveEnd, mLastActiveStart, mStart, and Notify().

Referenced by AdornedRulerPanel::MovePlayRegionHandle::DoAdjust(), AdornedRulerPanel::NewPlayRegionHandle::DoStartAdjust(), ProjectTempoListener::OnProjectTempoChange(), 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>::infinity()
staticconstexprprivate

Definition at line 176 of file ViewInfo.h.

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

◆ mActive

bool PlayRegion::mActive { false }
private

Definition at line 183 of file ViewInfo.h.

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

◆ mEnd

double PlayRegion::mEnd { invalidValue }
private

Definition at line 179 of file ViewInfo.h.

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

◆ mLastActiveEnd

double PlayRegion::mLastActiveEnd { invalidValue }
private

Definition at line 181 of file ViewInfo.h.

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

◆ mLastActiveStart

double PlayRegion::mLastActiveStart { invalidValue }
private

Definition at line 180 of file ViewInfo.h.

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

◆ mStart

double PlayRegion::mStart { invalidValue }
private

Definition at line 178 of file ViewInfo.h.

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


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