mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +02:00
Pass optional extra information into TrackShifter::HitTest ...
... Because LabelTrack, unlike the others, will also need a mouse y coordinate. The extra information is present when using the time-shift tool but not when using the items in ClipMenus.
This commit is contained in:
parent
69d5c1b12e
commit
14dc5af223
@ -742,7 +742,7 @@ public:
|
||||
~NoteTrackShifter() override {}
|
||||
Track &GetTrack() const override { return *mpTrack; }
|
||||
|
||||
HitTestResult HitTest( double ) override
|
||||
HitTestResult HitTest( double, HitTestParams* ) override
|
||||
{
|
||||
return HitTestResult::Intervals;
|
||||
}
|
||||
|
@ -1314,7 +1314,7 @@ public:
|
||||
~WaveTrackShifter() override {}
|
||||
Track &GetTrack() const override { return *mpTrack; }
|
||||
|
||||
HitTestResult HitTest( double time ) override
|
||||
HitTestResult HitTest( double time, HitTestParams* ) override
|
||||
{
|
||||
auto pClip = mpTrack->GetClipAtTime( time );
|
||||
|
||||
|
@ -241,7 +241,7 @@ CoarseTrackShifter::CoarseTrackShifter( Track &track )
|
||||
|
||||
CoarseTrackShifter::~CoarseTrackShifter() = default;
|
||||
|
||||
auto CoarseTrackShifter::HitTest( double ) -> HitTestResult
|
||||
auto CoarseTrackShifter::HitTest( double, HitTestParams* ) -> HitTestResult
|
||||
{
|
||||
return HitTestResult::Track;
|
||||
}
|
||||
@ -462,7 +462,10 @@ UIHandle::Result TimeShiftHandle::Click
|
||||
auto pShifter = MakeTrackShifter::Call( *pTrack );
|
||||
|
||||
if (!event.ShiftDown()) {
|
||||
switch( pShifter->HitTest( clickTime ) ) {
|
||||
TrackShifter::HitTestParams params{
|
||||
rect, event.m_x, event.m_y
|
||||
};
|
||||
switch( pShifter->HitTest( clickTime, ¶ms ) ) {
|
||||
case TrackShifter::HitTestResult::Miss:
|
||||
return Cancelled;
|
||||
case TrackShifter::HitTestResult::Intervals: {
|
||||
|
@ -25,6 +25,8 @@ class TrackList;
|
||||
class Track;
|
||||
class TrackInterval;
|
||||
|
||||
class ViewInfo;
|
||||
|
||||
//! Abstract base class for policies to manipulate a track type with the Time Shift tool
|
||||
class TrackShifter {
|
||||
public:
|
||||
@ -39,9 +41,21 @@ public:
|
||||
Track //<! Shift selected track only as a whole
|
||||
};
|
||||
|
||||
//! Optional, more complete information for hit testing
|
||||
struct HitTestParams {
|
||||
wxRect rect;
|
||||
wxCoord xx, yy;
|
||||
};
|
||||
|
||||
//! Decide how shift behaves, based on the track that is clicked in
|
||||
/*! If the return value is Intervals, then some intervals may be marked moving as a side effect */
|
||||
virtual HitTestResult HitTest( double time ) = 0;
|
||||
/*!
|
||||
@pre `!pParams || (time == pParams->viewInfo.PositionToTime(pParams->xx, pParams->rect.x))`
|
||||
*/
|
||||
virtual HitTestResult HitTest(
|
||||
double time, //!< A time value to test
|
||||
HitTestParams *pParams = nullptr //!< Optional extra information
|
||||
) = 0;
|
||||
|
||||
using Intervals = std::vector<TrackInterval>;
|
||||
|
||||
@ -158,7 +172,7 @@ public:
|
||||
~CoarseTrackShifter() override;
|
||||
Track &GetTrack() const override { return *mpTrack; }
|
||||
|
||||
HitTestResult HitTest( double ) override;
|
||||
HitTestResult HitTest( double, HitTestParams* ) override;
|
||||
|
||||
//! Returns false
|
||||
bool SyncLocks() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user