More enum class additions.
[dcpomatic.git] / src / wx / audio_dialog.cc
index f2377de43fefc07c3a273e95b348494a1e8e2839..b8c7f7b7343b23af4b08f62361d68dd6747606cd 100644 (file)
 #include "lib/job_manager.h"
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <iostream>
 
 using std::cout;
 using std::list;
 using std::vector;
 using std::pair;
-using boost::shared_ptr;
-using boost::weak_ptr;
+using std::shared_ptr;
+using std::weak_ptr;
 using boost::bind;
 using boost::optional;
 using boost::const_pointer_cast;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
 using namespace dcpomatic;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 
 /** @param parent Parent window.
  *  @param film Film we are using.
@@ -111,6 +113,8 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<Film
                _channel_checkbox[i]->Bind (wxEVT_CHECKBOX, boost::bind (&AudioDialog::channel_clicked, this, _1));
        }
 
+       show_or_hide_channel_checkboxes ();
+
        {
                wxStaticText* m = new StaticText (this, _("Type"));
                m->SetFont (subheading_font);
@@ -168,6 +172,20 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<Film
        _plot->Cursor.connect (bind (&AudioDialog::set_cursor, this, _1, _2));
 }
 
+
+void
+AudioDialog::show_or_hide_channel_checkboxes ()
+{
+       for (int i = 0; i < _channels; ++i) {
+               _channel_checkbox[i]->Show ();
+       }
+
+       for (int i = _channels; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
+               _channel_checkbox[i]->Hide ();
+       }
+}
+
+
 void
 AudioDialog::try_to_load_analysis ()
 {
@@ -185,7 +203,7 @@ AudioDialog::try_to_load_analysis ()
                _plot->set_analysis (shared_ptr<AudioAnalysis> ());
                _analysis.reset ();
 
-               BOOST_FOREACH (shared_ptr<Job> i, JobManager::instance()->get()) {
+               for (auto i: JobManager::instance()->get()) {
                        if (dynamic_pointer_cast<AnalyseAudioJob>(i)) {
                                i->cancel ();
                        }
@@ -216,14 +234,7 @@ AudioDialog::try_to_load_analysis ()
        _plot->set_analysis (_analysis);
        _plot->set_gain_correction (_analysis->gain_correction (_playlist));
        setup_statistics ();
-
-       for (int i = 0; i < _channels; ++i) {
-               _channel_checkbox[i]->Show ();
-       }
-
-       for (int i = _channels; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
-               _channel_checkbox[i]->Hide ();
-       }
+       show_or_hide_channel_checkboxes ();
 
        /* Set up some defaults if no check boxes are checked */
 
@@ -244,7 +255,7 @@ AudioDialog::try_to_load_analysis ()
                        mapped = film->mapped_audio_channels ();
                }
 
-               BOOST_FOREACH (int i, mapped) {
+               for (auto i: mapped) {
                        if (_channel_checkbox[i]) {
                                _channel_checkbox[i]->SetValue (true);
                                _plot->set_channel_visible (i, true);
@@ -303,12 +314,12 @@ AudioDialog::channel_clicked (wxCommandEvent& ev)
 void
 AudioDialog::film_change (ChangeType type, int p)
 {
-       if (type != CHANGE_TYPE_DONE) {
+       if (type != ChangeType::DONE) {
                return;
        }
 
        if (p == Film::AUDIO_CHANNELS) {
-               shared_ptr<Film> film = _film.lock ();
+               auto film = _film.lock ();
                if (film) {
                        _channels = film->audio_channels ();
                        try_to_load_analysis ();
@@ -319,7 +330,7 @@ AudioDialog::film_change (ChangeType type, int p)
 void
 AudioDialog::content_change (ChangeType type, int p)
 {
-       if (type != CHANGE_TYPE_DONE) {
+       if (type != ChangeType::DONE) {
                return;
        }
 
@@ -364,12 +375,12 @@ AudioDialog::setup_statistics ()
                return;
        }
 
-       shared_ptr<Film> film = _film.lock ();
+       auto film = _film.lock ();
        if (!film) {
                return;
        }
 
-       pair<AudioAnalysis::PeakTime, int> const peak = _analysis->overall_sample_peak ();
+       auto const peak = _analysis->overall_sample_peak ();
        float const peak_dB = linear_to_db(peak.first.peak) + _analysis->gain_correction(_playlist);
        _sample_peak->SetLabel (
                wxString::Format (
@@ -401,7 +412,7 @@ AudioDialog::setup_statistics ()
 
        /* XXX: check whether it's ok to add dB gain to these quantities */
 
-       if (static_cast<bool>(_analysis->integrated_loudness ())) {
+       if (static_cast<bool>(_analysis->integrated_loudness())) {
                _integrated_loudness->SetLabel (
                        wxString::Format (
                                _("Integrated loudness %.2f LUFS"),
@@ -410,7 +421,7 @@ AudioDialog::setup_statistics ()
                        );
        }
 
-       if (static_cast<bool>(_analysis->loudness_range ())) {
+       if (static_cast<bool>(_analysis->loudness_range())) {
                _loudness_range->SetLabel (
                        wxString::Format (
                                _("Loudness range %.2f LU"),
@@ -444,7 +455,7 @@ AudioDialog::set_cursor (optional<DCPTime> time, optional<float> db)
                return;
        }
 
-       shared_ptr<Film> film = _film.lock();
+       auto film = _film.lock();
        DCPOMATIC_ASSERT (film);
        _cursor->SetLabel (wxString::Format (_("Cursor: %.1fdB at %s"), *db, time->timecode(film->video_frame_rate())));
 }