7#include "../../ui/TimeShiftHandle.h"
8#include "../../../LabelTrack.h"
20 case LabelTrackEvent::Permutation:
21 return OnLabelPermuted(e);
22 case LabelTrackEvent::Addition:
23 return OnLabelAdded(e);
24 case LabelTrackEvent::Deletion:
25 return OnLabelDeleted(e);
54 if (
mpTrack->IsSelected() && time >= t0 && time < t1 )
66 return GetIndex( myInterval ) == iLabel;
116 interval.
Start(), interval.End(),
117 std::make_unique<IntervalData>( *pTrack->GetLabel(index) ) };
118 pTrack->DeleteLabel(index);
140 std::for_each( intervals.rbegin(), intervals.rend(),
141 [
this, pTrack, offset](
auto &interval){
142 auto pData = static_cast<IntervalData*>( interval.Extra() );
144 pData->region.move(offset);
145 auto index = pTrack->AddLabel(pData->region, pData->title);
147 mMoving.emplace_back( pTrack->MakeInterval(index) );
154 auto &labels =
mpTrack->GetLabels();
157 auto labelStruct = labels[index];
158 labelStruct.selectedRegion.move(offset);
159 mpTrack->SetLabel( index, labelStruct );
175 if (former < 0 || present < 0) {
182 if ( index == former )
184 else if ( former < index && index <= present )
186 else if ( former > index && index >= present )
209 auto &index = pExtra->
index;
210 if ( index >= present )
233 auto &index = pExtra->
index;
234 if ( index > former )
236 else if ( index == former )
253 return std::make_unique<LabelTrackShifter>(track, project);
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(MakeLabelTrackShifter)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
A LabelStruct holds information for ONE label in a LabelTrack.
A LabelTrack is a Track that holds labels (LabelStruct).
Track & GetTrack() const override
There is always an associated track.
static size_t GetIndex(const TrackInterval &interval)
void DoHorizontalOffset(double offset) override
AudacityProject & mProject
std::shared_ptr< LabelTrack > mpTrack
bool MayMigrateTo(Track &otherTrack) override
Whether intervals may migrate to the other track, not yet checking all placement constraints */.
void OnLabelPermuted(const LabelTrackEvent &e)
void SelectInterval(const TrackInterval &interval) override
Notifies the shifter that a region is selected, so it may update its fixed and moving intervals.
Intervals Detach() override
Remove all moving intervals from the track, if possible.
void OnLabelAdded(const LabelTrackEvent &e)
static size_t & GetIndex(TrackInterval &interval)
~LabelTrackShifter() override
LabelTrackShifter(LabelTrack &track, AudacityProject &project)
Observer::Subscription mSubscription
bool SyncLocks() override
Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group.
bool AdjustFit(const Track &, const Intervals &, double &, double) override
Test whether intervals can fit into another track, maybe adjusting the offset slightly.
HitTestResult HitTest(double time, const ViewInfo &viewInfo, HitTestParams *pParams) override
Decide how shift behaves, based on the track that is clicked in.
bool Attach(Intervals intervals, double offset) override
Put moving intervals into the track, which may have migrated from another.
void OnLabelDeleted(const LabelTrackEvent e)
static LabelTrackView & Get(LabelTrack &)
static int OverATextBox(const LabelTrack &track, int xx, int yy)
int GetNavigationIndex(AudacityProject &project) const
A move-only handle representing a connection to a Publisher.
Defines a selected portion of a project.
Abstract base class for an object holding data associated with points on a time axis.
A start and an end time, and mutative access to optional extra information.
TrackIntervalData * Extra() const
Abstract base class for policies to manipulate a track type with the Time Shift tool.
std::vector< TrackInterval > Intervals
void CommonSelectInterval(const TrackInterval &interval)
void UnfixIntervals(std::function< bool(const TrackInterval &) > pred)
Change intervals satisfying a predicate from fixed to moving.
void InitIntervals()
Derived class constructor can initialize all intervals reported by the track as fixed,...
const Intervals & MovingIntervals() const
Return special intervals of the track that may move.
bool CommonMayMigrateTo(Track &otherTrack)
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.
@ Track
Shift selected track and sister channels only, as a whole.
NotifyingSelectedRegion selectedRegion
For defining overrides of the method.
const std::weak_ptr< Track > mpTrack
enum LabelTrackEvent::Type type
IntervalData(const LabelStruct &label)
Optional extra information about an interval, appropriate to a subtype of Track.
Optional, more complete information for hit testing.