2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/film_editor.cc
21 * @brief A wx widget to edit a film's metadata, and perform various functions.
27 #include <boost/thread.hpp>
28 #include <boost/filesystem.hpp>
29 #include <boost/lexical_cast.hpp>
30 #include "lib/format.h"
32 #include "lib/transcode_job.h"
33 #include "lib/exceptions.h"
34 #include "lib/ab_transcode_job.h"
35 #include "lib/job_manager.h"
36 #include "lib/filter.h"
37 #include "lib/screen.h"
38 #include "lib/config.h"
39 #include "filter_dialog.h"
41 #include "film_editor.h"
42 #include "gain_calculator_dialog.h"
43 #include "sound_processor.h"
44 #include "dci_name_dialog.h"
48 using std::stringstream;
51 using std::setprecision;
54 using boost::shared_ptr;
56 /** @param f Film to edit */
57 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
61 _sizer = new wxFlexGridSizer (2, 4, 4);
64 add_label_to_sizer (_sizer, this, "Name");
65 _name = new wxTextCtrl (this, wxID_ANY);
66 _sizer->Add (_name, 1, wxEXPAND);
68 add_label_to_sizer (_sizer, this, "DCP Name");
69 _dcp_name = new wxStaticText (this, wxID_ANY, wxT (""));
70 _sizer->Add (_dcp_name, 0, wxALIGN_CENTER_VERTICAL | wxSHRINK);
72 _use_dci_name = new wxCheckBox (this, wxID_ANY, wxT ("Use DCI name"));
73 _sizer->Add (_use_dci_name, 1, wxEXPAND);
74 _edit_dci_button = new wxButton (this, wxID_ANY, wxT ("Details..."));
75 _sizer->Add (_edit_dci_button, 0);
77 add_label_to_sizer (_sizer, this, "Content");
78 _content = new wxFilePickerCtrl (this, wxID_ANY, wxT (""), wxT ("Select Content File"), wxT("*.*"));
79 _sizer->Add (_content, 1, wxEXPAND);
81 add_label_to_sizer (_sizer, this, "Content Type");
82 _dcp_content_type = new wxComboBox (this, wxID_ANY);
83 _sizer->Add (_dcp_content_type);
85 add_label_to_sizer (_sizer, this, "Format");
86 _format = new wxComboBox (this, wxID_ANY);
87 _sizer->Add (_format);
90 add_label_to_sizer (_sizer, this, "Crop");
91 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
93 add_label_to_sizer (s, this, "L");
94 _left_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
95 s->Add (_left_crop, 0);
96 add_label_to_sizer (s, this, "R");
97 _right_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
98 s->Add (_right_crop, 0);
99 add_label_to_sizer (s, this, "T");
100 _top_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
101 s->Add (_top_crop, 0);
102 add_label_to_sizer (s, this, "B");
103 _bottom_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
104 s->Add (_bottom_crop, 0);
109 /* VIDEO-only stuff */
111 video_control (add_label_to_sizer (_sizer, this, "Filters"));
112 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
113 _filters = new wxStaticText (this, wxID_ANY, wxT ("None"));
114 video_control (_filters);
115 s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
116 _filters_button = new wxButton (this, wxID_ANY, wxT ("Edit..."));
117 video_control (_filters_button);
118 s->Add (_filters_button, 0);
122 video_control (add_label_to_sizer (_sizer, this, "Scaler"));
123 _scaler = new wxComboBox (this, wxID_ANY);
124 _sizer->Add (video_control (_scaler), 1);
127 video_control (add_label_to_sizer (_sizer, this, "Audio Stream"));
128 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
129 _audio_stream = new wxComboBox (this, wxID_ANY);
130 s->Add (video_control (_audio_stream), 1);
131 _audio = new wxStaticText (this, wxID_ANY, wxT (""));
132 s->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
133 _sizer->Add (s, 1, wxEXPAND);
137 video_control (add_label_to_sizer (_sizer, this, "Audio Gain"));
138 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
139 _audio_gain = new wxSpinCtrl (this);
140 s->Add (video_control (_audio_gain), 1);
141 video_control (add_label_to_sizer (s, this, "dB"));
142 _audio_gain_calculate_button = new wxButton (this, wxID_ANY, _("Calculate..."));
143 video_control (_audio_gain_calculate_button);
144 s->Add (_audio_gain_calculate_button, 1, wxEXPAND);
149 video_control (add_label_to_sizer (_sizer, this, "Audio Delay"));
150 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
151 _audio_delay = new wxSpinCtrl (this);
152 s->Add (video_control (_audio_delay), 1);
153 video_control (add_label_to_sizer (s, this, "ms"));
157 _with_subtitles = new wxCheckBox (this, wxID_ANY, wxT("With Subtitles"));
158 video_control (_with_subtitles);
159 _sizer->Add (_with_subtitles, 1);
161 _subtitle_stream = new wxComboBox (this, wxID_ANY);
162 _sizer->Add (_subtitle_stream);
164 video_control (add_label_to_sizer (_sizer, this, "Subtitle Offset"));
165 _subtitle_offset = new wxSpinCtrl (this);
166 _sizer->Add (video_control (_subtitle_offset), 1);
169 video_control (add_label_to_sizer (_sizer, this, "Subtitle Scale"));
170 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
171 _subtitle_scale = new wxSpinCtrl (this);
172 s->Add (video_control (_subtitle_scale));
173 video_control (add_label_to_sizer (s, this, "%"));
177 video_control (add_label_to_sizer (_sizer, this, "Frames Per Second"));
178 _frames_per_second = new wxStaticText (this, wxID_ANY, wxT (""));
179 _sizer->Add (video_control (_frames_per_second), 1, wxALIGN_CENTER_VERTICAL);
181 video_control (add_label_to_sizer (_sizer, this, "Original Size"));
182 _original_size = new wxStaticText (this, wxID_ANY, wxT (""));
183 _sizer->Add (video_control (_original_size), 1, wxALIGN_CENTER_VERTICAL);
185 video_control (add_label_to_sizer (_sizer, this, "Length"));
186 _length = new wxStaticText (this, wxID_ANY, wxT (""));
187 _sizer->Add (video_control (_length), 1, wxALIGN_CENTER_VERTICAL);
191 video_control (add_label_to_sizer (_sizer, this, "Trim frames"));
192 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
193 add_label_to_sizer (s, this, "Start");
194 _dcp_trim_start = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
195 s->Add (_dcp_trim_start);
196 add_label_to_sizer (s, this, "End");
197 _dcp_trim_end = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
198 s->Add (_dcp_trim_end);
203 _dcp_ab = new wxCheckBox (this, wxID_ANY, wxT ("A/B"));
204 video_control (_dcp_ab);
205 _sizer->Add (_dcp_ab, 1);
206 _sizer->AddSpacer (0);
208 /* STILL-only stuff */
210 still_control (add_label_to_sizer (_sizer, this, "Duration"));
211 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
212 _still_duration = new wxSpinCtrl (this);
213 still_control (_still_duration);
214 s->Add (_still_duration, 1, wxEXPAND);
215 still_control (add_label_to_sizer (s, this, "s"));
219 /* Set up our editing widgets */
221 _left_crop->SetRange (0, 1024);
222 _top_crop->SetRange (0, 1024);
223 _right_crop->SetRange (0, 1024);
224 _bottom_crop->SetRange (0, 1024);
225 _audio_gain->SetRange (-60, 60);
226 _audio_delay->SetRange (-1000, 1000);
227 _still_duration->SetRange (0, 60 * 60);
228 _subtitle_offset->SetRange (-1024, 1024);
229 _subtitle_scale->SetRange (1, 1000);
230 _dcp_trim_start->SetRange (0, 100);
231 _dcp_trim_end->SetRange (0, 100);
233 vector<DCPContentType const *> const ct = DCPContentType::all ();
234 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
235 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
238 vector<Scaler const *> const sc = Scaler::all ();
239 for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
240 _scaler->Append (std_to_wx ((*i)->name()));
243 JobManager::instance()->ActiveJobsChanged.connect (
244 bind (&FilmEditor::active_jobs_changed, this, _1)
247 /* And set their values from the Film */
250 /* Now connect to them, since initial values are safely set */
251 _name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
252 _use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
253 _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
254 _format->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
255 _content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this);
256 _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
257 _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
258 _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
259 _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
260 _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
261 _scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
262 _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
263 _dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this);
264 _audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
265 _audio_gain_calculate_button->Connect (
266 wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
268 _audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
269 _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
270 _dcp_trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::dcp_trim_start_changed), 0, this);
271 _dcp_trim_end->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::dcp_trim_end_changed), 0, this);
272 _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
273 _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
274 _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
275 _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
276 _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
282 /** Called when the left crop widget has been changed */
284 FilmEditor::left_crop_changed (wxCommandEvent &)
290 _film->set_left_crop (_left_crop->GetValue ());
293 /** Called when the right crop widget has been changed */
295 FilmEditor::right_crop_changed (wxCommandEvent &)
301 _film->set_right_crop (_right_crop->GetValue ());
304 /** Called when the top crop widget has been changed */
306 FilmEditor::top_crop_changed (wxCommandEvent &)
312 _film->set_top_crop (_top_crop->GetValue ());
315 /** Called when the bottom crop value has been changed */
317 FilmEditor::bottom_crop_changed (wxCommandEvent &)
323 _film->set_bottom_crop (_bottom_crop->GetValue ());
326 /** Called when the content filename has been changed */
328 FilmEditor::content_changed (wxCommandEvent &)
335 _film->set_content (wx_to_std (_content->GetPath ()));
336 } catch (std::exception& e) {
337 _content->SetPath (std_to_wx (_film->directory ()));
338 error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
342 /** Called when the DCP A/B switch has been toggled */
344 FilmEditor::dcp_ab_toggled (wxCommandEvent &)
350 _film->set_dcp_ab (_dcp_ab->GetValue ());
353 /** Called when the name widget has been changed */
355 FilmEditor::name_changed (wxCommandEvent &)
361 _film->set_name (string (_name->GetValue().mb_str()));
365 FilmEditor::subtitle_offset_changed (wxCommandEvent &)
371 _film->set_subtitle_offset (_subtitle_offset->GetValue ());
375 FilmEditor::subtitle_scale_changed (wxCommandEvent &)
381 _film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
385 /** Called when the metadata stored in the Film object has changed;
386 * so that we can update the GUI.
387 * @param p Property of the Film that has changed.
390 FilmEditor::film_changed (Film::Property p)
404 checked_set (_content, _film->content ());
407 setup_subtitle_control_sensitivity ();
410 case Film::HAS_SUBTITLES:
411 setup_subtitle_control_sensitivity ();
414 case Film::AUDIO_STREAMS:
415 case Film::SUBTITLE_STREAMS:
421 vector<Format const *>::iterator i = _formats.begin ();
422 while (i != _formats.end() && *i != _film->format ()) {
426 checked_set (_format, n);
427 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
431 checked_set (_left_crop, _film->crop().left);
432 checked_set (_right_crop, _film->crop().right);
433 checked_set (_top_crop, _film->crop().top);
434 checked_set (_bottom_crop, _film->crop().bottom);
438 pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
439 if (p.first.empty () && p.second.empty ()) {
440 _filters->SetLabel (_("None"));
442 string const b = p.first + " " + p.second;
443 _filters->SetLabel (std_to_wx (b));
449 checked_set (_name, _film->name());
450 _film->set_dci_date_today ();
451 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
453 case Film::FRAMES_PER_SECOND:
454 s << fixed << setprecision(2) << _film->frames_per_second();
455 _frames_per_second->SetLabel (std_to_wx (s.str ()));
457 case Film::AUDIO_SAMPLE_RATE:
458 setup_audio_details ();
461 if (_film->size().width == 0 && _film->size().height == 0) {
462 _original_size->SetLabel (wxT (""));
464 s << _film->size().width << " x " << _film->size().height;
465 _original_size->SetLabel (std_to_wx (s.str ()));
469 if (_film->frames_per_second() > 0 && _film->length()) {
470 s << _film->length().get() << " frames; " << seconds_to_hms (_film->length().get() / _film->frames_per_second());
471 } else if (_film->length()) {
472 s << _film->length().get() << " frames";
474 _length->SetLabel (std_to_wx (s.str ()));
475 if (_film->length()) {
476 _dcp_trim_start->SetRange (0, _film->length().get());
477 _dcp_trim_end->SetRange (0, _film->length().get());
480 case Film::DCP_CONTENT_TYPE:
481 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
482 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
487 checked_set (_dcp_ab, _film->dcp_ab ());
490 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
492 case Film::DCP_TRIM_START:
493 checked_set (_dcp_trim_start, _film->dcp_trim_start());
495 case Film::DCP_TRIM_END:
496 checked_set (_dcp_trim_end, _film->dcp_trim_end());
498 case Film::AUDIO_GAIN:
499 checked_set (_audio_gain, _film->audio_gain ());
501 case Film::AUDIO_DELAY:
502 checked_set (_audio_delay, _film->audio_delay ());
504 case Film::STILL_DURATION:
505 checked_set (_still_duration, _film->still_duration ());
507 case Film::WITH_SUBTITLES:
508 checked_set (_with_subtitles, _film->with_subtitles ());
509 _subtitle_scale->Enable (_film->with_subtitles ());
510 _subtitle_offset->Enable (_film->with_subtitles ());
511 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
513 case Film::SUBTITLE_OFFSET:
514 checked_set (_subtitle_offset, _film->subtitle_offset ());
516 case Film::SUBTITLE_SCALE:
517 checked_set (_subtitle_scale, _film->subtitle_scale() * 100);
519 case Film::USE_DCI_NAME:
520 checked_set (_use_dci_name, _film->use_dci_name ());
521 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
523 case Film::DCI_METADATA:
524 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
526 case Film::AUDIO_STREAM:
527 checked_set (_audio_stream, _film->audio_stream_index ());
528 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
529 setup_audio_details ();
531 case Film::SUBTITLE_STREAM:
532 checked_set (_subtitle_stream, _film->subtitle_stream_index ());
537 /** Called when the format widget has been changed */
539 FilmEditor::format_changed (wxCommandEvent &)
545 int const n = _format->GetSelection ();
547 assert (n < int (_formats.size()));
548 _film->set_format (_formats[n]);
552 /** Called when the DCP content type widget has been changed */
554 FilmEditor::dcp_content_type_changed (wxCommandEvent &)
560 int const n = _dcp_content_type->GetSelection ();
562 _film->set_dcp_content_type (DCPContentType::from_index (n));
566 /** Sets the Film that we are editing */
568 FilmEditor::set_film (shared_ptr<Film> f)
572 set_things_sensitive (_film != 0);
575 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
579 FileChanged (_film->directory ());
584 film_changed (Film::NAME);
585 film_changed (Film::CONTENT);
586 film_changed (Film::DCP_CONTENT_TYPE);
587 film_changed (Film::FORMAT);
588 film_changed (Film::CROP);
589 film_changed (Film::FILTERS);
590 film_changed (Film::DCP_TRIM_START);
591 film_changed (Film::DCP_TRIM_END);
592 film_changed (Film::DCP_AB);
593 film_changed (Film::SIZE);
594 film_changed (Film::LENGTH);
595 film_changed (Film::FRAMES_PER_SECOND);
596 film_changed (Film::AUDIO_SAMPLE_RATE);
597 film_changed (Film::SCALER);
598 film_changed (Film::AUDIO_GAIN);
599 film_changed (Film::AUDIO_DELAY);
600 film_changed (Film::STILL_DURATION);
601 film_changed (Film::WITH_SUBTITLES);
602 film_changed (Film::HAS_SUBTITLES);
603 film_changed (Film::SUBTITLE_OFFSET);
604 film_changed (Film::SUBTITLE_SCALE);
605 film_changed (Film::USE_DCI_NAME);
606 film_changed (Film::DCI_METADATA);
609 /** Updates the sensitivity of lots of widgets to a given value.
610 * @param s true to make sensitive, false to make insensitive.
613 FilmEditor::set_things_sensitive (bool s)
616 _use_dci_name->Enable (s);
617 _edit_dci_button->Enable (s);
619 _content->Enable (s);
620 _left_crop->Enable (s);
621 _right_crop->Enable (s);
622 _top_crop->Enable (s);
623 _bottom_crop->Enable (s);
624 _filters_button->Enable (s);
626 _audio_stream->Enable (s);
627 _dcp_content_type->Enable (s);
628 _dcp_trim_start->Enable (s);
629 _dcp_trim_end->Enable (s);
631 _audio_gain->Enable (s);
632 _audio_gain_calculate_button->Enable (s);
633 _audio_delay->Enable (s);
634 _still_duration->Enable (s);
636 setup_subtitle_control_sensitivity ();
639 /** Called when the `Edit filters' button has been clicked */
641 FilmEditor::edit_filters_clicked (wxCommandEvent &)
643 FilterDialog* d = new FilterDialog (this, _film->filters());
644 d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
649 /** Called when the scaler widget has been changed */
651 FilmEditor::scaler_changed (wxCommandEvent &)
657 int const n = _scaler->GetSelection ();
659 _film->set_scaler (Scaler::from_index (n));
664 FilmEditor::audio_gain_changed (wxCommandEvent &)
670 _film->set_audio_gain (_audio_gain->GetValue ());
674 FilmEditor::audio_delay_changed (wxCommandEvent &)
680 _film->set_audio_delay (_audio_delay->GetValue ());
684 FilmEditor::video_control (wxControl* c)
686 _video_controls.push_back (c);
691 FilmEditor::still_control (wxControl* c)
693 _still_controls.push_back (c);
698 FilmEditor::setup_visibility ()
700 ContentType c = VIDEO;
703 c = _film->content_type ();
706 for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
707 (*i)->Show (c == VIDEO);
710 for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
711 (*i)->Show (c == STILL);
718 FilmEditor::still_duration_changed (wxCommandEvent &)
724 _film->set_still_duration (_still_duration->GetValue ());
728 FilmEditor::dcp_trim_start_changed (wxCommandEvent &)
734 _film->set_dcp_trim_start (_dcp_trim_start->GetValue ());
738 FilmEditor::dcp_trim_end_changed (wxCommandEvent &)
744 _film->set_dcp_trim_end (_dcp_trim_end->GetValue ());
748 FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
750 GainCalculatorDialog* d = new GainCalculatorDialog (this);
753 if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
758 _audio_gain->SetValue (
759 Config::instance()->sound_processor()->db_for_fader_change (
765 /* This appears to be necessary, as the change is not signalled,
768 wxCommandEvent dummy;
769 audio_gain_changed (dummy);
775 FilmEditor::setup_formats ()
777 ContentType c = VIDEO;
780 c = _film->content_type ();
785 vector<Format const *> fmt = Format::all ();
786 for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
787 if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) {
788 _formats.push_back (*i);
789 } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) {
790 _formats.push_back (*i);
795 for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
796 _format->Append (std_to_wx ((*i)->name ()));
803 FilmEditor::with_subtitles_toggled (wxCommandEvent &)
809 _film->set_with_subtitles (_with_subtitles->GetValue ());
813 FilmEditor::setup_subtitle_control_sensitivity ()
815 bool const h = _film ? _film->has_subtitles() : false;
816 _with_subtitles->Enable (h);
817 _subtitle_stream->Enable (h);
818 _subtitle_offset->Enable (h);
819 _subtitle_scale->Enable (h);
823 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
829 _film->set_use_dci_name (_use_dci_name->GetValue ());
833 FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
839 DCINameDialog* d = new DCINameDialog (this, _film);
845 FilmEditor::setup_streams ()
847 _audio_stream->Clear ();
848 vector<AudioStream> a = _film->audio_streams ();
849 for (vector<AudioStream>::iterator i = a.begin(); i != a.end(); ++i) {
850 _audio_stream->Append (std_to_wx (i->name()));
852 _audio_stream->SetSelection (_film->audio_stream_index ());
854 _subtitle_stream->Clear ();
855 vector<SubtitleStream> s = _film->subtitle_streams ();
856 for (vector<SubtitleStream>::iterator i = s.begin(); i != s.end(); ++i) {
857 _subtitle_stream->Append (std_to_wx (i->name()));
859 _subtitle_stream->SetSelection (_film->subtitle_stream_index ());
863 FilmEditor::audio_stream_changed (wxCommandEvent &)
869 _film->set_audio_stream (_audio_stream->GetSelection ());
873 FilmEditor::subtitle_stream_changed (wxCommandEvent &)
879 _film->set_subtitle_stream (_subtitle_stream->GetSelection ());
883 FilmEditor::setup_audio_details ()
885 if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) {
886 _audio->SetLabel (wxT (""));
889 s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz";
890 _audio->SetLabel (std_to_wx (s.str ()));
895 FilmEditor::active_jobs_changed (bool a)
897 set_things_sensitive (!a);