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 {}
19 Track &GetTrack() const override { return *mpTrack; }
20
22 double time, const ViewInfo &viewInfo, HitTestParams* ) override
23 {
24 UnfixAll();
25 auto t0 = viewInfo.selectedRegion.t0();
26 auto t1 = viewInfo.selectedRegion.t1();
27 if ( mpTrack->IsSelected() && time >= t0 && time < t1 )
29 else
31 }
32
33 void SelectInterval(const ChannelGroupInterval &interval) override
34 {
35 CommonSelectInterval(interval);
36 }
37
38 bool SyncLocks() override { return true; }
39
40 // Ensure that t0 is still within the data.
41 // This corrects for any rounding errors.
42 double AdjustT0(double t0) const override
43 {
44 auto& track = GetTrack();
45 if (t0 < track.GetStartTime())
46 t0 = track.GetStartTime();
47 if (t0 > track.GetEndTime())
48 t0 = track.GetEndTime();
49
50 return t0;
51 }
52
53private:
54 const std::shared_ptr<NoteTrack> mpTrack;
55};
56
59 return [](NoteTrack &track, AudacityProject&) {
60 return std::make_unique<NoteTrackShifter>(track);
61 };
62}
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 start and an end time, and whatever else subclasses associate with them.
Definition: Channel.h:30
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:86
void SelectInterval(const ChannelGroupInterval &interval) override
Notifies the shifter that a region is selected, so it may update its fixed and moving intervals.
Track & GetTrack() const override
Note track is always leader; satisfying the post.
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.
const std::shared_ptr< NoteTrack > mpTrack
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:122
Abstract base class for policies to manipulate a track type for Time Shift.
void CommonSelectInterval(const ChannelGroupInterval &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:215
For defining overrides of the method.
Optional, more complete information for hit testing.