mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +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"
|
#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;
|
bool AColor::inited = false;
|
||||||
wxBrush AColor::lightBrush[2];
|
wxBrush AColor::lightBrush[2];
|
||||||
wxBrush AColor::mediumBrush[2];
|
wxBrush AColor::mediumBrush[2];
|
||||||
|
26
src/AColor.h
26
src/AColor.h
@ -22,32 +22,6 @@ class wxDC;
|
|||||||
class wxGraphicsContext;
|
class wxGraphicsContext;
|
||||||
class wxRect;
|
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 {
|
class AColor {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "TrackPanelMouseEvent.h"
|
#include "TrackPanelMouseEvent.h"
|
||||||
#include "HitTestResult.h"
|
#include "HitTestResult.h"
|
||||||
#include "ViewInfo.h"
|
#include "ViewInfo.h"
|
||||||
|
#include "widgets/OverlayPanel.h"
|
||||||
|
|
||||||
#include "tracks/ui/TrackView.h"
|
#include "tracks/ui/TrackView.h"
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "OverlayPanel.h"
|
#include "OverlayPanel.h"
|
||||||
|
|
||||||
#include "Overlay.h"
|
#include "Overlay.h"
|
||||||
#include "../AColor.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <wx/dcclient.h>
|
#include <wx/dcclient.h>
|
||||||
|
|
||||||
@ -134,3 +133,18 @@ void OverlayPanel::Compress()
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(OverlayPanel, BackedPanel)
|
BEGIN_EVENT_TABLE(OverlayPanel, BackedPanel)
|
||||||
END_EVENT_TABLE()
|
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;
|
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
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user