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 (const std::shared_ptr< Track > &pTrack, bool gripHit)
 
TimeShiftHandleoperator= (TimeShiftHandle &&)=default
 
bool IsGripHit () const
 
virtual ~TimeShiftHandle ()
 
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
 
- 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)
 
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

std::shared_ptr< TrackGetTrack () const
 
bool WasMoved () const
 

Private Member Functions

 TimeShiftHandle (const TimeShiftHandle &)=delete
 
void DoSlideVertical (ViewInfo &viewInfo, wxCoord xx, TrackList &trackList, const std::shared_ptr< 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 261 of file TimeShiftHandle.h.

Constructor & Destructor Documentation

◆ TimeShiftHandle() [1/2]

TimeShiftHandle::TimeShiftHandle ( const TimeShiftHandle )
privatedelete

◆ TimeShiftHandle() [2/2]

TimeShiftHandle::TimeShiftHandle ( const std::shared_ptr< Track > &  pTrack,
bool  gripHit 
)
explicit

Definition at line 31 of file TimeShiftHandle.cpp.

33 : mGripHit{ gripHit }
34{
36}
ClipMoveState mClipMoveState
std::shared_ptr< Track > mCapturedTrack

References ClipMoveState::mCapturedTrack, and mClipMoveState.

◆ ~TimeShiftHandle()

TimeShiftHandle::~TimeShiftHandle ( )
virtual

Definition at line 114 of file TimeShiftHandle.cpp.

115{
116}

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 1000 of file TimeShiftHandle.cpp.

1001{
1003 {
1004 ProjectHistory::Get( *pProject ).RollbackState();
1006 }
1008}
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 495 of file TimeShiftHandle.cpp.

497{
498 using namespace RefreshCode;
499 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
500 if ( unsafe )
501 return Cancelled;
502
503 const wxMouseEvent &event = evt.event;
504 const wxRect &rect = evt.rect;
505 auto &viewInfo = ViewInfo::Get( *pProject );
506
507 const auto pView = std::static_pointer_cast<TrackView>(evt.pCell);
508 const auto pTrack = pView ? pView->FindTrack().get() : nullptr;
509 if (!pTrack)
511
512 auto &trackList = TrackList::Get( *pProject );
513
515 mDidSlideVertically = false;
516
517 const bool multiToolModeActive =
519
520 const double clickTime =
521 viewInfo.PositionToTime(event.m_x, rect.x);
522
523 auto pShifter = MakeTrackShifter::Call( *pTrack, *pProject );
524
525 auto hitTestResult = TrackShifter::HitTestResult::Track;
526 if (!event.ShiftDown()) {
528 rect, event.m_x, event.m_y
529 };
530 hitTestResult = pShifter->HitTest( clickTime, viewInfo, &params );
531 switch( hitTestResult ) {
533 return Cancelled;
534 default:
535 break;
536 }
537 }
538 else {
539 // just do shifting of one whole track
540 }
541
542 mClipMoveState.Init( *pProject, *pTrack,
543 hitTestResult,
544 std::move( pShifter ),
545 clickTime,
546
547 viewInfo, trackList,
548 SyncLockState::Get( *pProject ).IsSyncLocked() );
549
550 mSlideUpDownOnly = event.CmdDown() && !multiToolModeActive;
551 mRect = rect;
552 mClipMoveState.mMouseClickX = event.m_x;
554 std::make_shared<SnapManager>(*trackList.GetOwner(),
556 viewInfo);
559 auto pInterval = mClipMoveState.CapturedInterval();
560 mSnapPreferRightEdge = pInterval &&
561 (fabs(clickTime - pInterval->End()) <
562 fabs(clickTime - pInterval->Start()));
563
564 return RefreshNone;
565}
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:385
@ 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)
const TrackInterval * CapturedInterval() const
Return pointer to the first fixed interval of the captured track, if there is one.
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.
ShifterMap shifters
Optional, more complete information for hit testing.

References AttachedVirtualFunction< Tag, Return, This, Arguments >::Call(), 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 48 of file TimeShiftHandle.cpp.

