Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TimeShiftHandle Class Reference

#include <TimeShiftHandle.h>

Inheritance diagram for TimeShiftHandle:
[legend]
Collaboration diagram for TimeShiftHandle:
[legend]

Public Member Functions

 TimeShiftHandle (std::shared_ptr< Track > pTrack, bool gripHit)
 
TimeShiftHandleoperator= (TimeShiftHandle &&)=default
 
bool IsGripHit () const
 
virtual ~TimeShiftHandle ()
 
std::shared_ptr< const ChannelFindChannel () const override
 
void Enter (bool forward, AudacityProject *) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
bool Clicked () const
 
std::shared_ptr< TrackGetTrack () const
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
virtual std::shared_ptr< const ChannelFindChannel () const =0
 
virtual bool IsDragging () const
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Static Public Member Functions

static UIHandlePtr HitAnywhere (std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
 
static UIHandlePtr HitTest (std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Protected Member Functions

bool WasMoved () const
 

Private Member Functions

 TimeShiftHandle (const TimeShiftHandle &)=delete
 
void DoSlideVertical (ViewInfo &viewInfo, wxCoord xx, TrackList &trackList, Track *dstTrack, double &desiredSlideAmount)
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
wxRect DrawingArea (TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
 

Static Private Member Functions

static HitTestPreview HitPreview (const AudacityProject *pProject, bool unsafe)
 

Private Attributes

wxRect mRect {}
 
bool mDidSlideVertically {}
 
bool mSlideUpDownOnly {}
 
bool mSnapPreferRightEdge {}
 
std::shared_ptr< SnapManagermSnapManager {}
 
ClipMoveState mClipMoveState {}
 
bool mGripHit {}
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 294 of file TimeShiftHandle.h.

Constructor & Destructor Documentation

◆ TimeShiftHandle() [1/2]

TimeShiftHandle::TimeShiftHandle ( const TimeShiftHandle )
privatedelete

◆ TimeShiftHandle() [2/2]

TimeShiftHandle::TimeShiftHandle ( std::shared_ptr< Track pTrack,
bool  gripHit 
)

Substitute the leader track before assigning mCapturedTrack

Definition at line 32 of file TimeShiftHandle.cpp.

33 : mGripHit{ gripHit }
34{
36 if (pTrack)
37 if (const auto pOwner = pTrack->GetOwner())
38 pTrack = (*pOwner->Find(pTrack.get()))->SharedPointer();
40}
ClipMoveState mClipMoveState
std::shared_ptr< Track > mCapturedTrack

References ClipMoveState::mCapturedTrack, and mClipMoveState.

◆ ~TimeShiftHandle()

TimeShiftHandle::~TimeShiftHandle ( )
virtual

Definition at line 118 of file TimeShiftHandle.cpp.

119{
120}

Member Function Documentation

◆ Cancel()

UIHandle::Result TimeShiftHandle::Cancel ( AudacityProject pProject)
overridevirtual

Implements UIHandle.

Definition at line 979 of file TimeShiftHandle.cpp.

980{
982 {
983 ProjectHistory::Get( *pProject ).RollbackState();
985 }
987}
static ProjectHistory & Get(AudacityProject &project)

References ProjectHistory::Get(), ClipMoveState::initialized, mClipMoveState, RefreshCode::RefreshAll, RefreshCode::RefreshNone, and ProjectHistory::RollbackState().

Referenced by Drag(), and Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Click()

UIHandle::Result TimeShiftHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 466 of file TimeShiftHandle.cpp.

468{
469 using namespace RefreshCode;
470 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
471 if ( unsafe )
472 return Cancelled;
473
474 const wxMouseEvent &event = evt.event;
475 const wxRect &rect = evt.rect;
476 auto &viewInfo = ViewInfo::Get( *pProject );
477
478 const auto pView = std::static_pointer_cast<ChannelView>(evt.pCell);
479 const auto clickedTrack = pView ? pView->FindTrack().get() : nullptr;
480 if (!clickedTrack)
482
483 auto &trackList = TrackList::Get(*pProject);
484 // Substitute the leader track before giving it to MakeTrackShifter
485 // and ClipMoveState::Init
486 const auto pTrack = *trackList.Find(clickedTrack);
487
489 mDidSlideVertically = false;
490
491 const bool multiToolModeActive =
493
494 const double clickTime =
495 viewInfo.PositionToTime(event.m_x, rect.x);
496
497 auto pShifter = MakeTrackShifter::Call(*pTrack, *pProject);
498
499 auto hitTestResult = TrackShifter::HitTestResult::Track;
500 if (!event.ShiftDown()) {
502 rect, event.m_x, event.m_y
503 };
504 hitTestResult = pShifter->HitTest( clickTime, viewInfo, &params );
505 switch( hitTestResult ) {
507 return Cancelled;
508 default:
509 break;
510 }
511 }
512 else {
513 // just do shifting of one whole track
514 }
515
516 mClipMoveState.Init(*pProject, *pTrack,
517 hitTestResult, move(pShifter), clickTime,
518 viewInfo, trackList,
519 SyncLockState::Get( *pProject ).IsSyncLocked() );
520
521 mSlideUpDownOnly = event.CmdDown() && !multiToolModeActive;
522 mRect = rect;
523 mClipMoveState.mMouseClickX = event.m_x;
525 std::make_shared<SnapManager>(*trackList.GetOwner(),
527 viewInfo);
530 auto pInterval = mClipMoveState.CapturedInterval();
531 mSnapPreferRightEdge = pInterval &&
532 (fabs(clickTime - pInterval->End()) <
533 fabs(clickTime - pInterval->Start()));
534
535 return RefreshNone;
536}
EffectDistortionSettings params
Definition: Distortion.cpp:77
static Return Call(This &obj, Arguments ...arguments)
Invoke the method – but only after static initialization time.
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
int GetTool() const
bool IsSyncLocked() const
Definition: SyncLock.cpp:43
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:26
std::shared_ptr< SnapManager > mSnapManager
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
@ Track
Shift selected track and sister channels only, as a whole.
@ Miss
Don't shift anything.
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
SnapPointArray FindCandidates(const TrackList &tracks, const ClipMoveState::ShifterMap &shifters)
void Init(AudacityProject &project, Track &capturedTrack, TrackShifter::HitTestResult hitTestResult, std::unique_ptr< TrackShifter > pHit, double clickTime, const ViewInfo &viewInfo, TrackList &trackList, bool syncLocked)
Will associate a TrackShifter with each track in the list.
const ChannelGroupInterval * CapturedInterval() const
Return pointer to the first fixed interval of the captured track, if there is one.
ShifterMap shifters
Optional, more complete information for hit testing.

References AttachedVirtualFunction< Tag, Return, This, Arguments >::Call(), Cancelled, RefreshCode::Cancelled, ClipMoveState::CapturedInterval(), ClipMoveState::clear(), TrackPanelMouseEvent::event, anonymous_namespace{TimeShiftHandle.cpp}::FindCandidates(), ProjectAudioIO::Get(), ViewInfo::Get(), SyncLockState::Get(), TrackList::Get(), ProjectSettings::Get(), ProjectSettings::GetTool(), ClipMoveState::Init(), ProjectAudioIO::IsAudioActive(), SyncLockState::IsSyncLocked(), mClipMoveState, mDidSlideVertically, TrackShifter::Miss, ClipMoveState::mMouseClickX, mRect, mSlideUpDownOnly, mSnapManager, mSnapPreferRightEdge, ToolCodes::multiTool, params, TrackPanelMouseEvent::pCell, TrackPanelMouseEvent::rect, RefreshCode::RefreshNone, ClipMoveState::shifters, ClipMoveState::snapLeft, ClipMoveState::snapRight, and TrackShifter::Track.

Referenced by AffordanceHandle::Click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clicked()

bool TimeShiftHandle::Clicked ( ) const

Definition at line 52 of file TimeShiftHandle.cpp.

53{
55}

References ClipMoveState::initialized, and mClipMoveState.

Referenced by AffordanceHandle::Preview().

Here is the caller graph for this function:

◆ DoSlideVertical()

void TimeShiftHandle::DoSlideVertical ( ViewInfo viewInfo,
wxCoord  xx,
TrackList trackList,
Track dstTrack,
double &  desiredSlideAmount 
)
private

Definition at line 738 of file TimeShiftHandle.cpp.

741{
742 Correspondence correspondence;
743
744 // Substitute leader track before reassigning mCapturedTrack
745 dstTrack = *trackList.Find(dstTrack);
746
747 // See if captured track corresponds to another
748 auto &capturedTrack = *mClipMoveState.mCapturedTrack;
750 correspondence, trackList, capturedTrack, *dstTrack, mClipMoveState ))
751 return;
752
753 // Try to extend the correpondence
754 auto tryExtend = [&](bool forward) {
755 auto range = trackList.Any();
756 auto begin = range.begin(), end = range.end();
757 auto pCaptured = trackList.Find(&capturedTrack);
758 auto pDst = trackList.Find(dstTrack);
759 // Scan for more correspondences
760 while (true) {
761 // Remember that TrackIter wraps circularly to the end iterator when
762 // decrementing it
763
764 // First move to a track with moving intervals and
765 // without a correspondent
766 do
767 forward ? ++pCaptured : --pCaptured;
768 while (pCaptured != end &&
769 (correspondence.count(*pCaptured) ||
770 mClipMoveState.shifters[*pCaptured]->MovingIntervals().empty()));
771 if (pCaptured == end)
772 break;
773
774 // Change the choice of possible correspondent track too
775 do
776 forward ? ++pDst : --pDst;
777 while (pDst != end && correspondence.count(*pDst));
778 if (pDst == end)
779 break;
780
781 // Make correspondence if we can
783 correspondence, trackList, **pCaptured, **pDst, mClipMoveState))
784 break;
785 }
786 };
787 // Try extension, backward first, then forward
788 // (anticipating the case of dragging a label that is under a clip)
789 tryExtend(false);
790 tryExtend(true);
791
792 // Having passed that test, remove clips temporarily from their
793 // tracks, so moving clips don't interfere with each other
794 // when we call CanInsertClip()
795 TemporaryClipRemover remover{ mClipMoveState };
796
797 // Now check that the move is possible
798 auto slideAmount = desiredSlideAmount;
799 // The test for tolerance will need review with FishEye!
800 // The tolerance is supposed to be the time for twenty pixels,
801 // i.e. twenty pixel tolerance at current zoom.
802 double tolerance =
803 viewInfo.PositionToTime(xx + 10) - viewInfo.PositionToTime(xx - 10);
804 bool ok = CheckFit( mClipMoveState, correspondence, remover.detached,
805 tolerance, slideAmount /*in,out*/ );
806
807 if (!ok) {
808 // Failure, even with using tolerance.
809 remover.Reinsert( nullptr, .0 );
810 return;
811 }
812
813 remover.Reinsert( &correspondence, slideAmount );
814
816 viewInfo.selectedRegion.move( slideAmount );
817
818 // Make the offset permanent; start from a "clean slate"
819 assert(dstTrack->IsLeader());
822 mDidSlideVertically = true;
823 desiredSlideAmount = .0;
824}
void move(double delta)
Definition: ViewInfo.cpp:97
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:160
bool IsLeader() const override
Definition: Track.cpp:291
TrackIter< Track > Find(Track *pTrack)
Definition: Track.cpp:519
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1079
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:34
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
bool CheckFit(ClipMoveState &state, const Correspondence &correspondence, const DetachedIntervals &intervals, double tolerance, double &desiredSlideAmount)
std::unordered_map< Track *, Track * > Correspondence
bool FindCorrespondence(Correspondence &correspondence, TrackList &trackList, Track &capturedTrack, Track &track, ClipMoveState &state)

