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 TrackFindTrack () 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 TrackFindTrack () 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 std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- 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 292 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 
)

Definition at line 32 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 962 of file TimeShiftHandle.cpp.

963{
965 {
966 ProjectHistory::Get( *pProject ).RollbackState();
968 }
970}
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 457 of file TimeShiftHandle.cpp.

459{
460 using namespace RefreshCode;
461 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
462 if ( unsafe )
463 return Cancelled;
464
465 const wxMouseEvent &event = evt.event;
466 const wxRect &rect = evt.rect;
467 auto &viewInfo = ViewInfo::Get( *pProject );
468
469 const auto pView =
470 std::dynamic_pointer_cast<CommonTrackPanelCell>(evt.pCell);
471 const auto pTrack = pView ? pView->FindTrack() : nullptr;
472 if (!pTrack)
474
476 mDidSlideVertically = false;
477
478 const bool multiToolModeActive =
480
481 const double clickTime =
482 viewInfo.PositionToTime(event.m_x, rect.x);
483
484 auto pShifter = MakeTrackShifter::Call(*pTrack, *pProject);
485
486 auto hitTestResult = TrackShifter::HitTestResult::Track;
487 if (!event.ShiftDown()) {
489 rect, event.m_x, event.m_y
490 };
491 hitTestResult = pShifter->HitTest( clickTime, viewInfo, &params );
492 switch( hitTestResult ) {
494 return Cancelled;
495 default:
496 break;
497 }
498 }
499 else {
500 // just do shifting of one whole track
501 }
502
503 auto &trackList = TrackList::Get(*pProject);
504 mClipMoveState.Init(*pProject, *pTrack,
505 hitTestResult, move(pShifter), clickTime,
506 viewInfo, trackList,
507 SyncLockState::Get( *pProject ).IsSyncLocked() );
508
509 mSlideUpDownOnly = event.CmdDown() && !multiToolModeActive;
510 mRect = rect;
511 mClipMoveState.mMouseClickX = event.m_x;
513 std::make_shared<SnapManager>(*trackList.GetOwner(),
515 viewInfo);
518 auto pInterval = mClipMoveState.CapturedInterval();
519 mSnapPreferRightEdge = pInterval &&
520 (fabs(clickTime - pInterval->End()) <
521 fabs(clickTime - pInterval->Start()));
522
523 return RefreshNone;
524}
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:44
static SyncLockState & Get(AudacityProject &project)
Definition: SyncLock.cpp:27
std::shared_ptr< SnapManager > mSnapManager
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
@ 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 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,
Track dstTrack,
double &  desiredSlideAmount 
)
private

Definition at line 725 of file TimeShiftHandle.cpp.

