Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
NoteTrackShifter Class Referencefinal
Inheritance diagram for NoteTrackShifter:
[legend]
Collaboration diagram for NoteTrackShifter:
[legend]

Public Member Functions

 NoteTrackShifter (NoteTrack &track)
 
 ~NoteTrackShifter () override
 
TrackGetTrack () const override
 There is always an associated track. More...
 
HitTestResult HitTest (double time, const ViewInfo &viewInfo, HitTestParams *) override
 Decide how shift behaves, based on the track that is clicked in. More...
 
void SelectInterval (TimeInterval interval) override
 Notifies the shifter that a region is selected, so it may update its fixed and moving intervals. More...
 
bool SyncLocks () override
 Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group. More...
 
double AdjustT0 (double t0) const override
 
- Public Member Functions inherited from TrackShifter
 TrackShifter ()
 
 TrackShifter (const TrackShifter &)=delete
 
TrackShifteroperator= (const TrackShifter &)=delete
 
virtual ~TrackShifter ()=0
 
virtual TrackGetTrack () const =0
 There is always an associated track. More...
 
virtual HitTestResult HitTest (double time, const ViewInfo &viewInfo, HitTestParams *pParams=nullptr)=0
 Decide how shift behaves, based on the track that is clicked in. More...
 
const IntervalsFixedIntervals () const
 Return special intervals of the track that will not move. More...
 
const IntervalsMovingIntervals () const
 Return special intervals of the track that may move. More...
 
void UnfixIntervals (std::function< bool(const ChannelGroupInterval &)> pred)
 Change intervals satisfying a predicate from fixed to moving. More...
 
void UnfixAll ()
 Change all intervals from fixed to moving. More...
 
virtual void SelectInterval (TimeInterval interval)
 Notifies the shifter that a region is selected, so it may update its fixed and moving intervals. More...
 
virtual bool SyncLocks ()=0
 Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group. More...
 
virtual double HintOffsetLarger (double desiredOffset)
 Given amount to shift by horizontally, maybe adjust it from zero to suggest minimum distance. More...
 
virtual double QuantizeOffset (double desiredOffset)
 Given amount to shift by horizontally, do any preferred rounding, before placement constraint checks. More...
 
virtual double AdjustOffsetSmaller (double desiredOffset)
 Given amount to shift by horizontally, maybe adjust it toward zero to meet placement constraints. More...
 
virtual bool MayMigrateTo (Track &otherTrack)
 
virtual Intervals Detach ()
 Remove all moving intervals from the track, if possible. More...
 
virtual bool AdjustFit (const Track &otherTrack, const Intervals &intervals, double &desiredOffset, double tolerance)
 
virtual bool Attach (Intervals intervals, double offset)
 Put moving intervals into the track, which may have migrated from another. More...
 
virtual bool FinishMigration ()
 When dragging is done, do (once) the final steps of migration (which may be expensive) More...
 
virtual void DoHorizontalOffset (double offset)
 
virtual double AdjustT0 (double t0) const
 

Private Attributes

const std::shared_ptr< NoteTrackmpTrack
 

Additional Inherited Members

- Public Types inherited from TrackShifter
enum class  HitTestResult { Miss , Selection , Intervals , Track }
 Possibilities for HitTest on the clicked track. More...
 
using Intervals = std::vector< std::shared_ptr< ChannelGroupInterval > >
 
- Protected Member Functions inherited from TrackShifter
void CommonSelectInterval (TimeInterval interval)
 
bool CommonMayMigrateTo (Track &otherTrack)
 
void InitIntervals ()
 Derived class constructor can initialize all intervals reported by the track as fixed, none moving. More...
 
bool AllFixed () const
 
- Protected Attributes inherited from TrackShifter
Intervals mFixed
 
Intervals mMoving
 

Detailed Description

Definition at line 10 of file NoteTrackShifter.cpp.

Constructor & Destructor Documentation

◆ NoteTrackShifter()

NoteTrackShifter::NoteTrackShifter ( NoteTrack track)
inline

