Disable warnings around all wx includes.
[dcpomatic.git] / src / wx / audio_panel.cc
index 6ac673f4d246641326cf1b60a8c6ea2acb90d845..cfea4f0264a5b8a55ea200e1b94de5ea11f9db89 100644 (file)
 #include "lib/ffmpeg_content.h"
 #include "lib/job_manager.h"
 #include "lib/maths_util.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/spinctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <iostream>
 
 
@@ -58,7 +61,6 @@ using namespace dcpomatic;
 
 AudioPanel::AudioPanel (ContentPanel* p)
        : ContentSubPanel (p, _("Audio"))
-       , _audio_dialog (0)
 {
 
 }
@@ -110,6 +112,8 @@ AudioPanel::create ()
        _fade_out_label = create_label (this, _("Fade out"), true);
        _fade_out = new Timecode<ContentTime> (this);
 
+       _use_same_fades_as_video = new wxCheckBox (this, wxID_ANY, _("Use same fades as video"));
+
        _mapping = new AudioMappingView (this, _("Content"), _("content"), _("DCP"), _("DCP"));
        _sizer->Add (_mapping, 1, wxEXPAND | wxALL, 6);
 
@@ -133,6 +137,7 @@ AudioPanel::create ()
 
        _fade_in->Changed.connect (boost::bind(&AudioPanel::fade_in_changed, this));
        _fade_out->Changed.connect (boost::bind(&AudioPanel::fade_out_changed, this));
+       _use_same_fades_as_video->Bind (wxEVT_CHECKBOX, boost::bind(&AudioPanel::use_same_fades_as_video_changed, this));
 
        _mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
        _active_jobs_connection = JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&AudioPanel::active_jobs_changed, this, _1, _2));
@@ -183,6 +188,9 @@ AudioPanel::add_to_grid ()
        add_label_to_sizer (_grid, _fade_out_label, true, wxGBPosition(r, 0));
        _grid->Add (_fade_out, wxGBPosition(r, 1), wxGBSpan(1, 3));
        ++r;
+
+       _grid->Add (_use_same_fades_as_video, wxGBPosition(r, 0), wxGBSpan(1, 4));
+       ++r;
 }
 
 
@@ -219,6 +227,7 @@ AudioPanel::film_changed (Film::Property property)
        }
 }
 
+
 void
 AudioPanel::film_content_changed (int property)
 {
@@ -291,9 +300,12 @@ AudioPanel::film_content_changed (int property)
                } else {
                        _fade_out->clear ();
                }
+       } else if (property == AudioContentProperty::USE_SAME_FADES_AS_VIDEO) {
+               setup_sensitivity ();
        }
 }
 
+
 void
 AudioPanel::gain_calculate_button_clicked ()
 {
@@ -325,6 +337,7 @@ AudioPanel::gain_calculate_button_clicked ()
        d->Destroy ();
 }
 
+
 void
 AudioPanel::setup_description ()
 {
@@ -337,6 +350,7 @@ AudioPanel::setup_description ()
        checked_set (_description, ac.front()->audio->processing_description(_parent->film()));
 }
 
+
 void
 AudioPanel::mapping_changed (AudioMapping m)
 {
@@ -346,6 +360,7 @@ AudioPanel::mapping_changed (AudioMapping m)
        }
 }
 
+
 void
 AudioPanel::content_selection_changed ()
 {
@@ -358,11 +373,13 @@ AudioPanel::content_selection_changed ()
        film_content_changed (AudioContentProperty::GAIN);
        film_content_changed (AudioContentProperty::FADE_IN);
        film_content_changed (AudioContentProperty::FADE_OUT);
+       film_content_changed (AudioContentProperty::USE_SAME_FADES_AS_VIDEO);
        film_content_changed (DCPContentProperty::REFERENCE_AUDIO);
 
        setup_sensitivity ();
 }
 
+
 void
 AudioPanel::setup_sensitivity ()
 {
@@ -386,6 +403,8 @@ AudioPanel::setup_sensitivity ()
        auto const ref = _reference->GetValue();
        auto const single = sel.size() == 1;
 
+       auto const all_have_video = std::all_of(sel.begin(), sel.end(), [](shared_ptr<const Content> c) { return static_cast<bool>(c->video); });
+
        _gain->wrapped()->Enable (!ref);
        _gain_calculate_button->Enable (!ref && single);
        _show->Enable (single);
@@ -393,8 +412,12 @@ AudioPanel::setup_sensitivity ()
        _delay->wrapped()->Enable (!ref);
        _mapping->Enable (!ref && single);
        _description->Enable (!ref && single);
+       _fade_in->Enable (!_use_same_fades_as_video->GetValue());
+       _fade_out->Enable (!_use_same_fades_as_video->GetValue());
+       _use_same_fades_as_video->Enable (!ref && all_have_video);
 }
 
+
 void
 AudioPanel::show_clicked ()
 {
@@ -412,6 +435,7 @@ AudioPanel::show_clicked ()
        _audio_dialog->Show ();
 }
 
+
 /** @return If there is one selected piece of audio content, return its peak value in dB (if known) */
 optional<float>
 AudioPanel::peak () const
@@ -433,6 +457,7 @@ AudioPanel::peak () const
        return peak_dB;
 }
 
+
 void
 AudioPanel::setup_peak ()
 {
@@ -461,6 +486,7 @@ AudioPanel::setup_peak ()
        }
 }
 
+
 void
 AudioPanel::active_jobs_changed (optional<string> old_active, optional<string> new_active)
 {
@@ -472,6 +498,7 @@ AudioPanel::active_jobs_changed (optional<string> old_active, optional<string> n
        }
 }
 
+
 void
 AudioPanel::reference_clicked ()
 {
@@ -488,6 +515,7 @@ AudioPanel::reference_clicked ()
        d->set_reference_audio (_reference->GetValue ());
 }
 
+
 void
 AudioPanel::set_film (shared_ptr<Film>)
 {
@@ -520,3 +548,12 @@ AudioPanel::fade_out_changed ()
        }
 }
 
+
+void
+AudioPanel::use_same_fades_as_video_changed ()
+{
+       for (auto content: _parent->selected_audio()) {
+               content->audio->set_use_same_fades_as_video(_use_same_fades_as_video->GetValue());
+       }
+}
+