Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
anonymous_namespace{TrackView.cpp}::TrackPositioner Struct Referencefinal
Inheritance diagram for anonymous_namespace{TrackView.cpp}::TrackPositioner:
Collaboration diagram for anonymous_namespace{TrackView.cpp}::TrackPositioner:

Public Member Functions

 TrackPositioner (AudacityProject &project)
 TrackPositioner (const TrackPositioner &) PROHIBITED
TrackPositioneroperator= (const TrackPositioner &) PROHIBITED
void OnUpdate (const TrackListEvent &e)
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()

Public Attributes

Observer::Subscription mSubscription

Detailed Description

Attached to each project, it receives track list events and maintains the cache of cumulative track view heights for use by TrackPanel.

Definition at line 194 of file TrackView.cpp.

Constructor & Destructor Documentation

◆ TrackPositioner() [1/2]

anonymous_namespace{TrackView.cpp}::TrackPositioner::TrackPositioner ( AudacityProject project)

Definition at line 198 of file TrackView.cpp.

199 : mProject{ project }
200 {
201 mSubscription = TrackList::Get( project )
203 }
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:370

References TrackList::Get(), and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

◆ TrackPositioner() [2/2]

anonymous_namespace{TrackView.cpp}::TrackPositioner::TrackPositioner ( const TrackPositioner )

Member Function Documentation

◆ OnUpdate()

void anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate ( const TrackListEvent e)

Definition at line 207 of file TrackView.cpp.

208 {
209 switch (e.mType) {
214 break;
215 default:
216 return;
217 }
218 auto iter =
219 TrackList::Get( mProject ).Find( e.mpTrack.lock().get() );
220 if ( !*iter )
221 return;
223 auto prev = iter;
224 auto yy = TrackView::GetCumulativeHeight( *--prev );
226 while( auto pTrack = *iter ) {
227 auto &view = TrackView::Get( *pTrack );
228 view.SetCumulativeHeightBefore( yy );
229 yy += view.GetHeight();
230 ++iter;
231 }
232 }
auto Find(Track *pTrack) -> TrackIter< TrackType >
Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.
Definition: Track.h:972
static int GetCumulativeHeight(const Track *pTrack)
Definition: TrackView.cpp:39
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
const std::weak_ptr< Track > mpTrack
Definition: Track.h:897
const Type mType
Definition: Track.h:896
Posted when some track changed its height.
Definition: Track.h:875
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:884
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:878
Posted when tracks are reordered but otherwise unchanged.
Definition: Track.h:872

References TrackListEvent::ADDITION, TrackListEvent::DELETION, TrackList::Find(), TrackList::Get(), TrackView::Get(), TrackView::GetCumulativeHeight(), TrackListEvent::mpTrack, TrackListEvent::mType, TrackListEvent::PERMUTED, and TrackListEvent::RESIZING.

Here is the call graph for this function:

◆ operator=()

TrackPositioner & anonymous_namespace{TrackView.cpp}::TrackPositioner::operator= ( const TrackPositioner )

Member Data Documentation

◆ mProject

AudacityProject& anonymous_namespace{TrackView.cpp}::TrackPositioner::mProject

Definition at line 196 of file TrackView.cpp.

◆ mSubscription

Observer::Subscription anonymous_namespace{TrackView.cpp}::TrackPositioner::mSubscription

Definition at line 234 of file TrackView.cpp.

The documentation for this struct was generated from the following file: