![]() |
Audacity 3.2.0
|
Abstract base class for policies to manipulate a track type with the Time Shift tool. More...
#include <TimeShiftHandle.h>
Classes | |
struct | HitTestParams |
Optional, more complete information for hit testing. More... | |
Public Types | |
enum class | HitTestResult { Miss , Selection , Intervals , Track } |
Possibilities for HitTest on the clicked track. More... | |
using | Intervals = std::vector< TrackInterval > |
Public Member Functions | |
TrackShifter () | |
TrackShifter (const TrackShifter &) PROHIBITED | |
TrackShifter & | operator= (const TrackShifter &) PROHIBITED |
virtual | ~TrackShifter ()=0 |
virtual Track & | GetTrack () 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 Intervals & | FixedIntervals () const |
Return special intervals of the track that will not move. More... | |
const Intervals & | MovingIntervals () const |
Return special intervals of the track that may move. More... | |
void | UnfixIntervals (std::function< bool(const TrackInterval &) > pred) |
Change intervals satisfying a predicate from fixed to moving. More... | |
void | UnfixAll () |
Change all intervals from fixed to moving. More... | |
virtual void | SelectInterval (const TrackInterval &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) |
Whether intervals may migrate to the other track, not yet checking all placement constraints */. More... | |
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) |
Test whether intervals can fit into another track, maybe adjusting the offset slightly. More... | |
virtual bool | Attach (Intervals intervals) |
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 |
Protected Member Functions | |
void | CommonSelectInterval (const TrackInterval &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 | |
Intervals | mFixed |
Intervals | mMoving |
Private Attributes | |
bool | mAllFixed = true |
Abstract base class for policies to manipulate a track type with the Time Shift tool.
Definition at line 33 of file TimeShiftHandle.h.
using TrackShifter::Intervals = std::vector<TrackInterval> |
Definition at line 69 of file TimeShiftHandle.h.
|
strong |
Possibilities for HitTest on the clicked track.
Definition at line 44 of file TimeShiftHandle.h.
|
default |
TrackShifter::TrackShifter | ( | const TrackShifter & | ) |
|
pure virtualdefault |
|
virtual |
Test whether intervals can fit into another track, maybe adjusting the offset slightly.
Default implementation does nothing and returns false
intervals | Assume these came from Detach() and only after MayMigrateTo returned true for otherTrack | |
[in,out] | desiredOffset | |
tolerance | Nonnegative ceiling for allowed changes in fabs(desiredOffset) |
Reimplemented in LabelTrackShifter, and WaveTrackShifter.
Definition at line 224 of file TimeShiftHandle.cpp.
|
virtual |
Given amount to shift by horizontally, maybe adjust it toward zero to meet placement constraints.
Default implementation returns the argument
fabs(r) <= fabs(desiredOffset)
r * desiredOffset >= 0
(i.e. signs are not opposite) r
is return value) Reimplemented in WaveTrackShifter.
Definition at line 178 of file TimeShiftHandle.cpp.
|
virtual |
Reimplemented in NoteTrackShifter, and WaveTrackShifter.
Definition at line 246 of file TimeShiftHandle.cpp.
|
inlineprotected |
Definition at line 170 of file TimeShiftHandle.h.
Referenced by DoHorizontalOffset().
|
virtual |
Put moving intervals into the track, which may have migrated from another.
In case of failure, track states are unspecified
Default implementation does nothing and returns true
Reimplemented in LabelTrackShifter, and WaveTrackShifter.
Definition at line 230 of file TimeShiftHandle.cpp.
|
protected |
May be useful to override MayMigrateTo()
, if certain other needed overrides are given. Returns true, iff: tracks have same type, and corresponding positions in their channel groups, which have same size
Definition at line 188 of file TimeShiftHandle.cpp.
References TrackList::Channels(), Track::GetOwner(), GetTrack(), and Track::SameKindAs().
Referenced by WaveTrackShifter::MayMigrateTo(), and LabelTrackShifter::MayMigrateTo().
|
protected |
Unfix any of the intervals that intersect the given one; may be useful to override SelectInterval()
Definition at line 160 of file TimeShiftHandle.cpp.
References ConstTrackInterval::End(), ConstTrackInterval::Start(), and UnfixIntervals().
Referenced by LabelTrackShifter::SelectInterval(), and NoteTrackShifter::SelectInterval().
|
virtual |
Remove all moving intervals from the track, if possible.
Default implementation does nothing
Reimplemented in LabelTrackShifter, and WaveTrackShifter.
Definition at line 219 of file TimeShiftHandle.cpp.
|
virtual |
Shift all moving intervals horizontally Default moves the whole track, provided !AllFixed()
; else does nothing
Reimplemented in LabelTrackShifter, and WaveTrackShifter.
Definition at line 240 of file TimeShiftHandle.cpp.
References AllFixed(), GetTrack(), and Track::Offset().
|
virtual |
When dragging is done, do (once) the final steps of migration (which may be expensive)
In case of failure, track states are unspecified
Default implementation does nothing and returns true
Reimplemented in WaveTrackShifter.
Definition at line 235 of file TimeShiftHandle.cpp.
|
inline |
Return special intervals of the track that will not move.
Definition at line 72 of file TimeShiftHandle.h.
|
pure virtual |
There is always an associated track.
Implemented in LabelTrackShifter, NoteTrackShifter, WaveTrackShifter, and CoarseTrackShifter.
Referenced by CommonMayMigrateTo(), DoHorizontalOffset(), and InitIntervals().
|
virtual |
Given amount to shift by horizontally, maybe adjust it from zero to suggest minimum distance.
Any interval placement constraints, not necessarily met at the suggested offset Default implementation returns the argument
fabs(r) >= fabs(desiredOffset)
r * desiredOffset >= 0
(i.e. signs are not opposite) r
is return value) Reimplemented in WaveTrackShifter.
Definition at line 168 of file TimeShiftHandle.cpp.
|
pure virtual |
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
!pParams || (time == pParams->viewInfo.PositionToTime(pParams->xx, pParams->rect.x))
time | A time value to test |
pParams | Optional extra information |
Implemented in NoteTrackShifter, WaveTrackShifter, LabelTrackShifter, and CoarseTrackShifter.
|
protected |
Derived class constructor can initialize all intervals reported by the track as fixed, none moving.
This can't be called by the base class constructor, when GetTrack() isn't yet callable
Definition at line 251 of file TimeShiftHandle.cpp.
References Track::GetIntervals(), GetTrack(), mFixed, and mMoving.
Referenced by CoarseTrackShifter::CoarseTrackShifter(), LabelTrackShifter::LabelTrackShifter(), NoteTrackShifter::NoteTrackShifter(), and WaveTrackShifter::WaveTrackShifter().
|
virtual |
Whether intervals may migrate to the other track, not yet checking all placement constraints */.
Default implementation returns false
Reimplemented in WaveTrackShifter, and LabelTrackShifter.
Definition at line 183 of file TimeShiftHandle.cpp.
|
inline |
Return special intervals of the track that may move.
Definition at line 75 of file TimeShiftHandle.h.
Referenced by WaveTrackShifter::AdjustOffsetSmaller(), WaveTrackShifter::AdjustT0(), LabelTrackShifter::DoHorizontalOffset(), and WaveTrackShifter::DoHorizontalOffset().
TrackShifter & TrackShifter::operator= | ( | const TrackShifter & | ) |
|
virtual |
Given amount to shift by horizontally, do any preferred rounding, before placement constraint checks.
Default implementation returns argument
Reimplemented in WaveTrackShifter.
Definition at line 173 of file TimeShiftHandle.cpp.
|
virtual |
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 in LabelTrackShifter, NoteTrackShifter, and WaveTrackShifter.
Definition at line 155 of file TimeShiftHandle.cpp.
References UnfixAll().
|
pure virtual |
Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group.
Implemented in LabelTrackShifter, NoteTrackShifter, WaveTrackShifter, and CoarseTrackShifter.
void TrackShifter::UnfixAll | ( | ) |
Change all intervals from fixed to moving.
Definition at line 148 of file TimeShiftHandle.cpp.
References mAllFixed, mFixed, and mMoving.
Referenced by NoteTrackShifter::HitTest(), and SelectInterval().
void TrackShifter::UnfixIntervals | ( | std::function< bool(const TrackInterval &) > | pred | ) |
Change intervals satisfying a predicate from fixed to moving.
Definition at line 134 of file TimeShiftHandle.cpp.
References mAllFixed, mFixed, and mMoving.
Referenced by CommonSelectInterval(), WaveTrackShifter::HitTest(), LabelTrackShifter::HitTest(), and WaveTrackShifter::SelectInterval().
|
private |
Becomes false after UnfixAll()
, even if there are no intervals, or if any one interval was unfixed
Definition at line 178 of file TimeShiftHandle.h.
Referenced by UnfixAll(), and UnfixIntervals().
|
protected |
Definition at line 174 of file TimeShiftHandle.h.
Referenced by InitIntervals(), LabelTrackShifter::OnLabelAdded(), LabelTrackShifter::OnLabelDeleted(), LabelTrackShifter::OnLabelPermuted(), UnfixAll(), and UnfixIntervals().
|
protected |
Definition at line 175 of file TimeShiftHandle.h.
Referenced by WaveTrackShifter::Attach(), LabelTrackShifter::Detach(), WaveTrackShifter::Detach(), LabelTrackShifter::HitTest(), InitIntervals(), LabelTrackShifter::OnLabelAdded(), LabelTrackShifter::OnLabelDeleted(), LabelTrackShifter::OnLabelPermuted(), UnfixAll(), and UnfixIntervals().