Audacity 3.2.0
OverlayPanel.h
Go to the documentation of this file.
1//
2// OverlayPanel.h
3// Audacity
4//
5// Created by Paul Licameli on 5/1/16.
6//
7//
8
9#ifndef __AUDACITY_OVERLAY_PANEL__
10#define __AUDACITY_OVERLAY_PANEL__
11
12#include <memory>
13#include <vector>
14#include "BackedPanel.h" // to inherit
15
16class Overlay;
17
18class AUDACITY_DLL_API OverlayPanel /* not final */ : public BackedPanel {
19public:
20 OverlayPanel(wxWindow * parent, wxWindowID id,
21 const wxPoint & pos,
22 const wxSize & size,
23 // default as for wxPanel:
24 long style = wxTAB_TRAVERSAL | wxNO_BORDER);
25
26 // Registers overlay objects.
27 // The sequence in which they were registered is the sequence in
28 // which they are painted.
29 // OverlayPanel is not responsible for their memory management.
30 void AddOverlay( const std::weak_ptr<Overlay> &pOverlay );
31 void ClearOverlays();
32
33 // Erases and redraws to the client area the overlays that have
34 // been previously added with AddOverlay(). If "repaint_all" is
35 // true, all overlays will be erased and re-drawn. Otherwise, only
36 // the ones that are out-of-date, as well as the intersecting ones,
37 // will be erased and re-drawn.
38 // pDC can be null, in which case, DrawOverlays() will create a
39 // wxClientDC internally when necessary.
40 void DrawOverlays(bool repaint_all, wxDC *pDC = nullptr);
41
42private:
43 using OverlayPtr = std::weak_ptr<Overlay>;
44
45 void Compress();
46 std::vector< OverlayPtr > mOverlays;
47
48
49 DECLARE_EVENT_TABLE()
50 friend class GetInfoCommand;
51};
52
54struct AUDACITY_DLL_API DCUnchanger {
55public:
57
58 DCUnchanger(const wxBrush &brush_, const wxPen &pen_, long logicalOperation_)
59 : brush(brush_), pen(pen_), logicalOperation(logicalOperation_)
60 {}
61
62 void operator () (wxDC *pDC) const;
63
64 wxBrush brush {};
65 wxPen pen {};
66 long logicalOperation {};
67};
68
70// It's like wxDCPenChanger, etc., but simple and general
71class AUDACITY_DLL_API ADCChanger : public std::unique_ptr<wxDC, ::DCUnchanger>
72{
73 using Base = std::unique_ptr<wxDC, ::DCUnchanger>;
74public:
76 ADCChanger(wxDC *pDC);
77};
78
79#endif
Makes temporary drawing context changes that you back out of, RAII style.
Definition: OverlayPanel.h:72
std::unique_ptr< wxDC, ::DCUnchanger > Base
Definition: OverlayPanel.h:73
BackedPanel is for a panel that consists of a bitmap with something drawn over it....
Definition: BackedPanel.h:19
Command which outputs a list of available menu commands on the status channel.
std::weak_ptr< Overlay > OverlayPtr
Definition: OverlayPanel.h:43
std::vector< OverlayPtr > mOverlays
Definition: OverlayPanel.h:46
Used to restore pen, brush and logical-op in a DC back to what they were.
Definition: OverlayPanel.h:54
DCUnchanger(const wxBrush &brush_, const wxPen &pen_, long logicalOperation_)
Definition: OverlayPanel.h:58