diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 837577fd6..0d608344b 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -2829,6 +2829,20 @@ auto TrackPanel::FindCell(int mouseX, int mouseY) -> FoundCell }; } +wxRect TrackPanel::FindRect( const TrackPanelCell &cell ) +{ + auto range = Cells(); + auto end = range.second, + iter = std::find_if( range.first, end, + [&]( const decltype(*end) &pair ) + { return pair.first.get() == &cell; } + ); + if (iter == end) + return {}; + else + return (*iter).second; +} + // This finds the rectangle of a given track (including all channels), // either that of the label 'adornment' or the track itself // The given track is assumed to be the first channel diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 0afaab43f..78b264cae 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -268,6 +268,7 @@ public: wxRect rect; }; virtual FoundCell FindCell(int mouseX, int mouseY) = 0; + virtual wxRect FindRect(const TrackPanelCell &cell) = 0; virtual TrackPanelCell *GetFocusedCell() = 0; virtual void SetFocusedCell() = 0; @@ -467,6 +468,9 @@ protected: // Find track info by coordinate FoundCell FindCell(int mouseX, int mouseY) override; + // Find rectangle of the given cell + wxRect FindRect(const TrackPanelCell &cell) override; + int GetVRulerWidth() const; int GetVRulerOffset() const { return mTrackInfo.GetTrackInfoWidth(); }