MCPcopy Create free account
hub / github.com/audacity/audacity / Drag

Method Drag

src/tracks/ui/SelectHandle.cpp:809–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

807}
808
809UIHandle::Result SelectHandle::Drag(const TrackPanelMouseEvent &evt,
810 AudacityProject *pProject)
811{
812 using namespace RefreshCode;
813
814 const auto pView = mpView.lock();
815 if ( !pView )
816 return Cancelled;
817 auto &view = *pView;
818
819 auto &viewInfo = ViewInfo::Get( *pProject );
820 const wxMouseEvent &event = evt.event;
821
822 int x = mAutoScrolling ? mMostRecentX : event.m_x;
823 int y = mAutoScrolling ? mMostRecentY : event.m_y;
824 mMostRecentX = x;
825 mMostRecentY = y;
826
827 /// AS: If we're dragging to adjust a selection (or actually,
828 /// if the screen is scrolling while you're selecting), we
829 /// handle it here.
830
831 // Fuhggeddaboudit if we're not dragging and not autoscrolling.
832 if (!event.Dragging() && !mAutoScrolling)
833 return RefreshNone;
834
835 if (event.CmdDown()) {
836 // Ctrl-drag has no meaning, fuhggeddaboudit
837 // JKC YES it has meaning.
838 //return RefreshNone;
839 }
840
841 // Also fuhggeddaboudit if not in a track.
842 const auto pChannel = view.FindChannel();
843 if (!pChannel)
844 return RefreshNone;
845
846 // JKC: Logic to prevent a selection smaller than 5 pixels to
847 // prevent accidental dragging when selecting.
848 // (if user really wants a tiny selection, they should zoom in).
849 // Can someone make this value of '5' configurable in
850 // preferences?
851 enum { minimumSizedSelection = 5 }; //measured in pixels
852
853 // Might be dragging frequency bounds only, test
854 if (mSelStartValid) {
855 wxInt64 SelStart = viewInfo.TimeToPosition(mSelStart, mRect.x); //cvt time to pixels.
856 // Abandon this drag if selecting < 5 pixels.
857 if (wxLongLong(SelStart - x).Abs() < minimumSizedSelection)
858 return RefreshNone;
859 }
860
861 if (evt.pCell) {
862 if ( auto clickedTrack =
863 static_cast<CommonTrackPanelCell*>(evt.pCell.get())->FindTrack() ) {
864 // Handle which tracks are selected
865 Track *sTrack = FindTrack();
866 Track *eTrack = clickedTrack.get();

Callers 1

OnTimerMethod · 0.45

Calls 9

GetFunction · 0.85
TimeToPositionMethod · 0.80
AbsMethod · 0.80
SelectRangeOfTracksMethod · 0.80
FindTrackFunction · 0.70
lockMethod · 0.45
FindChannelMethod · 0.45
FindTrackMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected