Audacity 3.2.0
NoteTrackShifter.cpp
Go to the documentation of this file.
1
6#include "../../../ui/TimeShiftHandle.h"
7#include "../../../../NoteTrack.h"
8#include "ViewInfo.h"
9
10class NoteTrackShifter final : public TrackShifter {
11public:
13 : mpTrack{ track.SharedPointer<NoteTrack>() }
14 {
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
52private:
53 std::shared_ptr<NoteTrack> mpTrack;
54};
55
58 return [](NoteTrack &track, AudacityProject&) {
59 return std::make_unique<NoteTrackShifter>(track);
60 };
61}
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(MakeNoteTrackShifter)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:63
std::shared_ptr< NoteTrack > mpTrack
Track & GetTrack() const override
There is always an associated track.
NoteTrackShifter(NoteTrack &track)
double AdjustT0(double t0) const override
~NoteTrackShifter() override
bool SyncLocks() override
Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group.
HitTestResult HitTest(double time, const ViewInfo &viewInfo, HitTestParams *) override
Decide how shift behaves, based on the track that is clicked in.
void SelectInterval(const TrackInterval &interval) override
Notifies the shifter that a region is selected, so it may update its fixed and moving intervals.
double t1() const
Definition: ViewInfo.h:36
double t0() const
Definition: ViewInfo.h:35
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:226
A start and an end time, and mutative access to optional extra information.
Definition: Track.h:206
Abstract base class for policies to manipulate a track type with the Time Shift tool.
void CommonSelectInterval(const TrackInterval &interval)
void UnfixAll()
Change all intervals from fixed to moving.
void InitIntervals()
Derived class constructor can initialize all intervals reported by the track as fixed,...
HitTestResult
Possibilities for HitTest on the clicked track.
@ 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:219
For defining overrides of the method.
Optional, more complete information for hit testing.