References TrackList::Any(), PackedArray::begin(), anonymous_namespace{TimeShiftHandle.cpp}::CheckFit(), PackedArray::end(), TrackList::Find(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), forward, Track::IsLeader(), ClipMoveState::mCapturedTrack, mClipMoveState, mDidSlideVertically, ClipMoveState::mMouseClickX, NotifyingSelectedRegion::move(), ClipMoveState::movingSelection, ZoomInfo::PositionToTime(), ViewInfo::selectedRegion, Track::SharedPointer(), and ClipMoveState::shifters.

Referenced by Drag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Drag()

UIHandle::Result TimeShiftHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 826 of file TimeShiftHandle.cpp.

828{
829 using namespace RefreshCode;
830 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
831 if (unsafe) {
832 this->Cancel(pProject);
833 return RefreshAll | Cancelled;
834 }
835
836 const wxMouseEvent &event = evt.event;
837 auto &viewInfo = ViewInfo::Get( *pProject );
838
839 auto &trackList = TrackList::Get(*pProject);
840 ChannelView *trackView = dynamic_cast<ChannelView*>(evt.pCell.get());
841 Track *track =
842 *trackList.Find(trackView ? trackView->FindTrack().get() : nullptr);
843
844 // Uncommenting this permits drag to continue to work even over the controls area
845 /*
846 track = static_cast<CommonTrackPanelCell*>(evt.pCell)->FindTrack().get();
847 */
848
849 if (!track) {
850 // Allow sliding if the pointer is not over any track, but only if x is
851 // within the bounds of the tracks area.
852 if (event.m_x >= mRect.GetX() &&
853 event.m_x < mRect.GetX() + mRect.GetWidth())
854 track = mClipMoveState.mCapturedTrack.get();
855 }
856
857 // May need a shared_ptr to reassign mCapturedTrack below
858 auto pTrack = Track::SharedPointer( track );
859 if (!pTrack)
861
862 // GM: slide now implementing snap-to
863 // samples functionality based on sample rate.
864
865 // Start by undoing the current slide amount; everything
866 // happens relative to the original horizontal position of
867 // each clip...
869
871 // Slide the selection, too
872 viewInfo.selectedRegion.move( -mClipMoveState.hSlideAmount );
873 }
875
876 double desiredSlideAmount = 0.0;
878 {
879 desiredSlideAmount =
880 viewInfo.PositionToTime(event.m_x) -
881 viewInfo.PositionToTime(mClipMoveState.mMouseClickX);
882
883 if (!mClipMoveState.shifters.empty())
884 desiredSlideAmount =
885 mClipMoveState.shifters[track]->QuantizeOffset(desiredSlideAmount);
886 }
887
888 if(mClipMoveState.mCapturedTrack != pTrack)
889 {
890 // Scroll during vertical drag.
891 // If the mouse is over a track that isn't the captured track,
892 // decide which tracks the captured clips should go to.
893 // Viewport::Get(*pProject).ShowTrack(pTrack); //vvv Gale says this has problems on Linux, per bug 393 thread. Revert for 2.0.2.
894
895 //move intervals with new start/end times
897 viewInfo, event.m_x, trackList, pTrack.get(), desiredSlideAmount);
898 }
899
901 {
902 AdjustToSnap(viewInfo, mRect.x,
903 mSnapManager.get(),
906 desiredSlideAmount);
907 }
908
909 if (desiredSlideAmount == 0.0)
910 return RefreshAll;
911
912 // Note that mouse dragging doesn't use TrackShifter::HintOffsetLarger()
913
914 mClipMoveState.DoSlideHorizontal( desiredSlideAmount );
915
917 // Slide the selection, too
918 viewInfo.selectedRegion.move( mClipMoveState.hSlideAmount );
919 }
920
921 return RefreshAll;
922}
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:341
std::shared_ptr< Track > FindTrack()
Result Cancel(AudacityProject *pProject) override
void DoSlideVertical(ViewInfo &viewInfo, wxCoord xx, TrackList &trackList, Track *dstTrack, double &desiredSlideAmount)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:122
void AdjustToSnap(const ViewInfo &viewInfo, wxCoord xx, SnapManager *pSnapManager, bool snapPreferRightEdge, ClipMoveState &state, double &desiredSlideAmount)
void DoHorizontalOffset(double offset)
Offset tracks or intervals horizontally, without adjusting the offset.
double DoSlideHorizontal(double desiredSlideAmount)
Do sliding of tracks and intervals, maybe adjusting the offset.

