1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-04 17:49:45 +02:00

Remove pTrack from FoundCell; new function hides some casting

This commit is contained in:
Paul Licameli 2018-06-24 22:14:37 -04:00
parent 79067e43f0
commit 7395e5acbd
2 changed files with 13 additions and 12 deletions

View File

@ -628,6 +628,15 @@ void TrackPanel::HandleInterruptedDrag()
} }
} }
namespace {
std::shared_ptr<Track> FindTrack(TrackPanelCell *pCell )
{
if (pCell)
return static_cast<CommonTrackPanelCell*>( pCell )->FindTrack();
return {};
}
}
void TrackPanel::ProcessUIHandleResult void TrackPanel::ProcessUIHandleResult
(Track *pClickedTrack, Track *pLatestTrack, (Track *pClickedTrack, Track *pLatestTrack,
UIHandle::Result refreshResult) UIHandle::Result refreshResult)
@ -844,10 +853,7 @@ void TrackPanel::HandleMotion
auto newCell = tpmState.pCell; auto newCell = tpmState.pCell;
std::shared_ptr<Track> newTrack; const auto newTrack = FindTrack( newCell.get() );
if ( newCell )
newTrack = static_cast<CommonTrackPanelCell*>( newCell.get() )->
FindTrack();
wxString status{}, tooltip{}; wxString status{}, tooltip{};
wxCursor *pCursor{}; wxCursor *pCursor{};
@ -865,10 +871,7 @@ void TrackPanel::HandleMotion
// Not yet dragging. // Not yet dragging.
auto oldCell = mLastCell.lock(); auto oldCell = mLastCell.lock();
std::shared_ptr<Track> oldTrack; const auto oldTrack = FindTrack( oldCell.get() );
if ( oldCell )
oldTrack = static_cast<CommonTrackPanelCell*>( oldCell.get() )->
FindTrack();
unsigned updateFlags = mMouseOverUpdateFlags; unsigned updateFlags = mMouseOverUpdateFlags;
@ -1540,7 +1543,7 @@ try
const auto foundCell = FindCell( event.m_x, event.m_y ); const auto foundCell = FindCell( event.m_x, event.m_y );
auto &rect = foundCell.rect; auto &rect = foundCell.rect;
auto &pCell = foundCell.pCell; auto &pCell = foundCell.pCell;
auto &pTrack = foundCell.pTrack; const auto pTrack = FindTrack( pCell.get() );
const auto size = GetSize(); const auto size = GetSize();
TrackPanelMouseEvent tpmEvent{ event, rect, size, pCell }; TrackPanelMouseEvent tpmEvent{ event, rect, size, pCell };
@ -1677,7 +1680,7 @@ try
wxRect rect; wxRect rect;
const auto foundCell = FindCell(event.m_x, event.m_y); const auto foundCell = FindCell(event.m_x, event.m_y);
auto t = foundCell.pTrack; const auto t = FindTrack( foundCell.pCell.get() );
if ( t ) if ( t )
EnsureVisible(t.get()); EnsureVisible(t.get());
} }
@ -2773,7 +2776,6 @@ TrackPanel::FoundCell TrackPanel::FindCell(int mouseX, int mouseY)
iter = prev; iter = prev;
auto found = *iter; auto found = *iter;
return { return {
static_cast<CommonTrackPanelCell*>( found.first.get() )->FindTrack(),
found.first, found.first,
found.second found.second
}; };

View File

@ -367,7 +367,6 @@ protected:
// Find track info by coordinate // Find track info by coordinate
struct FoundCell { struct FoundCell {
std::shared_ptr<Track> pTrack;
std::shared_ptr<TrackPanelCell> pCell; std::shared_ptr<TrackPanelCell> pCell;
wxRect rect; wxRect rect;
}; };