Definition at line 12 of file NoteTrackShifter.cpp.

13 : mpTrack{ track.SharedPointer<NoteTrack>() }
14 {
16 }
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
const std::shared_ptr< NoteTrack > mpTrack
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:146
void InitIntervals()
Derived class constructor can initialize all intervals reported by the track as fixed,...

References TrackShifter::InitIntervals().

Here is the call graph for this function:

◆ ~NoteTrackShifter()

NoteTrackShifter::~NoteTrackShifter ( )
inlineoverride

Definition at line 17 of file NoteTrackShifter.cpp.

17{}

Member Function Documentation

◆ AdjustT0()

double NoteTrackShifter::AdjustT0 ( double  t0) const
inlineoverridevirtual

Reimplemented from TrackShifter.

Definition at line 41 of file NoteTrackShifter.cpp.

42 {
43 auto& track = GetTrack();
44 if (t0 < track.GetStartTime())
45 t0 = track.GetStartTime();
46 if (t0 > track.GetEndTime())
47 t0 = track.GetEndTime();
48
49 return t0;
50 }
Track & GetTrack() const override
There is always an associated track.

References GetTrack().

Here is the call graph for this function:

◆ GetTrack()

Track & NoteTrackShifter::GetTrack ( ) const
inlineoverridevirtual

There is always an associated track.

Implements TrackShifter.

Definition at line 18 of file NoteTrackShifter.cpp.

18{ return *mpTrack; }

References mpTrack.

Referenced by AdjustT0().

Here is the caller graph for this function:

◆ HitTest()

HitTestResult NoteTrackShifter::HitTest ( double  time,
const ViewInfo viewInfo,
HitTestParams pParams 
)
inlineoverridevirtual

Decide how shift behaves, based on the track that is clicked in.

If the return value is Intervals or Selection, then some intervals may be marked moving as a side effect

Precondition
!pParams || (time == pParams->viewInfo.PositionToTime(pParams->xx, pParams->rect.x))
Parameters
timeA time value to test
pParamsOptional extra information

Implements TrackShifter.

Definition at line 20 of file NoteTrackShifter.cpp.

22 {
23 UnfixAll();
24 auto t0 = viewInfo.selectedRegion.t0();
25 auto t1 = viewInfo.selectedRegion.t1();
26 if ( mpTrack->IsSelected() && time >= t0 && time < t1 )
28 else
30 }
double t1() const
Definition: ViewInfo.h:36
double t0() const
Definition: ViewInfo.h:35
void UnfixAll()
Change all intervals from fixed to moving.
@ Selection
Shift chosen intervals of this track; may shift other tracks' intervals.
@ Intervals
Shift intervals only of selected track and sister channels.
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216

References TrackShifter::Intervals, mpTrack, ViewInfo::selectedRegion, TrackShifter::Selection, NotifyingSelectedRegion::t0(), NotifyingSelectedRegion::t1(), and TrackShifter::UnfixAll().

Here is the call graph for this function:

◆ SelectInterval()

void NoteTrackShifter::SelectInterval ( TimeInterval  interval)
inlineoverridevirtual

Notifies the shifter that a region is selected, so it may update its fixed and moving intervals.

Default behavior: if any part of the track is selected, unfix all parts of it.

Reimplemented from TrackShifter.

Definition at line 32 of file NoteTrackShifter.cpp.

33 {
34 CommonSelectInterval(interval);
35 }
void CommonSelectInterval(TimeInterval interval)

References TrackShifter::CommonSelectInterval().

Here is the call graph for this function:

◆ SyncLocks()

bool NoteTrackShifter::SyncLocks ( )
inlineoverridevirtual

Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group.

Implements TrackShifter.

Definition at line 37 of file NoteTrackShifter.cpp.

37{ return true; }

Member Data Documentation

◆ mpTrack

const std::shared_ptr<NoteTrack> NoteTrackShifter::mpTrack
private

Definition at line 53 of file NoteTrackShifter.cpp.

Referenced by GetTrack(), and HitTest().


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