X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Faudio_panel.cc;h=d7deeec41987053ce654dac7ac61797330140e4c;hb=dc3c76a718338212521a56614da49358f5eeabc8;hp=5e8370d46bfcb5b258f0219517faccbcef498cdb;hpb=ddc48862d1008fa18f5dffd14ba2218a1b6803e3;p=dcpomatic.git diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index 5e8370d46..d7deeec41 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -34,6 +34,7 @@ #include "lib/dcp_content.h" #include "lib/ffmpeg_audio_stream.h" #include "lib/ffmpeg_content.h" +#include "lib/film.h" #include "lib/job_manager.h" #include "lib/maths_util.h" #include @@ -70,14 +71,6 @@ AudioPanel::AudioPanel (ContentPanel* p) void AudioPanel::create () { - _reference = new CheckBox (this, _("Use this DCP's audio as OV and make VF")); - _reference_note = new StaticText (this, wxT("")); - _reference_note->Wrap (200); - auto font = _reference_note->GetFont(); - font.SetStyle(wxFONTSTYLE_ITALIC); - font.SetPointSize(font.GetPointSize() - 1); - _reference_note->SetFont(font); - _show = new Button (this, _("Show graph of audio levels...")); _peak = new StaticText (this, wxT ("")); @@ -113,13 +106,16 @@ AudioPanel::create () _fade_out_label = create_label (this, _("Fade out"), true); _fade_out = new Timecode (this); - _use_same_fades_as_video = new wxCheckBox (this, wxID_ANY, _("Use same fades as video")); + _use_same_fades_as_video = new CheckBox(this, _("Use same fades as video")); _mapping = new AudioMappingView (this, _("Content"), _("content"), _("DCP"), _("DCP")); _sizer->Add (_mapping, 1, wxEXPAND | wxALL, 6); _description = new StaticText (this, wxT(" \n"), wxDefaultPosition, wxDefaultSize); _sizer->Add (_description, 0, wxALL, 12); + auto font = _description->GetFont(); + font.SetStyle(wxFONTSTYLE_ITALIC); + font.SetPointSize(font.GetPointSize() - 1); _description->SetFont (font); _gain->wrapped()->SetRange (-60, 60); @@ -128,24 +124,23 @@ AudioPanel::create () _delay->wrapped()->SetRange (-1000, 1000); content_selection_changed (); - film_changed (Film::Property::AUDIO_CHANNELS); - film_changed (Film::Property::VIDEO_FRAME_RATE); - film_changed (Film::Property::REEL_TYPE); + film_changed(FilmProperty::AUDIO_CHANNELS); + film_changed(FilmProperty::VIDEO_FRAME_RATE); + film_changed(FilmProperty::REEL_TYPE); - _reference->Bind (wxEVT_CHECKBOX, boost::bind (&AudioPanel::reference_clicked, this)); _show->Bind (wxEVT_BUTTON, boost::bind (&AudioPanel::show_clicked, this)); _gain_calculate_button->Bind (wxEVT_BUTTON, boost::bind (&AudioPanel::gain_calculate_button_clicked, this)); _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)); + _use_same_fades_as_video->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)); add_to_grid (); - _sizer->Layout (); + layout(); } @@ -154,12 +149,6 @@ AudioPanel::add_to_grid () { int r = 0; - auto reference_sizer = new wxBoxSizer (wxVERTICAL); - reference_sizer->Add (_reference, 0); - reference_sizer->Add (_reference_note, 0); - _grid->Add (reference_sizer, wxGBPosition(r, 0), wxGBSpan(1, 4)); - ++r; - _grid->Add (_show, wxGBPosition (r, 0), wxGBSpan (1, 2)); _grid->Add (_peak, wxGBPosition (r, 2), wxGBSpan (1, 2), wxALIGN_CENTER_VERTICAL); ++r; @@ -195,32 +184,24 @@ AudioPanel::add_to_grid () } -AudioPanel::~AudioPanel () -{ - if (_audio_dialog) { - _audio_dialog->Destroy (); - _audio_dialog = nullptr; - } -} - void -AudioPanel::film_changed (Film::Property property) +AudioPanel::film_changed (FilmProperty property) { if (!_parent->film()) { return; } switch (property) { - case Film::Property::AUDIO_CHANNELS: - case Film::Property::AUDIO_PROCESSOR: + case FilmProperty::AUDIO_CHANNELS: + case FilmProperty::AUDIO_PROCESSOR: _mapping->set_output_channels (_parent->film()->audio_output_names ()); setup_peak (); break; - case Film::Property::VIDEO_FRAME_RATE: + case FilmProperty::VIDEO_FRAME_RATE: setup_description (); break; - case Film::Property::REEL_TYPE: - case Film::Property::INTEROP: + case FilmProperty::REEL_TYPE: + case FilmProperty::INTEROP: setup_sensitivity (); break; default: @@ -264,15 +245,6 @@ AudioPanel::film_content_changed (int property) /* This is a bit aggressive but probably not so bad */ _peak_cache.clear(); setup_peak (); - } else if (property == DCPContentProperty::REFERENCE_AUDIO) { - if (ac.size() == 1) { - shared_ptr dcp = dynamic_pointer_cast (ac.front ()); - checked_set (_reference, dcp ? dcp->reference_audio () : false); - } else { - checked_set (_reference, false); - } - - setup_sensitivity (); } else if (property == ContentProperty::VIDEO_FRAME_RATE) { setup_description (); } else if (property == AudioContentProperty::FADE_IN) { @@ -312,18 +284,17 @@ AudioPanel::film_content_changed (int property) void AudioPanel::gain_calculate_button_clicked () { - auto d = new GainCalculatorDialog (this); - auto const r = d->ShowModal (); - auto c = d->db_change(); + GainCalculatorDialog dialog(this); + auto const r = dialog.ShowModal(); + auto change = dialog.db_change(); - if (r == wxID_CANCEL || !c) { - d->Destroy (); + if (r == wxID_CANCEL || !change) { return; } auto old_peak_dB = peak (); auto old_value = _gain->wrapped()->GetValue(); - _gain->wrapped()->SetValue(old_value + *c); + _gain->wrapped()->SetValue(old_value + *change); /* This appears to be necessary, as the change is not signalled, I think. @@ -336,8 +307,6 @@ AudioPanel::gain_calculate_button_clicked () _gain->wrapped()->SetValue (old_value); _gain->view_changed (); } - - d->Destroy (); } @@ -393,19 +362,8 @@ AudioPanel::setup_sensitivity () dcp = dynamic_pointer_cast (sel.front ()); } - string why_not; - bool const can_reference = dcp && dcp->can_reference_audio (_parent->film(), why_not); - wxString cannot; - if (why_not.empty()) { - cannot = _("Cannot reference this DCP's audio."); - } else { - cannot = _("Cannot reference this DCP's audio: ") + std_to_wx(why_not); - } - setup_refer_button (_reference, _reference_note, dcp, can_reference, cannot); - - auto const ref = _reference->GetValue(); + auto const ref = dcp && dcp->reference_audio(); auto const single = sel.size() == 1; - auto const all_have_video = std::all_of(sel.begin(), sel.end(), [](shared_ptr c) { return static_cast(c->video); }); _gain->wrapped()->Enable (!ref); @@ -424,17 +382,14 @@ AudioPanel::setup_sensitivity () void AudioPanel::show_clicked () { - if (_audio_dialog) { - _audio_dialog->Destroy (); - _audio_dialog = nullptr; - } + _audio_dialog.reset(); auto ac = _parent->selected_audio (); if (ac.size() != 1) { return; } - _audio_dialog = new AudioDialog (this, _parent->film(), _parent->film_viewer(), ac.front()); + _audio_dialog.reset(this, _parent->film(), _parent->film_viewer(), ac.front()); _audio_dialog->Show (); } @@ -512,31 +467,11 @@ AudioPanel::active_jobs_changed (optional old_active, optional n } -void -AudioPanel::reference_clicked () -{ - auto c = _parent->selected (); - if (c.size() != 1) { - return; - } - - auto d = dynamic_pointer_cast(c.front()); - if (!d) { - return; - } - - d->set_reference_audio (_reference->GetValue ()); -} - - void AudioPanel::set_film (shared_ptr) { /* We are changing film, so destroy any audio dialog for the old one */ - if (_audio_dialog) { - _audio_dialog->Destroy (); - _audio_dialog = nullptr; - } + _audio_dialog.reset(); }