X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_plot.cc;h=7ed792351bb30e49ecbfa33fdb1ad12b72a3e286;hb=1ba7bca7f2950faa441ec83920d35b65016f3fa6;hp=3fec1d3fe3dec0f2e2af8026e94c1e9aed497f20;hpb=003de48cd0371a60d095dc9d02ed5763c410cf5e;p=dcpomatic.git diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index 3fec1d3fe..7ed792351 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -21,7 +21,6 @@ #include #include #include "audio_plot.h" -#include "lib/decoder_factory.h" #include "lib/audio_decoder.h" #include "lib/audio_analysis.h" #include "wx/wx_util.h" @@ -38,9 +37,10 @@ int const AudioPlot::_minimum = -70; int const AudioPlot::max_smoothing = 128; AudioPlot::AudioPlot (wxWindow* parent) - : wxPanel (parent) + : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) , _gain (0) , _smoothing (max_smoothing / 2) + , _message (_("Please wait; audio is being analysed...")) { #ifndef __WXOSX__ SetDoubleBuffered (true); @@ -54,14 +54,14 @@ AudioPlot::AudioPlot (wxWindow* parent) _type_visible[i] = false; } - _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 ( 0, 0, 0)); + _colours.push_back (wxColour (255, 0, 0)); + _colours.push_back (wxColour ( 0, 255, 0)); _colours.push_back (wxColour (139, 0, 204)); - _colours.push_back (wxColour ( 0, 0, 255)); + _colours.push_back (wxColour ( 0, 0, 255)); _colours.push_back (wxColour (100, 100, 100)); - Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (AudioPlot::paint), 0, this); + Bind (wxEVT_PAINT, boost::bind (&AudioPlot::paint, this)); SetMinSize (wxSize (640, 512)); } @@ -97,7 +97,14 @@ AudioPlot::set_type_visible (int t, bool v) } void -AudioPlot::paint (wxPaintEvent &) +AudioPlot::set_message (wxString s) +{ + _message = s; + Refresh (); +} + +void +AudioPlot::paint () { wxPaintDC dc (this); @@ -108,7 +115,7 @@ AudioPlot::paint (wxPaintEvent &) if (!_analysis || _analysis->channels() == 0) { gc->SetFont (gc->CreateFont (*wxNORMAL_FONT)); - gc->DrawText (_("Please wait; audio is being analysed..."), 32, 32); + gc->DrawText (_message, 32, 32); return; } @@ -148,11 +155,7 @@ AudioPlot::paint (wxPaintEvent &) plot_peak (p, c); } wxColour const col = _colours[c]; -#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9 gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (col.Red(), col.Green(), col.Blue(), col.Alpha() / 2), 1, wxPENSTYLE_SOLID)); -#else - gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (col.Red(), col.Green(), col.Blue(), col.Alpha() / 2), 1, wxSOLID)); -#endif gc->StrokePath (p); } } @@ -164,11 +167,7 @@ AudioPlot::paint (wxPaintEvent &) plot_rms (p, c); } wxColour const col = _colours[c]; -#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9 gc->SetPen (*wxThePenList->FindOrCreatePen (col, 1, wxPENSTYLE_SOLID)); -#else - gc->SetPen (*wxThePenList->FindOrCreatePen (col, 1, wxSOLID)); -#endif gc->StrokePath (p); } } @@ -192,6 +191,10 @@ AudioPlot::y_for_linear (float p) const void AudioPlot::plot_peak (wxGraphicsPath& path, int channel) const { + if (_analysis->points (channel) == 0) { + return; + } + path.MoveToPoint (_db_label_width, y_for_linear (_analysis->get_point(channel, 0)[AudioPoint::PEAK])); float peak = 0; @@ -212,6 +215,10 @@ AudioPlot::plot_peak (wxGraphicsPath& path, int channel) const void AudioPlot::plot_rms (wxGraphicsPath& path, int channel) const { + if (_analysis->points (channel) == 0) { + return; + } + path.MoveToPoint (_db_label_width, y_for_linear (_analysis->get_point(channel, 0)[AudioPoint::RMS])); list smoothing;