49{
51}

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,
const std::shared_ptr< Track > &  dstTrack,
double &  desiredSlideAmount 
)
private

Definition at line 764 of file TimeShiftHandle.cpp.

768{
769 Correspondence correspondence;
770
771 // See if captured track corresponds to another
772 auto &capturedTrack = *mClipMoveState.mCapturedTrack;
774 correspondence, trackList, capturedTrack, *dstTrack, mClipMoveState ))
775 return;
776
777 // Try to extend the correpondence
778 auto tryExtend = [&](bool forward){
779 auto begin = trackList.begin(), end = trackList.end();
780 auto pCaptured = trackList.Find( &capturedTrack );
781 auto pDst = trackList.Find( dstTrack.get() );
782 // Scan for more correspondences
783 while ( true ) {
784 // Remember that TrackIter wraps circularly to the end iterator when
785 // decrementing it
786
787 // First move to a track with moving intervals and
788 // without a correspondent
789 do
790 forward ? ++pCaptured : --pCaptured;
791 while ( pCaptured != end &&
792 ( correspondence.count(*pCaptured) || mClipMoveState.shifters[*pCaptured]->MovingIntervals().empty() ) );
793 if ( pCaptured == end )
794 break;
795
796 // Change the choice of possible correspondent track too
797 do
798 forward ? ++pDst : --pDst;
799 while ( pDst != end && correspondence.count(*pDst) );
800 if ( pDst == end )
801 break;
802
803 // Make correspondence if we can
805 correspondence, trackList, **pCaptured, **pDst, mClipMoveState ))
806 break;
807 }
808 };
809 // Try extension, backward first, then forward
810 // (anticipating the case of dragging a label that is under a clip)
811 tryExtend(false);
812 tryExtend(true);
813
814 // Having passed that test, remove clips temporarily from their
815 // tracks, so moving clips don't interfere with each other
816 // when we call CanInsertClip()
817 TemporaryClipRemover remover{ mClipMoveState };
818
819 // Now check that the move is possible
820 auto slideAmount = desiredSlideAmount;
821 // The test for tolerance will need review with FishEye!
822 // The tolerance is supposed to be the time for one pixel,
823 // i.e. one pixel tolerance at current zoom.
824 double tolerance =
825 viewInfo.PositionToTime(xx + 1) - viewInfo.PositionToTime(xx);
826 bool ok = CheckFit( mClipMoveState, correspondence, remover.detached,
827 tolerance, slideAmount /*in,out*/ );
828
829 if (!ok) {
830 // Failure, even with using tolerance.
831 remover.Reinsert( nullptr, .0 );
832 return;
833 }
834
835 remover.Reinsert( &correspondence, slideAmount );
836
838 viewInfo.selectedRegion.move( slideAmount );
839
840 // Make the offset permanent; start from a "clean slate"
843 mDidSlideVertically = true;
844 desiredSlideAmount = .0;
845}
void move(double delta)
Definition: ViewInfo.cpp:97
iterator end()
Definition: Track.h:1267
auto Find(Track *pTrack) -> TrackIter< TrackType >
Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.
Definition: Track.h:1275
iterator begin()
Definition: Track.h:1266
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:35
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::begin(), PackedArray::begin(), anonymous_namespace{TimeShiftHandle.cpp}::CheckFit(), TrackList::end(), PackedArray::end(), TrackList::Find(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), ClipMoveState::mCapturedTrack, mClipMoveState, mDidSlideVertically, ClipMoveState::mMouseClickX, NotifyingSelectedRegion::move(), ClipMoveState::movingSelection, ZoomInfo::PositionToTime(), ViewInfo::selectedRegion, 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 847 of file TimeShiftHandle.cpp.