728{
729 Correspondence correspondence;
730
731 // See if captured track corresponds to another
732 auto &capturedTrack = *mClipMoveState.mCapturedTrack;
734 correspondence, trackList, capturedTrack, *dstTrack, mClipMoveState ))
735 return;
736
737 // Try to extend the correpondence
738 auto tryExtend = [&](bool forward) {
739 auto range = trackList.Any();
740 auto begin = range.begin(), end = range.end();
741 auto pCaptured = trackList.Find(&capturedTrack);
742 auto pDst = trackList.Find(dstTrack);
743 // Scan for more correspondences
744 while (true) {
745 // Remember that TrackIter wraps circularly to the end iterator when
746 // decrementing it
747
748 // First move to a track with moving intervals and
749 // without a correspondent
750 do
751 forward ? ++pCaptured : --pCaptured;
752 while (pCaptured != end &&
753 (correspondence.count(*pCaptured) ||
754 mClipMoveState.shifters[*pCaptured]->MovingIntervals().empty()));
755 if (pCaptured == end)
756 break;
757
758 // Change the choice of possible correspondent track too
759 do
760 forward ? ++pDst : --pDst;
761 while (pDst != end && correspondence.count(*pDst));
762 if (pDst == end)
763 break;
764
765 // Make correspondence if we can
767 correspondence, trackList, **pCaptured, **pDst, mClipMoveState))
768 break;
769 }
770 };
771 // Try extension, backward first, then forward
772 // (anticipating the case of dragging a label that is under a clip)
773 tryExtend(false);
774 tryExtend(true);
775
776 // Having passed that test, remove clips temporarily from their
777 // tracks, so moving clips don't interfere with each other
778 // when we call CanInsertClip()
779 TemporaryClipRemover remover{ mClipMoveState };
780
781 // Now check that the move is possible
782 auto slideAmount = desiredSlideAmount;
783 // The test for tolerance will need review with FishEye!
784 // The tolerance is supposed to be the time for twenty pixels,
785 // i.e. twenty pixel tolerance at current zoom.
786 double tolerance =
787 viewInfo.PositionToTime(xx + 10) - viewInfo.PositionToTime(xx - 10);
788 bool ok = CheckFit( mClipMoveState, correspondence, remover.detached,
789 tolerance, slideAmount /*in,out*/ );
790
791 if (!ok) {
792 // Failure, even with using tolerance.
793 remover.Reinsert( nullptr, .0 );
794 return;
795 }
796
797 remover.Reinsert( &correspondence, slideAmount );
798
800 viewInfo.selectedRegion.move( slideAmount );
801
802 // Make the offset permanent; start from a "clean slate"
805 mDidSlideVertically = true;
806 desiredSlideAmount = .0;
807}
void move(double delta)
Definition: ViewInfo.cpp:97
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:146
TrackIter< Track > Find(Track *pTrack)
Definition: Track.cpp:470
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:34
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)
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References TrackList::Any(), details::begin(), anonymous_namespace{TimeShiftHandle.cpp}::CheckFit(), details::end(), TrackList::Find(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), forward, 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 809 of file TimeShiftHandle.cpp.

811{
812 using namespace RefreshCode;
813 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
814 if (unsafe) {
815 this->Cancel(pProject);
816 return RefreshAll | Cancelled;
817 }
818
819 const wxMouseEvent &event = evt.event;
820 auto &viewInfo = ViewInfo::Get( *pProject );
821
822 auto &trackList = TrackList::Get(*pProject);
823 ChannelView *trackView = dynamic_cast<ChannelView*>(evt.pCell.get());
824 const auto pChannel = trackView ? trackView->FindChannel() : nullptr;
825 auto track = pChannel
826 ? dynamic_cast<Track *>(&pChannel->GetChannelGroup())
827 : nullptr;
828
829 // Uncommenting this permits drag to continue to work even over the controls area
830 /*
831 track = static_cast<CommonTrackPanelCell*>(evt.pCell)->FindTrack().get();
832 */
833
834 if (!track) {
835 // Allow sliding if the pointer is not over any track, but only if x is
836 // within the bounds of the tracks area.
837 if (event.m_x >= mRect.GetX() &&
838 event.m_x < mRect.GetX() + mRect.GetWidth())
839 track = mClipMoveState.mCapturedTrack.get();
840 }
841
842 // May need a shared_ptr to reassign mCapturedTrack below
843 auto pTrack = Track::SharedPointer( track );
844 if (!pTrack)
846
847 // GM: slide now implementing snap-to
848 // samples functionality based on sample rate.
849
850 // Start by undoing the current slide amount; everything
851 // happens relative to the original horizontal position of
852 // each clip...
854
856 // Slide the selection, too
857 viewInfo.selectedRegion.move( -mClipMoveState.hSlideAmount );
858 }
860
861 double desiredSlideAmount = 0.0;
863 {
864 desiredSlideAmount =
865 viewInfo.PositionToTime(event.m_x) -
866 viewInfo.PositionToTime(mClipMoveState.mMouseClickX);
867
868 if (!mClipMoveState.shifters.empty())
869 desiredSlideAmount =
870 mClipMoveState.shifters[track]->QuantizeOffset(desiredSlideAmount);
871 }
872
873 if(mClipMoveState.mCapturedTrack != pTrack)
874 {
875 // Scroll during vertical drag.
876 // If the mouse is over a track that isn't the captured track,
877 // decide which tracks the captured clips should go to.
878 // Viewport::Get(*pProject).ShowTrack(pTrack); //vvv Gale says this has problems on Linux, per bug 393 thread. Revert for 2.0.2.
879
880 //move intervals with new start/end times
882 viewInfo, event.m_x, trackList, pTrack.get(), desiredSlideAmount);
883 }
884
886 {
887 AdjustToSnap(viewInfo, mRect.x,
888 mSnapManager.get(),
891 desiredSlideAmount);
892 }
893
894 if (desiredSlideAmount == 0.0)
895 return RefreshAll;
896
897 // Note that mouse dragging doesn't use TrackShifter::HintOffsetLarger()
898
899 mClipMoveState.DoSlideHorizontal( desiredSlideAmount );
900
902 // Slide the selection, too
903 viewInfo.selectedRegion.move( mClipMoveState.hSlideAmount );
904 }
905
906 return RefreshAll;
907}
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
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:110
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, CommonChannelCell::FindChannel(), 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 972 of file TimeShiftHandle.cpp.

