diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 088b78fa7..59a7bd199 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -534,8 +534,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, // This is used to snap the cursor to the nearest track that // lines up with it. mSnapManager = NULL; - mSnapLeft = -1; - mSnapRight = -1; // Register for tracklist updates mTracks->Connect(EVT_TRACKLIST_RESIZED, @@ -2064,8 +2062,7 @@ void TrackPanel::SelectionHandleClick(wxMouseEvent & event, // We create a NEW snap manager in case any snap-points have changed mSnapManager = std::make_unique(GetTracks(), mViewInfo); - mSnapLeft = -1; - mSnapRight = -1; + mSnapLeft = mSnapRight = -1; #ifdef USE_MIDI mStretching = false; @@ -2346,8 +2343,7 @@ void TrackPanel::StartSelection(int mouseXCoordinate, int trackLeftEdge) double s = mSelStart; if (mSnapManager) { - mSnapLeft = -1; - mSnapRight = -1; + mSnapLeft = mSnapRight = -1; bool snappedPoint, snappedTime; if (mSnapManager->Snap(mCapturedTrack, mSelStart, false, &s, &snappedPoint, &snappedTime)) { @@ -2393,8 +2389,7 @@ void TrackPanel::ExtendSelection(int mouseXCoordinate, int trackLeftEdge, origSel1 = sel1; if (mSnapManager) { - mSnapLeft = -1; - mSnapRight = -1; + mSnapLeft = mSnapRight = -1; bool snappedPoint, snappedTime; if (mSnapManager->Snap(mCapturedTrack, sel0, false, &sel0, &snappedPoint, &snappedTime)) { @@ -2413,8 +2408,7 @@ void TrackPanel::ExtendSelection(int mouseXCoordinate, int trackLeftEdge, !snappedTime) { sel0 = origSel0; sel1 = origSel1; - mSnapLeft = -1; - mSnapRight = -1; + mSnapLeft = mSnapRight = -1; } } @@ -7192,13 +7186,13 @@ void TrackPanel::DrawEverythingElse(wxDC * dc, } // Draw snap guidelines if we have any - if (mSnapManager && (mSnapLeft >= 0 || mSnapRight >= 0)) { + if ( mSnapManager && ( GetSnapLeft() >= 0 || GetSnapRight() >= 0 )) { AColor::SnapGuidePen(dc); - if (mSnapLeft >= 0) { - AColor::Line(*dc, (int)mSnapLeft, 0, mSnapLeft, 30000); + if ( GetSnapLeft() >= 0 ) { + AColor::Line(*dc, (int)GetSnapLeft(), 0, GetSnapLeft(), 30000); } - if (mSnapRight >= 0) { - AColor::Line(*dc, (int)mSnapRight, 0, mSnapRight, 30000); + if ( GetSnapRight() >= 0 ) { + AColor::Line(*dc, (int)GetSnapRight(), 0, GetSnapRight(), 30000); } } } diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 6c765f9a6..b3157c218 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -702,10 +702,16 @@ protected: // are the horizontal index of pixels to display user feedback // guidelines so the user knows when such snapping is taking place. std::unique_ptr mSnapManager; - wxInt64 mSnapLeft; - wxInt64 mSnapRight; + wxInt64 mSnapLeft { -1 }; + wxInt64 mSnapRight { -1 }; bool mSnapPreferRightEdge; +public: + wxInt64 GetSnapLeft () const { return mSnapLeft ; } + wxInt64 GetSnapRight() const { return mSnapRight; } + +protected: + NumericConverter mConverter; WaveTrack * mDrawingTrack; // Keeps track of which track you are drawing on between events cf. HandleDraw()