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:
parent
cfa7afcb24
commit
01551913f0
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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(); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user