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

125{ return mActive; }
bool mActive
Definition: ViewInfo.h:184

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

References invalidValue, and SetAllTimes().

Here is the call graph for this function:

◆ Empty()

bool PlayRegion::Empty ( ) const
inline

Definition at line 128 of file ViewInfo.h.

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

Referenced by ProjectTempoListener::OnProjectTempoChange().

Here is the caller graph for this function:

◆ GetEnd()

double PlayRegion::GetEnd ( ) const
inline

Definition at line 136 of file ViewInfo.h.

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

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

Here is the caller graph for this function:

◆ GetLastActiveEnd()

double PlayRegion::GetLastActiveEnd ( ) const
inline

Definition at line 150 of file ViewInfo.h.

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

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

Here is the caller graph for this function:

◆ GetLastActiveStart()

double PlayRegion::GetLastActiveStart ( ) const
inline

Definition at line 143 of file ViewInfo.h.

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

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

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:143
double GetLastActiveEnd() const
Definition: ViewInfo.h:150

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

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

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

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

◆ mActive

bool PlayRegion::mActive { false }
private

Definition at line 184 of file ViewInfo.h.

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

◆ mEnd

double PlayRegion::mEnd { invalidValue }
private

Definition at line 180 of file ViewInfo.h.

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

◆ mLastActiveEnd

double PlayRegion::mLastActiveEnd { invalidValue }
private

Definition at line 182 of file ViewInfo.h.

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

◆ mLastActiveStart

double PlayRegion::mLastActiveStart { invalidValue }
private

Definition at line 181 of file ViewInfo.h.

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

◆ mStart

double PlayRegion::mStart { invalidValue }
private

Definition at line 179 of file ViewInfo.h.

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


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