References anonymous_namespace{TimeShiftHandle.cpp}::AdjustToSnap(), Cancel(), Cancelled, ClipMoveState::DoHorizontalOffset(), ClipMoveState::DoSlideHorizontal(), DoSlideVertical(), TrackPanelMouseEvent::event, ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Find(), CommonTrackPanelCell::FindTrack(), ProjectAudioIO::Get(), ViewInfo::Get(), TrackList::Get(), ClipMoveState::hSlideAmount, ProjectAudioIO::IsAudioActive(), ClipMoveState::mCapturedTrack, mClipMoveState, ClipMoveState::mMouseClickX, ClipMoveState::movingSelection, mRect, mSlideUpDownOnly, mSnapManager, mSnapPreferRightEdge, TrackPanelMouseEvent::pCell, RefreshCode::RefreshAll, RefreshCode::RefreshNone, Track::SharedPointer(), and ClipMoveState::shifters.

Referenced by AffordanceHandle::Drag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw()

void TimeShiftHandle::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 989 of file TimeShiftHandle.cpp.

992{
993 if ( iPass == TrackArtist::PassSnapping ) {
994 auto &dc = context.dc;
995 // Draw snap guidelines if we have any
996 if ( mSnapManager ) {
999 }
1000 }
1001}
AUDACITY_DLL_API void DrawSnapLines(wxDC *dc, wxInt64 snap0, wxInt64 snap1)
Definition: TrackArt.cpp:821

