11#ifndef __AUDACITY_TIMESHIFT_HANDLE__
12#define __AUDACITY_TIMESHIFT_HANDLE__
15#include <unordered_map>
19#include "../../UIHandle.h"
69 using Intervals = std::vector<std::shared_ptr<ChannelGroupInterval>>;
89 : mStart{ start }, mEnd{
std::max(start,
end) }
92 double Start()
const {
return mStart; }
93 double End()
const {
return mEnd; }
114 virtual double HintOffsetLarger(
double desiredOffset );
118 virtual double QuantizeOffset(
double desiredOffset );
127 virtual double AdjustOffsetSmaller(
double desiredOffset );
134 virtual bool MayMigrateTo(
Track &otherTrack);
145 virtual bool AdjustFit(
146 const Track &otherTrack,
150 double &desiredOffset,
164 virtual bool Attach(
Intervals intervals,
double offset);
172 virtual bool FinishMigration();
176 virtual void DoHorizontalOffset(
double offset );
181 virtual double AdjustT0(
double t0)
const;
193 bool CommonMayMigrateTo(
Track &otherTrack);
197 void InitIntervals();
200 return mAllFixed && mMoving.empty();
207 bool mAllFixed =
true;
228struct MakeTrackShifterTag;
245 using ShifterMap = std::unordered_map<Track*, std::unique_ptr<TrackShifter>>;
250 Track &capturedTrack,
252 std::unique_ptr<TrackShifter> pHit,
264 double DoSlideHorizontal(
double desiredSlideAmount);
267 void DoHorizontalOffset(
double offset);
271 bool initialized{
false };
272 bool movingSelection {};
273 bool wasMoved{
false };
274 double hSlideAmount {};
276 wxInt64 snapLeft { -1 }, snapRight { -1 };
284 movingSelection =
false;
287 snapLeft = snapRight = -1;
306 std::weak_ptr<TimeShiftHandle> &holder,
307 const std::shared_ptr<Track> &pTrack,
bool gripHit);
309 std::weak_ptr<TimeShiftHandle> &holder,
310 const wxMouseState &state,
const wxRect &rect,
311 const std::shared_ptr<Track> &pTrack);
315 std::shared_ptr<const Track>
FindTrack()
const override;
331 wxWindow *pParent)
override;
337 bool Clicked()
const;
339 std::shared_ptr<Track>
GetTrack()
const;
343 bool WasMoved()
const;
349 void DoSlideVertical(
351 TrackList &trackList,
Track *dstTrack,
double& desiredSlideAmount);
356 const wxRect &rect,
unsigned iPass )
override;
360 const wxRect &rect,
const wxRect &panelRect,
unsigned iPass )
override;
364 bool mDidSlideVertically{};
365 bool mSlideUpDownOnly{};
367 bool mSnapPreferRightEdge{};
373 std::shared_ptr<SnapManager> mSnapManager{};
Utility for non-intrusive definition of a new method on a base class.
std::shared_ptr< UIHandle > UIHandlePtr
@ Cancel
Open was cancelled by the extension.
std::vector< Track * > TrackArray
DECLARE_EXPORTED_ATTACHED_VIRTUAL(AUDACITY_DLL_API, MakeTrackShifter)
Class template generates single-dispatch, open method registry tables.
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.
CoarseTrackShifter(Track &track)
bool SyncLocks() override
Returns false.
Track & GetTrack() const override
There is always an associated track.
const std::shared_ptr< Track > mpTrack
~CoarseTrackShifter() override
HitTestResult HitTest(double, const ViewInfo &, HitTestParams *) override
Decide how shift behaves, based on the track that is clicked in.
TimeShiftHandle(const TimeShiftHandle &)=delete
bool StopsOnKeystroke() override
TimeShiftHandle & operator=(TimeShiftHandle &&)=default
Abstract base class for an object holding data associated with points on a time axis.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Abstract base class for policies to manipulate a track type for Time Shift.
virtual Track & GetTrack() const =0
There is always an associated track.
virtual HitTestResult HitTest(double time, const ViewInfo &viewInfo, HitTestParams *pParams=nullptr)=0
Decide how shift behaves, based on the track that is clicked in.
const Intervals & MovingIntervals() const
Return special intervals of the track that may move.
virtual ~TrackShifter()=0
HitTestResult
Possibilities for HitTest on the clicked track.
virtual bool SyncLocks()=0
Whether unfixing of an interval should propagate to all overlapping intervals in the sync lock group.
TrackShifter(const TrackShifter &)=delete
const Intervals & FixedIntervals() const
Return special intervals of the track that will not move.
TrackShifter & operator=(const TrackShifter &)=delete
std::vector< std::shared_ptr< ChannelGroupInterval > > Intervals
Short-lived drawing and event-handling object associated with a TrackPanelCell.
void Release(wxWindow *handler)
AUDACITY_DLL_API HitTestPreview HitPreview(const bool bVZoom)
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Track & GetTrack(Channel &channel)
const char * end(const char *str) noexcept
ClipMoveState(const ClipMoveState &)=delete
ClipMoveState(ClipMoveState &&)=default
std::unordered_map< Track *, std::unique_ptr< TrackShifter > > ShifterMap
std::shared_ptr< Track > mCapturedTrack
Optional, more complete information for hit testing.
TimeInterval(double start, double end)