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 bool DoSlideVertical (ViewInfo &viewInfo, wxCoord xx, ClipMoveState &state, TrackList &trackList, Track &dstTrack, double &desiredSlideAmount)
 
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 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 1001 of file TimeShiftHandle.cpp.

1002{
1004 {
1005 ProjectHistory::Get( *pProject ).RollbackState();
1007 }
1009}
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 ProjectSettings::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,
557 true, // don't snap to time
561 auto pInterval = mClipMoveState.CapturedInterval();
562 mSnapPreferRightEdge = pInterval &&
563 (fabs(clickTime - pInterval->End()) <
564 fabs(clickTime - pInterval->Start()));
565
566 return RefreshNone;
567}
EffectDistortion::Params params
Definition: Distortion.cpp:83
const int kPixelTolerance
Definition: Snap.h:28
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)
bool IsSyncLocked() const
int GetTool() const
std::shared_ptr< SnapManager > mSnapManager
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
@ 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(), ViewInfo::Get(), TrackList::Get(), ProjectAudioIO::Get(), ProjectSettings::Get(), ProjectSettings::GetTool(), ClipMoveState::Init(), ProjectAudioIO::IsAudioActive(), ProjectSettings::IsSyncLocked(), kPixelTolerance, 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()

bool TimeShiftHandle::DoSlideVertical ( ViewInfo viewInfo,
wxCoord  xx,
ClipMoveState state,
TrackList trackList,
Track dstTrack,
double &  desiredSlideAmount 
)
static

Definition at line 778 of file TimeShiftHandle.cpp.

782{
783 Correspondence correspondence;
784
785 // See if captured track corresponds to another
786 auto &capturedTrack = *state.mCapturedTrack;
788 correspondence, trackList, capturedTrack, dstTrack, state ))
789 return false;
790
791 // Try to extend the correpondence
792 auto tryExtend = [&](bool forward){
793 auto begin = trackList.begin(), end = trackList.end();
794 auto pCaptured = trackList.Find( &capturedTrack );
795 auto pDst = trackList.Find( &dstTrack );
796 // Scan for more correspondences
797 while ( true ) {
798 // Remember that TrackIter wraps circularly to the end iterator when
799 // decrementing it
800
801 // First move to a track with moving intervals and
802 // without a correspondent
803 do
804 forward ? ++pCaptured : --pCaptured;
805 while ( pCaptured != end &&
806 ( correspondence.count(*pCaptured) || state.shifters[*pCaptured]->MovingIntervals().empty() ) );
807 if ( pCaptured == end )
808 break;
809
810 // Change the choice of possible correspondent track too
811 do
812 forward ? ++pDst : --pDst;
813 while ( pDst != end && correspondence.count(*pDst) );
814 if ( pDst == end )
815 break;
816
817 // Make correspondence if we can
819 correspondence, trackList, **pCaptured, **pDst, state ))
820 break;
821 }
822 };
823 // Try extension, backward first, then forward
824 // (anticipating the case of dragging a label that is under a clip)
825 tryExtend(false);
826 tryExtend(true);
827
828 // Having passed that test, remove clips temporarily from their
829 // tracks, so moving clips don't interfere with each other
830 // when we call CanInsertClip()
831 TemporaryClipRemover remover{ state };
832
833 // Now check that the move is possible
834 double slide = desiredSlideAmount; // remember amount requested.
835 // The test for tolerance will need review with FishEye!
836 // The tolerance is supposed to be the time for one pixel,
837 // i.e. one pixel tolerance at current zoom.
838 double tolerance =
839 viewInfo.PositionToTime(xx + 1) - viewInfo.PositionToTime(xx);
840 bool ok = CheckFit( state, correspondence, remover.detached,
841 tolerance, desiredSlideAmount /*in,out*/ );
842
843 if (!ok) {
844 // Failure, even with using tolerance.
845 remover.Reinsert( nullptr );
846 return false;
847 }
848
849 // Make the offset permanent; start from a "clean slate"
850 state.mMouseClickX = xx;
851 remover.Reinsert( &correspondence );
852 return true;
853}
iterator end()
Definition: Track.h:1391
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:1399
iterator begin()
Definition: Track.h:1390
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:41
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, ClipMoveState::mMouseClickX, ZoomInfo::PositionToTime(), 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 855 of file TimeShiftHandle.cpp.

