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);
53 if (
mpTrack->IsSelected() && time >= t0 && time < t1 )
65 return GetIndex( myInterval ) == iLabel;
111 auto moveLabel = [pTrack](
const auto &pInterval) {
113 auto result = std::make_shared<MovingInterval>(
114 pInterval->Start(), pInterval->End(), *pTrack->GetLabel(index));
115 pTrack->DeleteLabel(index);
138 std::for_each(intervals.rbegin(), intervals.rend(),
139 [
this, pTrack, offset](
const auto &pInterval){
140 auto data = static_cast<const MovingInterval&>(*pInterval);
142 data.region.move(offset);
143 auto index = pTrack->AddLabel(data.region, data.title);
145 mMoving.emplace_back(pTrack->MakeInterval(index));
152 auto &labels =
mpTrack->GetLabels();
155 auto labelStruct = labels[index];
156 labelStruct.selectedRegion.move(offset);
157 mpTrack->SetLabel(index, labelStruct);
173 if (former < 0 || present < 0) {
178 auto update = [=](
const auto &pInterval){
182 else if (former < index && index <= present)
184 else if (former > index && index >= present)
205 auto update = [=](
const auto &pInterval){
207 if (index >= present)
228 auto update = [=](
const auto &pInterval){
232 else if (index == former)
249 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
Label track is always leader; satisfying the post.
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)
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 SelectInterval(const ChannelGroupInterval &interval) override
Notifies the shifter that a region is selected, so it may update its fixed and moving intervals.
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(const ChannelGroupInterval &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
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
For defining overrides of the method.
const std::weak_ptr< Track > mpTrack
enum LabelTrackEvent::Type type
MovingInterval(double start, double end, const LabelStruct &label)
Optional, more complete information for hit testing.