849{
850 using namespace RefreshCode;
851 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
852 if (unsafe) {
853 this->Cancel(pProject);
854 return RefreshAll | Cancelled;
855 }
856
857 const wxMouseEvent &event = evt.event;
858 auto &viewInfo = ViewInfo::Get( *pProject );
859
860 TrackView *trackView = dynamic_cast<TrackView*>(evt.pCell.get());
861 Track *track = trackView ? trackView->FindTrack().get() : nullptr;
862
863 // Uncommenting this permits drag to continue to work even over the controls area
864 /*
865 track = static_cast<CommonTrackPanelCell*>(evt.pCell)->FindTrack().get();
866 */
867
868 if (!track) {
869 // Allow sliding if the pointer is not over any track, but only if x is
870 // within the bounds of the tracks area.
871 if (event.m_x >= mRect.GetX() &&
872 event.m_x < mRect.GetX() + mRect.GetWidth())
873 track = mClipMoveState.mCapturedTrack.get();
874 }
875
876 // May need a shared_ptr to reassign mCapturedTrack below
877 auto pTrack = Track::SharedPointer( track );
878 if (!pTrack)
880
881
882 auto &trackList = TrackList::Get( *pProject );
883
884 // GM: slide now implementing snap-to
885 // samples functionality based on sample rate.
886
887 // Start by undoing the current slide amount; everything
888 // happens relative to the original horizontal position of
889 // each clip...
891
893 // Slide the selection, too
894 viewInfo.selectedRegion.move( -mClipMoveState.hSlideAmount );
895 }
897
898 double desiredSlideAmount = 0.0;
900 {
901 desiredSlideAmount =
902 viewInfo.PositionToTime(event.m_x) -
903 viewInfo.PositionToTime(mClipMoveState.mMouseClickX);
904
905 if (!mClipMoveState.shifters.empty())
906 desiredSlideAmount =
907 mClipMoveState.shifters[ track ]->QuantizeOffset( desiredSlideAmount );
908 }
909
910 if(mClipMoveState.mCapturedTrack != pTrack)
911 {
912 // Scroll during vertical drag.
913 // If the mouse is over a track that isn't the captured track,
914 // decide which tracks the captured clips should go to.
915 // EnsureVisible(pTrack); //vvv Gale says this has problems on Linux, per bug 393 thread. Revert for 2.0.2.
916
917 //move intervals with new start/end times
918 DoSlideVertical(viewInfo, event.m_x, trackList, pTrack, desiredSlideAmount);
919 }
920
922 {
923 AdjustToSnap(viewInfo, mRect.x,
924 mSnapManager.get(),
927 desiredSlideAmount);
928 }
929
930 if (desiredSlideAmount == 0.0)
931 return RefreshAll;
932
933 // Note that mouse dragging doesn't use TrackShifter::HintOffsetLarger()
934
935 mClipMoveState.DoSlideHorizontal( desiredSlideAmount );
936
938 // Slide the selection, too
939 viewInfo.selectedRegion.move( mClipMoveState.hSlideAmount );
940 }
941
942 return RefreshAll;
943}
std::shared_ptr< Track > FindTrack()
Result Cancel(AudacityProject *pProject) override
void DoSlideVertical(ViewInfo &viewInfo, wxCoord xx, TrackList &trackList, const std::shared_ptr< Track > &dstTrack, double &desiredSlideAmount)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:162
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:232
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(), RefreshCode::Cancelled, ClipMoveState::DoHorizontalOffset(), ClipMoveState::DoSlideHorizontal(), DoSlideVertical(), TrackPanelMouseEvent::event, 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.

Here is the call graph for this function:

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 1010 of file TimeShiftHandle.cpp.

1013{
1014 if ( iPass == TrackArtist::PassSnapping ) {
1015 auto &dc = context.dc;
1016 // Draw snap guidelines if we have any
1017 if ( mSnapManager ) {
1018 mSnapManager->Draw(
1020 }
1021 }
1022}

References TrackPanelDrawingContext::dc, mClipMoveState, mSnapManager, TrackArtist::PassSnapping, ClipMoveState::snapLeft, and ClipMoveState::snapRight.

◆ DrawingArea()

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

Reimplemented from TrackPanelDrawable.

Definition at line 1024 of file TimeShiftHandle.cpp.

1027{
1028 if ( iPass == TrackArtist::PassSnapping )
1029 return MaximizeHeight( rect, panelRect );
1030 else
1031 return rect;
1032}
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 53 of file TimeShiftHandle.cpp.

54{
55#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
57#endif
58}
Result mChangeHighlight
Definition: UIHandle.h:139

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

Referenced by AffordanceHandle::Enter().

Here is the caller graph for this function:

◆ GetTrack()

std::shared_ptr< Track > TimeShiftHandle::GetTrack ( ) const
protected

Definition at line 38 of file TimeShiftHandle.cpp.

39{
41}

References ClipMoveState::mCapturedTrack, and mClipMoveState.

Referenced by AffordanceHandle::Release(), and NoteTrackAffordanceHandle::SelectAt().

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 80 of file TimeShiftHandle.cpp.

83{
84 auto result = std::make_shared<TimeShiftHandle>( pTrack, gripHit );
85 result = AssignUIHandlePtr(holder, result);
86 return result;
87}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151

References AssignUIHandlePtr().

Referenced by WaveTrackView::DoDetailedHitTest(), CommonTrackView::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 60 of file TimeShiftHandle.cpp.

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

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 89 of file TimeShiftHandle.cpp.

93{
97
98 // Perhaps we should delegate this to TrackArtist as only TrackArtist
99 // knows what the real sizes are??
100
101 // The drag Handle width includes border, width and a little extra margin.
102 const int adjustedDragHandleWidth = 14;
103 // The hotspot for the cursor isn't at its centre. Adjust for this.
104 const int hotspotOffset = 5;
105
106 // We are doing an approximate test here - is the mouse in the right or left border?
107 if (!(state.m_x + hotspotOffset < rect.x + adjustedDragHandleWidth ||
108 state.m_x + hotspotOffset >= rect.x + rect.width - adjustedDragHandleWidth))
109 return {};
110
111 return HitAnywhere( holder, pTrack, true );
112}
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 273 of file TimeShiftHandle.h.

273{ 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 945 of file TimeShiftHandle.cpp.

947{
948 // After all that, it still may be unsafe to drag.
949 // Even if so, make an informative cursor change from default to "banned."
950 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
951 return HitPreview(pProject, unsafe);
952}
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 954 of file TimeShiftHandle.cpp.

957{
958 using namespace RefreshCode;
959 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
960 if (unsafe)
961 return this->Cancel(pProject);
962
963 Result result = RefreshNone;
964
965 // Do not draw yellow lines
966 if ( mClipMoveState.snapLeft != -1 || mClipMoveState.snapRight != -1) {
968 result |= RefreshAll;
969 }
970
972 return result;
973
974 for ( auto &pair : mClipMoveState.shifters )
975 if ( !pair.second->FinishMigration() )
977
979 bool consolidate;
981 msg = XO("Moved clips to another track");
982 consolidate = false;
983 for (auto& pair : mClipMoveState.shifters)
984 pair.first->LinkConsistencyFix();
985 }
986 else {
987 msg = ( mClipMoveState.hSlideAmount > 0
988 ? XO("Time shifted tracks/clips right %.02f seconds")
989 : XO("Time shifted tracks/clips left %.02f seconds")
990 )
991 .Format( fabs( mClipMoveState.hSlideAmount ) );
992 consolidate = true;
993 }
994 ProjectHistory::Get( *pProject ).PushState(msg, XO("Time-Shift"),
995 consolidate ? (UndoPush::CONSOLIDATE) : (UndoPush::NONE));
996
997 return result | FixScrollbars;
998}
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:38

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 303 of file TimeShiftHandle.h.

303{ return true; }

◆ WasMoved()

bool TimeShiftHandle::WasMoved ( ) const
protected

Definition at line 43 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 331 of file TimeShiftHandle.h.

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

◆ mGripHit

bool TimeShiftHandle::mGripHit {}
private

Definition at line 343 of file TimeShiftHandle.h.

◆ mRect

wxRect TimeShiftHandle::mRect {}
private

Definition at line 329 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().

◆ mSlideUpDownOnly

bool TimeShiftHandle::mSlideUpDownOnly {}
private

Definition at line 332 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().

◆ mSnapManager

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

Definition at line 340 of file TimeShiftHandle.h.

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

◆ mSnapPreferRightEdge

bool TimeShiftHandle::mSnapPreferRightEdge {}
private

Definition at line 334 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().


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