mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 08:09:41 +02:00
Make OverlayPanel independent of AColor
This commit is contained in:
parent
fb713a5339
commit
3a1456bf53
@ -32,20 +32,6 @@ It is also a place to document colour usage policy in Audacity
|
||||
|
||||
#include "AllThemeResources.h"
|
||||
|
||||
void DCUnchanger::operator () (wxDC *pDC) const
|
||||
{
|
||||
if (pDC) {
|
||||
pDC->SetPen(pen);
|
||||
pDC->SetBrush(brush);
|
||||
pDC->SetLogicalFunction(wxRasterOperationMode(logicalOperation));
|
||||
}
|
||||
}
|
||||
|
||||
ADCChanger::ADCChanger(wxDC *pDC)
|
||||
: Base{ pDC, ::DCUnchanger{ pDC->GetBrush(), pDC->GetPen(),
|
||||
long(pDC->GetLogicalFunction()) } }
|
||||
{}
|
||||
|
||||
bool AColor::inited = false;
|
||||
wxBrush AColor::lightBrush[2];
|
||||
wxBrush AColor::mediumBrush[2];
|
||||
|
26
src/AColor.h
26
src/AColor.h
@ -22,32 +22,6 @@ class wxDC;
|
||||
class wxGraphicsContext;
|
||||
class wxRect;
|
||||
|
||||
/// Used to restore pen, brush and logical-op in a DC back to what they were.
|
||||
struct DCUnchanger {
|
||||
public:
|
||||
DCUnchanger() {}
|
||||
|
||||
DCUnchanger(const wxBrush &brush_, const wxPen &pen_, long logicalOperation_)
|
||||
: brush(brush_), pen(pen_), logicalOperation(logicalOperation_)
|
||||
{}
|
||||
|
||||
void operator () (wxDC *pDC) const;
|
||||
|
||||
wxBrush brush {};
|
||||
wxPen pen {};
|
||||
long logicalOperation {};
|
||||
};
|
||||
|
||||
/// Makes temporary drawing context changes that you back out of, RAII style
|
||||
// It's like wxDCPenChanger, etc., but simple and general
|
||||
class ADCChanger : public std::unique_ptr<wxDC, ::DCUnchanger>
|
||||
{
|
||||
using Base = std::unique_ptr<wxDC, ::DCUnchanger>;
|
||||
public:
|
||||
ADCChanger() : Base{} {}
|
||||
ADCChanger(wxDC *pDC);
|
||||
};
|
||||
|
||||
class AColor {
|
||||
public:
|
||||
|
||||
|
@ -19,6 +19,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "TrackPanelMouseEvent.h"
|
||||
#include "HitTestResult.h"
|
||||
#include "ViewInfo.h"
|
||||
#include "widgets/OverlayPanel.h"
|
||||
|
||||
#include "tracks/ui/TrackView.h"
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "OverlayPanel.h"
|
||||
|
||||
#include "Overlay.h"
|
||||
#include "../AColor.h"
|
||||
#include <algorithm>
|
||||
#include <wx/dcclient.h>
|
||||
|
||||
@ -134,3 +133,18 @@ void OverlayPanel::Compress()
|
||||
|
||||
BEGIN_EVENT_TABLE(OverlayPanel, BackedPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Maybe this class needs a better home
|
||||
void DCUnchanger::operator () (wxDC *pDC) const
|
||||
{
|
||||
if (pDC) {
|
||||
pDC->SetPen(pen);
|
||||
pDC->SetBrush(brush);
|
||||
pDC->SetLogicalFunction(wxRasterOperationMode(logicalOperation));
|
||||
}
|
||||
}
|
||||
|
||||
ADCChanger::ADCChanger(wxDC *pDC)
|
||||
: Base{ pDC, ::DCUnchanger{ pDC->GetBrush(), pDC->GetPen(),
|
||||
long(pDC->GetLogicalFunction()) } }
|
||||
{}
|
||||
|
@ -50,4 +50,30 @@ private:
|
||||
friend class GetInfoCommand;
|
||||
};
|
||||
|
||||
/// Used to restore pen, brush and logical-op in a DC back to what they were.
|
||||
struct DCUnchanger {
|
||||
public:
|
||||
DCUnchanger() {}
|
||||
|
||||
DCUnchanger(const wxBrush &brush_, const wxPen &pen_, long logicalOperation_)
|
||||
: brush(brush_), pen(pen_), logicalOperation(logicalOperation_)
|
||||
{}
|
||||
|
||||
void operator () (wxDC *pDC) const;
|
||||
|
||||
wxBrush brush {};
|
||||
wxPen pen {};
|
||||
long logicalOperation {};
|
||||
};
|
||||
|
||||
/// Makes temporary drawing context changes that you back out of, RAII style
|
||||
// It's like wxDCPenChanger, etc., but simple and general
|
||||
class ADCChanger : public std::unique_ptr<wxDC, ::DCUnchanger>
|
||||
{
|
||||
using Base = std::unique_ptr<wxDC, ::DCUnchanger>;
|
||||
public:
|
||||
ADCChanger() : Base{} {}
|
||||
ADCChanger(wxDC *pDC);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user