X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ffilm_editor.cc;h=34223ce0570999491b8cb967b1b3b835299df21a;hb=110d7d4e111c2db31489296587d855328c5d8b34;hp=471ca215f2fd377f030c88ea892c5f973caca59b;hpb=24195ec288ffa4a2c7415b976453b796e6a39f2a;p=dcpomatic.git diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 471ca215f..34223ce05 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -32,7 +32,6 @@ #include "lib/transcode_job.h" #include "lib/exceptions.h" #include "lib/ab_transcode_job.h" -#include "lib/thumbs_job.h" #include "lib/job_manager.h" #include "lib/filter.h" #include "lib/screen.h" @@ -44,12 +43,19 @@ #include "gain_calculator_dialog.h" #include "sound_processor.h" #include "dci_name_dialog.h" +#include "scaler.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::pair; +using std::fixed; +using std::setprecision; +using std::list; +using std::vector; +using boost::shared_ptr; /** @param f Film to edit */ -FilmEditor::FilmEditor (Film* f, wxWindow* parent) +FilmEditor::FilmEditor (shared_ptr f, wxWindow* parent) : wxPanel (parent) , _ignore_changes (Film::NONE) , _film (f) @@ -119,6 +125,16 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _scaler = new wxComboBox (this, wxID_ANY); _sizer->Add (video_control (_scaler), 1); + { + video_control (add_label_to_sizer (_sizer, this, "Audio Stream")); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _audio_stream = new wxComboBox (this, wxID_ANY); + s->Add (video_control (_audio_stream), 1); + _audio = new wxStaticText (this, wxID_ANY, wxT ("")); + s->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8); + _sizer->Add (s, 1, wxEXPAND); + } + { video_control (add_label_to_sizer (_sizer, this, "Audio Gain")); wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); @@ -143,7 +159,9 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _with_subtitles = new wxCheckBox (this, wxID_ANY, wxT("With Subtitles")); video_control (_with_subtitles); _sizer->Add (_with_subtitles, 1); - _sizer->AddSpacer (0); + + _subtitle_stream = new wxComboBox (this, wxID_ANY); + _sizer->Add (_subtitle_stream); video_control (add_label_to_sizer (_sizer, this, "Subtitle Offset")); _subtitle_offset = new wxSpinCtrl (this); @@ -170,9 +188,6 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _length = new wxStaticText (this, wxID_ANY, wxT ("")); _sizer->Add (video_control (_length), 1, wxALIGN_CENTER_VERTICAL); - video_control (add_label_to_sizer (_sizer, this, "Audio")); - _audio = new wxStaticText (this, wxID_ANY, wxT ("")); - _sizer->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL); { video_control (add_label_to_sizer (_sizer, this, "Range")); @@ -222,6 +237,10 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _scaler->Append (std_to_wx ((*i)->name())); } + JobManager::instance()->ActiveJobsChanged.connect ( + bind (&FilmEditor::active_jobs_changed, this, _1) + ); + /* And set their values from the Film */ set_film (f); @@ -249,6 +268,8 @@ FilmEditor::FilmEditor (Film* f, wxWindow* parent) _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this); _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this); _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this); + _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this); + _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this); setup_visibility (); setup_formats (); @@ -328,6 +349,7 @@ FilmEditor::content_changed (wxCommandEvent &) setup_visibility (); setup_formats (); setup_subtitle_button (); + setup_streams (); } /** Called when the DCP A/B switch has been toggled */ @@ -390,6 +412,8 @@ FilmEditor::subtitle_scale_changed (wxCommandEvent &) void FilmEditor::film_changed (Film::Property p) { + ensure_ui_thread (); + if (!_film || _ignore_changes == p) { return; } @@ -404,6 +428,15 @@ FilmEditor::film_changed (Film::Property p) setup_visibility (); setup_formats (); setup_subtitle_button (); + setup_streams (); + break; + case Film::HAS_SUBTITLES: + setup_subtitle_button (); + setup_streams (); + break; + case Film::AUDIO_STREAMS: + case Film::SUBTITLE_STREAMS: + setup_streams (); break; case Film::FORMAT: { @@ -440,21 +473,11 @@ FilmEditor::film_changed (Film::Property p) _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); break; case Film::FRAMES_PER_SECOND: - { - stringstream s; s << fixed << setprecision(2) << _film->frames_per_second(); _frames_per_second->SetLabel (std_to_wx (s.str ())); break; - } - case Film::AUDIO_CHANNELS: - _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); case Film::AUDIO_SAMPLE_RATE: - if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) { - _audio->SetLabel (wxT ("")); - } else { - s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz"; - _audio->SetLabel (std_to_wx (s.str ())); - } + setup_audio_details (); break; case Film::SIZE: if (_film->size().width == 0 && _film->size().height == 0) { @@ -465,10 +488,10 @@ FilmEditor::film_changed (Film::Property p) } break; case Film::LENGTH: - if (_film->frames_per_second() > 0 && _film->length() > 0) { - s << _film->length() << " frames; " << seconds_to_hms (_film->length() / _film->frames_per_second()); - } else if (_film->length() > 0) { - s << _film->length() << " frames"; + if (_film->frames_per_second() > 0 && _film->length()) { + s << _film->length().get() << " frames; " << seconds_to_hms (_film->length().get() / _film->frames_per_second()); + } else if (_film->length()) { + s << _film->length().get() << " frames"; } _length->SetLabel (std_to_wx (s.str ())); break; @@ -524,6 +547,14 @@ FilmEditor::film_changed (Film::Property p) case Film::DCI_METADATA: _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); break; + case Film::AUDIO_STREAM: + _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); + _audio_stream->SetSelection (_film->audio_stream_index ()); + setup_audio_details (); + break; + case Film::SUBTITLE_STREAM: + _subtitle_stream->SetSelection (_film->subtitle_stream_index ()); + break; } } @@ -566,14 +597,14 @@ FilmEditor::dcp_content_type_changed (wxCommandEvent &) /** Sets the Film that we are editing */ void -FilmEditor::set_film (Film* f) +FilmEditor::set_film (shared_ptr f) { _film = f; set_things_sensitive (_film != 0); if (_film) { - _film->Changed.connect (sigc::mem_fun (*this, &FilmEditor::film_changed)); + _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1)); } if (_film) { @@ -594,7 +625,6 @@ FilmEditor::set_film (Film* f) film_changed (Film::SIZE); film_changed (Film::LENGTH); film_changed (Film::FRAMES_PER_SECOND); - film_changed (Film::AUDIO_CHANNELS); film_changed (Film::AUDIO_SAMPLE_RATE); film_changed (Film::SCALER); film_changed (Film::AUDIO_GAIN); @@ -642,8 +672,8 @@ FilmEditor::set_things_sensitive (bool s) void FilmEditor::edit_filters_clicked (wxCommandEvent &) { - FilterDialog* d = new FilterDialog (this, _film->filters ()); - d->ActiveChanged.connect (sigc::mem_fun (*_film, &Film::set_filters)); + FilterDialog* d = new FilterDialog (this, _film->filters()); + d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1)); d->ShowModal (); d->Destroy (); } @@ -738,7 +768,7 @@ void FilmEditor::change_dcp_range_clicked (wxCommandEvent &) { DCPRangeDialog* d = new DCPRangeDialog (this, _film); - d->Changed.connect (sigc::mem_fun (*this, &FilmEditor::dcp_range_changed)); + d->Changed.connect (bind (&FilmEditor::dcp_range_changed, this, _1, _2)); d->ShowModal (); } @@ -853,3 +883,66 @@ FilmEditor::edit_dci_button_clicked (wxCommandEvent &) d->ShowModal (); d->Destroy (); } + +void +FilmEditor::setup_streams () +{ + _audio_stream->Clear (); + vector a = _film->audio_streams (); + for (vector::iterator i = a.begin(); i != a.end(); ++i) { + _audio_stream->Append (std_to_wx (i->name())); + } + _audio_stream->SetSelection (_film->audio_stream_index ()); + + _subtitle_stream->Clear (); + vector s = _film->subtitle_streams (); + for (vector::iterator i = s.begin(); i != s.end(); ++i) { + _subtitle_stream->Append (std_to_wx (i->name())); + } + _subtitle_stream->SetSelection (_film->subtitle_stream_index ()); +} + +void +FilmEditor::audio_stream_changed (wxCommandEvent &) +{ + if (!_film) { + return; + } + + _ignore_changes = Film::AUDIO_STREAM; + _film->set_audio_stream (_audio_stream->GetSelection ()); + _ignore_changes = Film::NONE; + + _dcp_name->SetLabel (std_to_wx (_film->dcp_name ())); + setup_audio_details (); +} + +void +FilmEditor::subtitle_stream_changed (wxCommandEvent &) +{ + if (!_film) { + return; + } + + _ignore_changes = Film::SUBTITLE_STREAM; + _film->set_subtitle_stream (_subtitle_stream->GetSelection ()); + _ignore_changes = Film::NONE; +} + +void +FilmEditor::setup_audio_details () +{ + if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) { + _audio->SetLabel (wxT ("")); + } else { + stringstream s; + s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz"; + _audio->SetLabel (std_to_wx (s.str ())); + } +} + +void +FilmEditor::active_jobs_changed (bool a) +{ + set_things_sensitive (!a); +}