1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Another override of CellularPanel::FindRect taking a predicate

This commit is contained in:
Paul Licameli
2018-11-19 11:15:32 -05:00
parent 15777834e0
commit 5bb4e1446f
2 changed files with 21 additions and 0 deletions

View File

@@ -1043,6 +1043,21 @@ wxRect CellularPanel::FindRect( const TrackPanelCell &cell )
return result; return result;
} }
wxRect CellularPanel::FindRect(
const std::function< bool( TrackPanelNode& ) > &pred)
{
wxRect result;
struct Stop{};
try { VisitPreorder( [&]( const wxRect &rect, TrackPanelNode &visited ) {
if ( pred( visited ) )
result = rect, throw Stop{};
} ); }
catch ( const Stop& ) {}
return result;
}
UIHandlePtr CellularPanel::Target() UIHandlePtr CellularPanel::Target()
{ {
auto &state = *mState; auto &state = *mState;

View File

@@ -97,6 +97,12 @@ public:
// is not specified which rectangle is returned. // is not specified which rectangle is returned.
wxRect FindRect(const TrackPanelCell &cell); wxRect FindRect(const TrackPanelCell &cell);
// Search the tree of subdivisions of the panel area for a node (group or
// cell) satisfying the predicate. If more than one sub-area is associated
// with some node satisfying the predicate, it is not specified which
// rectangle is returned.
wxRect FindRect(const std::function< bool( TrackPanelNode& ) > &pred);
UIHandlePtr Target(); UIHandlePtr Target();
std::shared_ptr<TrackPanelCell> LastCell() const; std::shared_ptr<TrackPanelCell> LastCell() const;