1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 08:39:46 +02:00

nonvirtual reimplementation of CellularPanel::FindRect using nodes

This commit is contained in:
Paul Licameli 2018-09-17 18:28:39 -04:00
parent cfa7afcb24
commit 01551913f0
6 changed files with 19 additions and 32 deletions

View File

@ -2141,17 +2141,6 @@ std::shared_ptr<TrackPanelNode> AdornedRulerPanel::Root()
return std::make_shared< MainGroup >( *this );
}
wxRect AdornedRulerPanel::FindRect(const TrackPanelCell &cell)
{
if (&cell == mScrubbingCell.get())
return mScrubZone;
if (&cell == mQPCell.get())
return mInner;
return {};
}
AudacityProject * AdornedRulerPanel::GetProject() const
{
return mProject;

View File

@ -176,8 +176,6 @@ private:
// Get the root object defining a recursive subdivision of the panel's
// area into cells
std::shared_ptr<TrackPanelNode> Root() override;
wxRect FindRect(const TrackPanelCell &cell) override;
public:
AudacityProject * GetProject() const override;
private:

View File

@ -1014,6 +1014,20 @@ auto CellularPanel::FindCell(int mouseX, int mouseY) -> FoundCell
return { {}, {} };
}
wxRect CellularPanel::FindRect( const TrackPanelCell &cell )
{
wxRect result;
struct Stop{};
try { VisitCells( [&]( const wxRect &rect, TrackPanelCell &visited ) {
if ( &visited == &cell )
result = rect, throw Stop{};
} ); }
catch ( const Stop& ) {}
return result;
}
UIHandlePtr CellularPanel::Target()
{
auto &state = *mState;

View File

@ -48,8 +48,6 @@ public:
// area into cells
virtual std::shared_ptr<TrackPanelNode> Root() = 0;
virtual wxRect FindRect(const TrackPanelCell &cell) = 0;
// Structure and functions for generalized visitation of the subdivision
struct Visitor {
virtual ~Visitor();
@ -94,6 +92,11 @@ public:
FoundCell FindCell(int mouseX, int mouseY);
// Search the tree of subdivisions of the panel area for the given cell.
// If more than one sub-area is associated with the same cell object, it
// is not specified which rectangle is returned.
wxRect FindRect(const TrackPanelCell &cell);
UIHandlePtr Target();
std::shared_ptr<TrackPanelCell> LastCell() const;

View File

@ -2088,20 +2088,6 @@ std::shared_ptr<TrackPanelNode> TrackPanel::Root()
return std::make_shared< MainGroup >( *this );
}
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

View File

@ -341,9 +341,6 @@ protected:
// area into cells
std::shared_ptr<TrackPanelNode> Root() override;
// Find rectangle of the given cell
wxRect FindRect(const TrackPanelCell &cell) override;
int GetVRulerWidth() const;
int GetVRulerOffset() const { return mTrackInfo.GetTrackInfoWidth(); }