mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-21 06:01:13 +02:00
Drawing sequence for overlays independent of insertion call sequence
This commit is contained in:
@@ -93,6 +93,10 @@ class Overlay
|
||||
public:
|
||||
virtual ~Overlay() = 0;
|
||||
|
||||
///\brief This number determines an ordering of overlays, so that those
|
||||
/// with higher numbers overpaint those with lower numbers that intersect
|
||||
virtual unsigned SequenceNumber() const = 0;
|
||||
|
||||
// nonvirtual wrapper
|
||||
std::pair<wxRect, bool> GetRectangle(wxSize size);
|
||||
|
||||
|
@@ -23,7 +23,16 @@ OverlayPanel::OverlayPanel(wxWindow * parent, wxWindowID id,
|
||||
|
||||
void OverlayPanel::AddOverlay( const std::weak_ptr<Overlay> &pOverlay)
|
||||
{
|
||||
mOverlays.push_back(pOverlay);
|
||||
if (pOverlay.expired())
|
||||
return;
|
||||
Compress();
|
||||
auto iter = std::lower_bound( mOverlays.begin(), mOverlays.end(),
|
||||
pOverlay.lock()->SequenceNumber(),
|
||||
[]( const OverlayPtr &p, unsigned value ) {
|
||||
return p.expired() || p.lock()->SequenceNumber() < value;
|
||||
}
|
||||
);
|
||||
mOverlays.insert(iter, pOverlay);
|
||||
}
|
||||
|
||||
void OverlayPanel::ClearOverlays()
|
||||
|
@@ -40,8 +40,10 @@ public:
|
||||
void DrawOverlays(bool repaint_all, wxDC *pDC = nullptr);
|
||||
|
||||
private:
|
||||
using OverlayPtr = std::weak_ptr<Overlay>;
|
||||
|
||||
void Compress();
|
||||
std::vector< std::weak_ptr<Overlay> > mOverlays;
|
||||
std::vector< OverlayPtr > mOverlays;
|
||||
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
Reference in New Issue
Block a user