21#include <wx/dcclient.h>
22#include <wx/graphics.h>
31 wxWindow* parent, wxWindowID winid,
34 , mCompressorSettings { compressorSettings }
36 SetDoubleBuffered(
true);
41constexpr auto WidthPxToDb(
double x,
int width,
double xPixelsPerDb)
43 return (x + 1 - width) / xPixelsPerDb;
46constexpr auto WidthDbToPx(
double db,
int width,
double xPixelsPerDb)
48 return width - 1 + db * xPixelsPerDb;
53 return -db * yPixelsPerDb;
57 double kneeX,
double kneeY,
const wxColor& colorAtKnee,
const wxSize&
size,
58 const wxGraphicsContext& gc)
61 constexpr auto w = .75;
64 const auto xf =
size.GetWidth() / 2.;
65 const auto yf =
size.GetHeight() / 2.;
66 const auto radius =
size.GetWidth();
67 return gc.CreateRadialGradientBrush(
68 kneeX, kneeY, xf, yf, radius, colorAtKnee, edgeColor);
74 const auto X = rect.GetWidth();
75 const auto Y = rect.GetHeight();
76 const auto xPixelsPerDb =
78 const auto yPixelsPerDb =
81 std::vector<wxPoint2DDouble> points;
83 for (
int x = rect.GetX(); x < X; ++x)
89 points.emplace_back(x, y);
101 wxGraphicsPath path = gc->CreatePath();
102 path.MoveToPoint(X, 0);
103 path.AddLineToPoint(0, 0);
104 std::for_each(points.begin(), points.end(), [&path](
const auto& point) {
105 path.AddLineToPoint(point);
112 path = gc->CreatePath();
113 path.MoveToPoint(X, Y);
114 path.AddLineToPoint(0, Y);
115 std::for_each(points.begin(), points.end(), [&path](
const auto& point) {
116 path.AddLineToPoint(point);
125 gc2->DrawLines(points.size(), points.data());
135 dc.SetBrush(*wxTRANSPARENT_BRUSH);
136 dc.DrawRectangle(rect);
static Settings & settings()
static float EvaluateTransferFunction(const DynamicRangeProcessorSettings &settings, float inputDb)
static constexpr auto rangeDb
const CompressorSettings & mCompressorSettings
bool AcceptsFocus() const override
void OnSize(wxSizeEvent &evt)
void OnPaint(wxPaintEvent &evt)
bool AcceptsFocusFromKeyboard() const override
wxColor GetColorMix(const wxColor &a, const wxColor &b, double aWeight)
static const wxColour targetCompressionColor
static constexpr auto targetCompressionLineWidth
std::unique_ptr< wxGraphicsContext > MakeGraphicsContext(const wxPaintDC &dc)
static const wxColour attackColor
static const wxColour backgroundColor
wxRect GetPanelRect(const wxPanelWrapper &panel)
static const wxColour releaseColor
static const wxColour lineColor
constexpr auto HeightDbToPx(double db, double yPixelsPerDb)
auto GetBrush(double kneeX, double kneeY, const wxColor &colorAtKnee, const wxSize &size, const wxGraphicsContext &gc)
constexpr auto WidthPxToDb(double x, int width, double xPixelsPerDb)
void DrawTransferFunction(wxPaintDC &dc, const wxRect &rect, const CompressorSettings &settings)
constexpr auto WidthDbToPx(double db, int width, double xPixelsPerDb)