X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_plot.cc;h=abd538037e5f6e53ff996443dfa283d883406aff;hb=HEAD;hp=e08e07e0505bb3f6ba4d246c5a4d39f72dd6c364;hpb=cf2ed48d21ddbc32bda262064480e88e69dc031a;p=dcpomatic.git diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index e08e07e05..abd538037 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -25,14 +25,16 @@ #include "lib/audio_decoder.h" #include "lib/audio_analysis.h" #include "lib/compose.hpp" +#include "lib/constants.h" #include "lib/maths_util.h" +#include +LIBDCP_DISABLE_WARNINGS #include +LIBDCP_ENABLE_WARNINGS #include #include -#include -using std::cout; using std::list; using std::map; using std::max; @@ -53,7 +55,7 @@ int const AudioPlot::_cursor_size = 8; int const AudioPlot::max_smoothing = 128; -AudioPlot::AudioPlot (wxWindow* parent, weak_ptr viewer) +AudioPlot::AudioPlot(wxWindow* parent, FilmViewer& viewer) : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) , _viewer (viewer) , _smoothing (max_smoothing / 2) @@ -71,7 +73,11 @@ AudioPlot::AudioPlot (wxWindow* parent, weak_ptr viewer) _type_visible[i] = false; } - _colours.push_back (wxColour ( 0, 0, 0)); + if (gui_is_dark()) { + _colours.push_back(wxColour(255, 255, 255)); + } else { + _colours.push_back(wxColour(0, 0, 0)); + } _colours.push_back (wxColour (255, 0, 0)); _colours.push_back (wxColour ( 0, 255, 0)); _colours.push_back (wxColour (139, 0, 204)); @@ -164,14 +170,14 @@ AudioPlot::paint () gc->SetAntialiasMode (wxANTIALIAS_DEFAULT); if (!_analysis || _analysis->channels() == 0) { - gc->SetFont (gc->CreateFont (*wxNORMAL_FONT)); + gc->SetFont(gc->CreateFont(*wxNORMAL_FONT, gui_is_dark() ? *wxWHITE : *wxBLACK)); gc->DrawText (_message, 32, 32); delete gc; return; } auto h_grid = gc->CreatePath (); - gc->SetFont (gc->CreateFont (*wxSMALL_FONT)); + gc->SetFont(gc->CreateFont(*wxSMALL_FONT, gui_is_dark() ? *wxWHITE : *wxBLACK)); wxDouble db_label_height; wxDouble db_label_descent; wxDouble db_label_leading; @@ -194,7 +200,9 @@ AudioPlot::paint () gc->DrawText (std_to_wx (String::compose ("%1dB", i)), 0, y - (db_label_height / 2)); } - gc->SetPen (wxPen (wxColour (200, 200, 200))); + wxColour const grid_colour = gui_is_dark() ? wxColour(80, 80, 80) : wxColour(200, 200, 200); + + gc->SetPen(wxPen(grid_colour)); gc->StrokePath (h_grid); /* Draw an x axis with marks */ @@ -204,8 +212,6 @@ AudioPlot::paint () DCPOMATIC_ASSERT (_analysis->samples_per_point() != 0.0); double const pps = _analysis->sample_rate() * metrics.x_scale / _analysis->samples_per_point(); - gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, wxPENSTYLE_SOLID)); - double const mark_interval = calculate_mark_interval (rint (128 / pps)); auto t = DCPTime::from_seconds (mark_interval); @@ -233,7 +239,7 @@ AudioPlot::paint () t += DCPTime::from_seconds (mark_interval); } - gc->SetPen (wxPen (wxColour (200, 200, 200))); + gc->SetPen(wxPen(grid_colour)); gc->StrokePath (v_grid); if (_type_visible[AudioPoint::PEAK]) { @@ -264,7 +270,7 @@ AudioPlot::paint () axes.MoveToPoint (metrics.db_label_width, 0); axes.AddLineToPoint (metrics.db_label_width, metrics.height - metrics.y_origin); axes.AddLineToPoint (metrics.db_label_width + data_width, metrics.height - metrics.y_origin); - gc->SetPen (wxPen (wxColour (0, 0, 0))); + gc->SetPen(wxPen(grid_colour)); gc->StrokePath (axes); if (_cursor) { @@ -444,9 +450,7 @@ void AudioPlot::left_down () { if (_cursor) { - if (auto fv = _viewer.lock()) { - fv->seek (_cursor->time, true); - } + _viewer.seek(_cursor->time, true); } }