975{
976 if ( iPass == TrackArtist::PassSnapping ) {
977 auto &dc = context.dc;
978 // Draw snap guidelines if we have any
979 if ( mSnapManager ) {
982 }
983 }
984}
AUDACITY_DLL_API void DrawSnapLines(wxDC *dc, wxInt64 snap0, wxInt64 snap1)
Definition: TrackArt.cpp:771

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

989{
990 if ( iPass == TrackArtist::PassSnapping )
991 return MaximizeHeight( rect, panelRect );
992 else
993 return rect;
994}
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:152

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

Referenced by AffordanceHandle::Enter().

Here is the caller graph for this function:

◆ FindTrack()

std::shared_ptr< const Track > TimeShiftHandle::FindTrack ( ) const
overridevirtual
Returns
pointer to associated track, if any

Implements UIHandle.

Definition at line 118 of file TimeShiftHandle.cpp.

119{
120 return GetTrack();
121}
std::shared_ptr< Track > GetTrack() const

References GetTrack().

Here is the call graph for this function:

◆ GetTrack()

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

Definition at line 38 of file TimeShiftHandle.cpp.

39{
41}

References ClipMoveState::mCapturedTrack, and mClipMoveState.

Referenced by FindTrack(), 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 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:164

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 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:189

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

303{ 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 909 of file TimeShiftHandle.cpp.

911{
912 // After all that, it still may be unsafe to drag.
913 // Even if so, make an informative cursor change from default to "banned."
914 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
915 return HitPreview(pProject, unsafe);
916}
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 918 of file TimeShiftHandle.cpp.

921{
922 using namespace RefreshCode;
923 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
924 if (unsafe)
925 return this->Cancel(pProject);
926
927 Result result = RefreshNone;
928
929 // Do not draw yellow lines
930 if ( mClipMoveState.snapLeft != -1 || mClipMoveState.snapRight != -1) {
932 result |= RefreshAll;
933 }
934
936 return result;
937
938 for ( auto &pair : mClipMoveState.shifters )
939 if (!pair.second->FinishMigration())
941
943 bool consolidate;
945 msg = XO("Moved clips to another track");
946 consolidate = false;
947 }
948 else {
949 msg = ( mClipMoveState.hSlideAmount > 0
950 ? XO("Time shifted tracks/clips right %.02f seconds")
951 : XO("Time shifted tracks/clips left %.02f seconds")
952 )
953 .Format( fabs( mClipMoveState.hSlideAmount ) );
954 consolidate = true;
955 }
956 ProjectHistory::Get( *pProject ).PushState(msg, XO("Move Clip"),
957 consolidate ? (UndoPush::CONSOLIDATE) : (UndoPush::NONE));
958
959 return result | FixScrollbars;
960}
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:40

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

335{ 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 364 of file TimeShiftHandle.h.

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

◆ mGripHit

bool TimeShiftHandle::mGripHit {}
private

Definition at line 376 of file TimeShiftHandle.h.

◆ mRect

wxRect TimeShiftHandle::mRect {}
private

Definition at line 362 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().

◆ mSlideUpDownOnly

bool TimeShiftHandle::mSlideUpDownOnly {}
private

Definition at line 365 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().

◆ mSnapManager

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

Definition at line 373 of file TimeShiftHandle.h.

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

◆ mSnapPreferRightEdge

bool TimeShiftHandle::mSnapPreferRightEdge {}
private

Definition at line 367 of file TimeShiftHandle.h.

Referenced by Click(), and Drag().


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