857{
858 using namespace RefreshCode;
859 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
860 if (unsafe) {
861 this->Cancel(pProject);
862 return RefreshAll | Cancelled;
863 }
864
865 const wxMouseEvent &event = evt.event;
866 auto &viewInfo = ViewInfo::Get( *pProject );
867
868 TrackView *trackView = dynamic_cast<TrackView*>(evt.pCell.get());
869 Track *track = trackView ? trackView->FindTrack().get() : nullptr;
870
871 // Uncommenting this permits drag to continue to work even over the controls area
872 /*
873 track = static_cast<CommonTrackPanelCell*>(evt.pCell)->FindTrack().get();
874 */
875
876 if (!track) {
877 // Allow sliding if the pointer is not over any track, but only if x is
878 // within the bounds of the tracks area.
879 if (event.m_x >= mRect.GetX() &&
880 event.m_x < mRect.GetX() + mRect.GetWidth())
881 track = mClipMoveState.mCapturedTrack.get();
882 }
883
884 // May need a shared_ptr to reassign mCapturedTrack below
885 auto pTrack = Track::SharedPointer( track );
886 if (!pTrack)
888
889
890 auto &trackList = TrackList::Get( *pProject );
891
892 // GM: slide now implementing snap-to
893 // samples functionality based on sample rate.
894
895 // Start by undoing the current slide amount; everything
896 // happens relative to the original horizontal position of
897 // each clip...
899
901 // Slide the selection, too
902 viewInfo.selectedRegion.move( -mClipMoveState.hSlideAmount );
903 }
905
906 double desiredSlideAmount =
907 FindDesiredSlideAmount( viewInfo, mRect.x, event, mSnapManager.get(),
909 *pTrack );
910
911 // Scroll during vertical drag.
912 // If the mouse is over a track that isn't the captured track,
913 // decide which tracks the captured clips should go to.
914 // EnsureVisible(pTrack); //vvv Gale says this has problems on Linux, per bug 393 thread. Revert for 2.0.2.
915 bool slidVertically = (
917 /* && !mCapturedClipIsSelection*/
918 && DoSlideVertical( viewInfo, event.m_x, mClipMoveState,
919 trackList, *pTrack, desiredSlideAmount ) );
920 if (slidVertically)
921 {
923 mDidSlideVertically = true;
924 }
925
926 if (desiredSlideAmount == 0.0)
927 return RefreshAll;
928
929 // Note that mouse dragging doesn't use TrackShifter::HintOffsetLarger()
930
931 mClipMoveState.DoSlideHorizontal( desiredSlideAmount );
932
934 // Slide the selection, too
935 viewInfo.selectedRegion.move( mClipMoveState.hSlideAmount );
936 }
937
938 if (slidVertically) {
939 // NEW origin
941 }
942
943 return RefreshAll;
944}
std::shared_ptr< Track > FindTrack()
static bool DoSlideVertical(ViewInfo &viewInfo, wxCoord xx, ClipMoveState &state, TrackList &trackList, Track &dstTrack, double &desiredSlideAmount)
Result Cancel(AudacityProject *pProject) override
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:297
double FindDesiredSlideAmount(const ViewInfo &viewInfo, wxCoord xx, const wxMouseEvent &event, SnapManager *pSnapManager, bool slideUpDownOnly, bool snapPreferRightEdge, ClipMoveState &state, Track &track)
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 Cancel(), RefreshCode::Cancelled, ClipMoveState::DoHorizontalOffset(), ClipMoveState::DoSlideHorizontal(), DoSlideVertical(), TrackPanelMouseEvent::event, anonymous_namespace{TimeShiftHandle.cpp}::FindDesiredSlideAmount(), CommonTrackPanelCell::FindTrack(), ViewInfo::Get(), TrackList::Get(), ProjectAudioIO::Get(), ClipMoveState::hSlideAmount, ProjectAudioIO::IsAudioActive(), ClipMoveState::mCapturedTrack, mClipMoveState, mDidSlideVertically, ClipMoveState::movingSelection, mRect, mSlideUpDownOnly, mSnapManager, mSnapPreferRightEdge, TrackPanelMouseEvent::pCell, RefreshCode::RefreshAll, RefreshCode::RefreshNone, and Track::SharedPointer().

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

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

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

1028{
1029 if ( iPass == TrackArtist::PassSnapping )
1030 return MaximizeHeight( rect, panelRect );
1031 else
1032 return rect;
1033}
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}
#define XO(s)
Definition: Internat.h:31
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:185

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

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

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

311{ 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(), Drag(), 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: