7#include "../../ui/TimeShiftHandle.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);
52 if (
mpTrack->IsSelected() && time >= t0 && time < t1 )
64 return GetIndex( myInterval ) == iLabel;
106 double End()
const override {
return end; }
113 auto moveLabel = [pTrack](
const auto &pInterval) {
115 auto result = std::make_shared<MovingInterval>(
116 pInterval->Start(), pInterval->End(), *pTrack->GetLabel(index));
117 pTrack->DeleteLabel(index);
140 std::for_each(intervals.rbegin(), intervals.rend(),
141 [
this, pTrack, offset](
const auto &pInterval){
142 auto data = static_cast<const MovingInterval&>(*pInterval);
144 data.region.move(offset);
145 auto index = pTrack->AddLabel(data.region, data.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) {
180 auto update = [=](
const auto &pInterval){
184 else if (former < index && index <= present)
186 else if (former > index && index >= present)
207 auto update = [=](
const auto &pInterval){
209 if (index >= present)
230 auto update = [=](
const auto &pInterval){
234 else if (index == former)
251 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 start and an end time, and whatever else subclasses associate with them.
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(ChannelGroupInterval &interval)
void DoHorizontalOffset(double offset) override
AudacityProject & mProject
static size_t GetIndex(const ChannelGroupInterval &interval)
bool MayMigrateTo(Track &otherTrack) override
void OnLabelPermuted(const LabelTrackEvent &e)
void SelectInterval(TimeInterval 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)
~LabelTrackShifter() override
const std::shared_ptr< LabelTrack > mpTrack
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
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.
Abstract base class for policies to manipulate a track type for Time Shift.
void CommonSelectInterval(TimeInterval interval)
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.
void UnfixIntervals(std::function< bool(const ChannelGroupInterval &)> pred)
Change intervals satisfying a predicate from fixed to moving.
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.
std::vector< std::shared_ptr< ChannelGroupInterval > > Intervals
NotifyingSelectedRegion selectedRegion
For defining overrides of the method.
const std::weak_ptr< Track > mpTrack
enum LabelTrackEvent::Type type
MovingInterval(double start, double end, const LabelStruct &label)
double Start() const override
double End() const override
Optional, more complete information for hit testing.