References TrackPanelDrawingContext::dc, TrackArt::DrawSnapLines(), mClipMoveState, mSnapManager, TrackArtist::PassSnapping, ClipMoveState::snapLeft, and ClipMoveState::snapRight.

Here is the call graph for this function:

◆ DrawingArea()

wxRect TimeShiftHandle::DrawingArea ( TrackPanelDrawingContext ,
const wxRect &  rect,
const wxRect &  panelRect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 1003 of file TimeShiftHandle.cpp.

1006{
1007 if ( iPass == TrackArtist::PassSnapping )
1008 return MaximizeHeight( rect, panelRect );
1009 else
1010 return rect;
1011}
static wxRect MaximizeHeight(const wxRect &rect, const wxRect &panelRect)

References TrackPanelDrawable::MaximizeHeight(), and TrackArtist::PassSnapping.

Here is the call graph for this function:

◆ Enter()

void TimeShiftHandle::Enter ( bool  forward,
AudacityProject  
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 57 of file TimeShiftHandle.cpp.

58{
59#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
61#endif
62}
Result mChangeHighlight
Definition: UIHandle.h:147

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

Referenced by AffordanceHandle::Enter().

Here is the caller graph for this function:

◆ FindChannel()

std::shared_ptr< const Channel > TimeShiftHandle::FindChannel ( ) const
overridevirtual
Returns
pointer to associated channel, if any

Implements UIHandle.

Definition at line 122 of file TimeShiftHandle.cpp.

123{
124 return std::dynamic_pointer_cast<const Channel>(GetTrack());
125}
std::shared_ptr< Track > GetTrack() const

References GetTrack().

Here is the call graph for this function:

◆ GetTrack()

std::shared_ptr< Track > TimeShiftHandle::GetTrack ( ) const
Returns
will point only to a leader

Definition at line 42 of file TimeShiftHandle.cpp.

43{
45}

References ClipMoveState::mCapturedTrack, and mClipMoveState.

Referenced by FindChannel(), NoteTrackAffordanceHandle::SelectAt(), and AffordanceHandle::UpdateTrackSelection().

Here is the caller graph for this function:

◆ HitAnywhere()

UIHandlePtr TimeShiftHandle::HitAnywhere ( std::weak_ptr< TimeShiftHandle > &  holder,
const std::shared_ptr< Track > &  pTrack,
bool  gripHit 
)
static

Definition at line 84 of file TimeShiftHandle.cpp.

87{
88 auto result = std::make_shared<TimeShiftHandle>( pTrack, gripHit );
89 result = AssignUIHandlePtr(holder, result);
90 return result;
91}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159

References AssignUIHandlePtr().

Referenced by WaveChannelView::DoDetailedHitTest(), CommonChannelView::HitTest(), and HitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HitPreview()

HitTestPreview TimeShiftHandle::HitPreview ( const AudacityProject pProject,
bool  unsafe 
)
staticprivate

Definition at line 64 of file TimeShiftHandle.cpp.

66{
67 static auto disabledCursor =
68 ::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);
69 static auto slideCursor =
70 MakeCursor(wxCURSOR_SIZEWE, TimeCursorXpm, 16, 16);
71 // TODO: Should it say "track or clip" ? Non-wave tracks can move, or clips in a wave track.
72 // TODO: mention effects of shift (move all clips of selected wave track) and ctrl (move vertically only) ?
73 // -- but not all of that is available in multi tool.
74 auto message = XO("Click and drag to move a track in time");
75
76 return {
77 message,
78 (unsafe
79 ? &*disabledCursor
80 : &*slideCursor)
81 };
82}
XO("Cut/Copy/Paste")
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:188

References MakeCursor(), and XO().

Referenced by Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HitTest()

UIHandlePtr TimeShiftHandle::HitTest ( std::weak_ptr< TimeShiftHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const std::shared_ptr< Track > &  pTrack 
)
static

method that tells us if the mouse event landed on a time-slider that allows us to time shift the sequence. (Those are the two "grips" drawn at left and right edges for multi tool mode.)

Definition at line 93 of file TimeShiftHandle.cpp.

97{
101
102 // Perhaps we should delegate this to TrackArtist as only TrackArtist
103 // knows what the real sizes are??
104
105 // The drag Handle width includes border, width and a little extra margin.
106 const int adjustedDragHandleWidth = 14;
107 // The hotspot for the cursor isn't at its centre. Adjust for this.
108 const int hotspotOffset = 5;
109
110 // We are doing an approximate test here - is the mouse in the right or left border?
111 if (!(state.m_x + hotspotOffset < rect.x + adjustedDragHandleWidth ||
112 state.m_x + hotspotOffset >= rect.x + rect.width - adjustedDragHandleWidth))
113 return {};
114
115 return HitAnywhere( holder, pTrack, true );
116}
static UIHandlePtr HitAnywhere(std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)

References HitAnywhere().

Referenced by WaveformView::DetailedHitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsGripHit()

bool TimeShiftHandle::IsGripHit ( ) const
inline

Definition at line 305 of file TimeShiftHandle.h.

305{ return mGripHit; }

Referenced by WaveformView::DoDraw().

Here is the caller graph for this function:

◆ operator=()

TimeShiftHandle & TimeShiftHandle::operator= ( TimeShiftHandle &&  )
default

◆ Preview()

HitTestPreview TimeShiftHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 924 of file TimeShiftHandle.cpp.

926{
927 // After all that, it still may be unsafe to drag.
928 // Even if so, make an informative cursor change from default to "banned."
929 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
930 return HitPreview(pProject, unsafe);
931}
static HitTestPreview HitPreview(const AudacityProject *pProject, bool unsafe)

References ProjectAudioIO::Get(), HitPreview(), and ProjectAudioIO::IsAudioActive().

Here is the call graph for this function:

◆ Release()

UIHandle::Result TimeShiftHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 933 of file TimeShiftHandle.cpp.

936{
937 using namespace RefreshCode;
938 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
939 if (unsafe)
940 return this->Cancel(pProject);
941
942 Result result = RefreshNone;
943
944 // Do not draw yellow lines
945 if ( mClipMoveState.snapLeft != -1 || mClipMoveState.snapRight != -1) {
947 result |= RefreshAll;
948 }
949
951 return result;
952
953 for ( auto &pair : mClipMoveState.shifters )
954 if (!pair.second->FinishMigration())
956
958 bool consolidate;
960 msg = XO("Moved clips to another track");
961 consolidate = false;
962 for (auto& pair : mClipMoveState.shifters)
963 pair.first->LinkConsistencyFix();
964 }
965 else {
966 msg = ( mClipMoveState.hSlideAmount > 0
967 ? XO("Time shifted tracks/clips right %.02f seconds")
968 : XO("Time shifted tracks/clips left %.02f seconds")
969 )
970 .Format( fabs( mClipMoveState.hSlideAmount ) );
971 consolidate = true;
972 }
973 ProjectHistory::Get( *pProject ).PushState(msg, XO("Move Clip"),
974 consolidate ? (UndoPush::CONSOLIDATE) : (UndoPush::NONE));
975
976 return result | FixScrollbars;
977}
Abstract base class used in importing a file.
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Holds a msgid for the translation catalog; may also bind format arguments.
unsigned Result
Definition: UIHandle.h:39

