mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-03 06:03:13 +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
src/tracks
playabletrack
ui
@ -742,7 +742,7 @@ public:
|
|||||||
~NoteTrackShifter() override {}
|
~NoteTrackShifter() override {}
|
||||||
Track &GetTrack() const override { return *mpTrack; }
|
Track &GetTrack() const override { return *mpTrack; }
|
||||||
|
|
||||||
HitTestResult HitTest( double ) override
|
HitTestResult HitTest( double, HitTestParams* ) override
|
||||||
{
|
{
|
||||||
return HitTestResult::Intervals;
|
return HitTestResult::Intervals;
|
||||||
}
|
}
|
||||||
|
@ -1314,7 +1314,7 @@ public:
|
|||||||
~WaveTrackShifter() override {}
|
~WaveTrackShifter() override {}
|
||||||
Track &GetTrack() const override { return *mpTrack; }
|
Track &GetTrack() const override { return *mpTrack; }
|
||||||
|
|
||||||
HitTestResult HitTest( double time ) override
|
HitTestResult HitTest( double time, HitTestParams* ) override
|
||||||
{
|
{
|
||||||
auto pClip = mpTrack->GetClipAtTime( time );
|
auto pClip = mpTrack->GetClipAtTime( time );
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ CoarseTrackShifter::CoarseTrackShifter( Track &track )
|
|||||||
|
|
||||||
CoarseTrackShifter::~CoarseTrackShifter() = default;
|
CoarseTrackShifter::~CoarseTrackShifter() = default;
|
||||||
|
|
||||||
auto CoarseTrackShifter::HitTest( double ) -> HitTestResult
|
auto CoarseTrackShifter::HitTest( double, HitTestParams* ) -> HitTestResult
|
||||||
{
|
{
|
||||||
return HitTestResult::Track;
|
return HitTestResult::Track;
|
||||||
}
|
}
|
||||||
@ -462,7 +462,10 @@ UIHandle::Result TimeShiftHandle::Click
|
|||||||
auto pShifter = MakeTrackShifter::Call( *pTrack );
|
auto pShifter = MakeTrackShifter::Call( *pTrack );
|
||||||
|
|
||||||
if (!event.ShiftDown()) {
|
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:
|
case TrackShifter::HitTestResult::Miss:
|
||||||
return Cancelled;
|
return Cancelled;
|
||||||
case TrackShifter::HitTestResult::Intervals: {
|
case TrackShifter::HitTestResult::Intervals: {
|
||||||
|
@ -25,6 +25,8 @@ class TrackList;
|
|||||||
class Track;
|
class Track;
|
||||||
class TrackInterval;
|
class TrackInterval;
|
||||||
|
|
||||||
|
class ViewInfo;
|
||||||
|
|
||||||
//! Abstract base class for policies to manipulate a track type with the Time Shift tool
|
//! Abstract base class for policies to manipulate a track type with the Time Shift tool
|
||||||
class TrackShifter {
|
class TrackShifter {
|
||||||
public:
|
public:
|
||||||
@ -39,9 +41,21 @@ public:
|
|||||||
Track //<! Shift selected track only as a whole
|
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
|
//! 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 */
|
/*! 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>;
|
using Intervals = std::vector<TrackInterval>;
|
||||||
|
|
||||||
@ -158,7 +172,7 @@ public:
|
|||||||
~CoarseTrackShifter() override;
|
~CoarseTrackShifter() override;
|
||||||
Track &GetTrack() const override { return *mpTrack; }
|
Track &GetTrack() const override { return *mpTrack; }
|
||||||
|
|
||||||
HitTestResult HitTest( double ) override;
|
HitTestResult HitTest( double, HitTestParams* ) override;
|
||||||
|
|
||||||
//! Returns false
|
//! Returns false
|
||||||
bool SyncLocks() override;
|
bool SyncLocks() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user