Move UserProperty into its own file.
[dcpomatic.git] / src / wx / audio_panel.cc
index 8e13225c76cd32da086d7c7dcf8829b5ba691bde..9e2ba986939dea29fd6b9aebd00735eea15bf000 100644 (file)
@@ -29,7 +29,6 @@
 #include "lib/job_manager.h"
 #include "lib/dcp_content.h"
 #include <wx/spinctrl.h>
-#include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
 #include <iostream>
 
@@ -39,7 +38,6 @@ using std::string;
 using std::list;
 using std::pair;
 using boost::dynamic_pointer_cast;
-using boost::lexical_cast;
 using boost::shared_ptr;
 using boost::optional;
 
@@ -56,15 +54,11 @@ AudioPanel::AudioPanel (ContentPanel* p)
        grid->Add (_reference, wxGBPosition (r, 0), wxGBSpan (1, 2));
        ++r;
 
-       {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _show = new wxButton (this, wxID_ANY, _("Show graph of audio levels..."));
-               s->Add (_show);
-               _peak = new wxStaticText (this, wxID_ANY, wxT (""));
-               s->Add (_peak, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_X_GAP);
-               grid->Add (s, wxGBPosition (r, 0), wxGBSpan (1, 2));
-               ++r;
-       }
+       _show = new wxButton (this, wxID_ANY, _("Show graph of audio levels..."));
+       grid->Add (_show, wxGBPosition (r, 0), wxGBSpan (1, 2));
+       _peak = new wxStaticText (this, wxID_ANY, wxT (""));
+       grid->Add (_peak, wxGBPosition (r, 2), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL);
+       ++r;
 
        add_label_to_sizer (grid, this, _("Gain"), true, wxGBPosition (r, 0));
        _gain = new ContentSpinCtrlDouble<AudioContent> (
@@ -173,6 +167,8 @@ AudioPanel::film_content_changed (int property)
                }
 
                setup_sensitivity ();
+       } else if (property == AudioContentProperty::AUDIO_VIDEO_FRAME_RATE) {
+               setup_description ();
        }
 }
 
@@ -249,16 +245,7 @@ AudioPanel::setup_sensitivity ()
 
        list<string> why_not;
        bool const can_reference = dcp && dcp->can_reference_audio (why_not);
-       _reference->Enable (can_reference);
-
-       wxString s;
-       if (!can_reference) {
-               s = _("Cannot reference this DCP.  ");
-               BOOST_FOREACH (string i, why_not) {
-                       s += std_to_wx(i) + wxT("  ");
-               }
-       }
-       _reference->SetToolTip (s);
+       setup_refer_button (_reference, dcp, can_reference, why_not);
 
        if (_reference->GetValue ()) {
                _gain->wrapped()->Enable (false);
@@ -307,8 +294,8 @@ AudioPanel::setup_peak ()
                playlist->add (sel.front ());
                try {
                        shared_ptr<AudioAnalysis> analysis (new AudioAnalysis (_parent->film()->audio_analysis_path (playlist)));
-                       if (analysis->peak ()) {
-                               float const peak_dB = 20 * log10 (analysis->peak().get()) + analysis->gain_correction (playlist);
+                       if (analysis->sample_peak ()) {
+                               float const peak_dB = 20 * log10 (analysis->sample_peak().get()) + analysis->gain_correction (playlist);
                                if (peak_dB > -3) {
                                        alert = true;
                                }