References Cancel(), CONSOLIDATE, RefreshCode::FixScrollbars, ProjectAudioIO::Get(), ProjectHistory::Get(), ClipMoveState::hSlideAmount, ProjectAudioIO::IsAudioActive(), mClipMoveState, mDidSlideVertically, anonymous_namespace{TimeShiftHandle.cpp}::MigrationFailure(), NONE, ProjectHistory::PushState(), RefreshCode::RefreshAll, RefreshCode::RefreshNone, ClipMoveState::shifters, ClipMoveState::snapLeft, ClipMoveState::snapRight, and XO().

Referenced by AffordanceHandle::Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopsOnKeystroke()

bool TimeShiftHandle::StopsOnKeystroke ( )
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 337 of file TimeShiftHandle.h.

337{ return true; }

◆ WasMoved()

bool TimeShiftHandle::WasMoved ( ) const
protected

Definition at line 47 of file TimeShiftHandle.cpp.

References ClipMoveState::initialized, mClipMoveState, mDidSlideVertically, and ClipMoveState::wasMoved.

Referenced by AffordanceHandle::Release().

Here is the caller graph for this function:

Member Data Documentation

◆ mClipMoveState

ClipMoveState TimeShiftHandle::mClipMoveState {}
private

◆ mDidSlideVertically

bool TimeShiftHandle::mDidSlideVertically {}
private

Definition at line 369 of file TimeShiftHandle.h.

Referenced by Click(), DoSlideVertical(), Release(), and WasMoved().

◆ mGripHit

bool TimeShiftHandle::mGripHit {}
private

Definition at line 381 of file TimeShiftHandle.h.

◆ mRect

wxRect TimeShiftHandle::mRect {}
private

Definition at line 367 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().

◆ mSlideUpDownOnly

bool TimeShiftHandle::mSlideUpDownOnly {}
private

Definition at line 370 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().

◆ mSnapManager

std::shared_ptr<SnapManager> TimeShiftHandle::mSnapManager {}
private

Definition at line 378 of file TimeShiftHandle.h.

Referenced by Click(), Drag(), and Draw().

◆ mSnapPreferRightEdge

bool TimeShiftHandle::mSnapPreferRightEdge {}
private

Definition at line 372 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().


The documentation for this class was generated from the following files: