Audacity  3.0.3
NoteTrackShifter.cpp
Go to the documentation of this file.
1 
6 #include "../../../ui/TimeShiftHandle.h"
7 #include "../../../../NoteTrack.h"
8 #include "ViewInfo.h"
9 
10 class NoteTrackShifter final : public TrackShifter {
11 public:
13  : mpTrack{ track.SharedPointer<NoteTrack>() }
14  {
15  InitIntervals();
16  }
17  ~NoteTrackShifter() override {}
18  Track &GetTrack() const override { return *mpTrack; }
19 
21  double time, const ViewInfo &viewInfo, HitTestParams* ) override
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  }
31 
32  void SelectInterval( const TrackInterval &interval ) override
33  {
34  CommonSelectInterval( interval );
35  }
36 
37  bool SyncLocks() override { return true; }
38 
39  // Ensure that t0 is still within the data.
40  // This corrects for any rounding errors.
41  double AdjustT0(double t0) const override
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  }
51 
52 private:
53  std::shared_ptr<NoteTrack> mpTrack;
54 };
55 
58  return [](NoteTrack &track, AudacityProject&) {
59  return std::make_unique<NoteTrackShifter>(track);
60  };
61 }
TrackShifter::UnfixAll
void UnfixAll()
Change all intervals from fixed to moving.
Definition: TimeShiftHandle.cpp:147
NoteTrackShifter::AdjustT0
double AdjustT0(double t0) const override
Definition: NoteTrackShifter.cpp:41
ViewInfo
Definition: ViewInfo.h:202
Track::SharedPointer
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:291
NoteTrackShifter::HitTest
HitTestResult HitTest(double time, const ViewInfo &viewInfo, HitTestParams *) override
Decide how shift behaves, based on the track that is clicked in.
Definition: NoteTrackShifter.cpp:20
TrackInterval
A start and an end time, and mutative access to optional extra information.
Definition: Track.h:219
NoteTrackShifter
Definition: NoteTrackShifter.cpp:10
NoteTrackShifter::SelectInterval
void SelectInterval(const TrackInterval &interval) override
Notifies the shifter that a region is selected, so it may update its fixed and moving intervals.
Definition: NoteTrackShifter.cpp:32
NotifyingSelectedRegion::t1
double t1() const
Definition: ViewInfo.h:48
NoteTrackShifter::~NoteTrackShifter
~NoteTrackShifter() override
Definition: NoteTrackShifter.cpp:17
TrackShifter
Abstract base class for policies to manipulate a track type with the Time Shift tool.
Definition: TimeShiftHandle.h:33
TrackShifter::HitTestResult::Selection
@ Selection
Shift chosen intervals of this track; may shift other tracks' intervals.
TrackShifter::HitTestResult
HitTestResult
Possibilities for HitTest on the clicked track.
Definition: TimeShiftHandle.h:44
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:229
NoteTrackShifter::NoteTrackShifter
NoteTrackShifter(NoteTrack &track)
Definition: NoteTrackShifter.cpp:12
TrackShifter::InitIntervals
void InitIntervals()
Derived class constructor can initialize all intervals reported by the track as fixed,...
Definition: TimeShiftHandle.cpp:250
NoteTrackShifter::mpTrack
std::shared_ptr< NoteTrack > mpTrack
Definition: NoteTrackShifter.cpp:53
ViewInfo.h
NoteTrackShifter::GetTrack
Track & GetTrack() const override
There is always an associated track.
Definition: NoteTrackShifter.cpp:18
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
TrackShifter::HitTestResult::Intervals
@ Intervals
Shift intervals only of selected track and sister channels.
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
AttachedVirtualFunction::Override
For defining overrides of the method.
Definition: AttachedVirtualFunction.h:184
NotifyingSelectedRegion::t0
double t0() const
Definition: ViewInfo.h:47
NoteTrackShifter::SyncLocks
bool SyncLocks() override
Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group.
Definition: NoteTrackShifter.cpp:37
DEFINE_ATTACHED_VIRTUAL_OVERRIDE
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(MakeNoteTrackShifter)
Definition: NoteTrackShifter.cpp:57
TrackShifter::CommonSelectInterval
void CommonSelectInterval(const TrackInterval &interval)
Definition: TimeShiftHandle.cpp:159
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:67
TrackShifter::HitTestParams
Optional, more complete information for hit testing.
Definition: TimeShiftHandle.h:52