X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_plot.cc;h=fd261925518b3c058605bf4f04951895e073ec2f;hb=d8a2e55855b50eda28ec7d394449274f5e085bd6;hp=b8b9ead256133667fd7fdb392bfd5b2ef95c124d;hpb=cb2d996875db099ce456c18e9751f5dfe3d9056d;p=dcpomatic.git diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index b8b9ead25..fd2619255 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -40,6 +40,7 @@ AudioPlot::AudioPlot (wxWindow* 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); @@ -53,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)); } @@ -96,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); @@ -107,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; } @@ -138,7 +146,6 @@ AudioPlot::paint (wxPaintEvent &) gc->StrokePath (grid); gc->DrawText (_("Time"), data_width, _height - _y_origin + db_label_height / 2); - if (_type_visible[AudioPoint::PEAK]) { for (int c = 0; c < MAX_AUDIO_CHANNELS; ++c) { @@ -252,7 +259,9 @@ AudioPlot::plot_rms (wxGraphicsPath& path, int channel) const p += pow (*j, 2); } - p = sqrt (p / smoothing.size ()); + if (smoothing.size() > 0) { + p = sqrt (p / smoothing.size ()); + } path.AddLineToPoint (_db_label_width + i * _x_scale, y_for_linear (p)); }