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/config.h"
38 #include "filter_dialog.h"
40 #include "film_editor.h"
41 #include "gain_calculator_dialog.h"
42 #include "sound_processor.h"
43 #include "dci_name_dialog.h"
47 using std::stringstream;
50 using std::setprecision;
53 using boost::shared_ptr;
55 /** @param f Film to edit */
56 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
59 , _generally_sensitive (true)
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_stream->Enable (_film->with_subtitles ());
510 _subtitle_scale->Enable (_film->with_subtitles ());
511 _subtitle_offset->Enable (_film->with_subtitles ());
512 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
514 case Film::SUBTITLE_OFFSET:
515 checked_set (_subtitle_offset, _film->subtitle_offset ());
517 case Film::SUBTITLE_SCALE:
518 checked_set (_subtitle_scale, _film->subtitle_scale() * 100);
520 case Film::USE_DCI_NAME:
521 checked_set (_use_dci_name, _film->use_dci_name ());
522 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
524 case Film::DCI_METADATA:
525 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
527 case Film::AUDIO_STREAM:
528 checked_set (_audio_stream, _film->audio_stream_index ());
529 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
530 setup_audio_details ();
532 case Film::SUBTITLE_STREAM:
533 checked_set (_subtitle_stream, _film->subtitle_stream_index ());
538 /** Called when the format widget has been changed */
540 FilmEditor::format_changed (wxCommandEvent &)
546 int const n = _format->GetSelection ();
548 assert (n < int (_formats.size()));
549 _film->set_format (_formats[n]);
553 /** Called when the DCP content type widget has been changed */
555 FilmEditor::dcp_content_type_changed (wxCommandEvent &)
561 int const n = _dcp_content_type->GetSelection ();
563 _film->set_dcp_content_type (DCPContentType::from_index (n));
567 /** Sets the Film that we are editing */
569 FilmEditor::set_film (shared_ptr<Film> f)
573 set_things_sensitive (_film != 0);
576 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
580 FileChanged (_film->directory ());
585 film_changed (Film::NAME);
586 film_changed (Film::CONTENT);
587 film_changed (Film::DCP_CONTENT_TYPE);
588 film_changed (Film::FORMAT);
589 film_changed (Film::CROP);
590 film_changed (Film::FILTERS);
591 film_changed (Film::DCP_TRIM_START);
592 film_changed (Film::DCP_TRIM_END);
593 film_changed (Film::DCP_AB);
594 film_changed (Film::SIZE);
595 film_changed (Film::LENGTH);
596 film_changed (Film::FRAMES_PER_SECOND);
597 film_changed (Film::AUDIO_SAMPLE_RATE);
598 film_changed (Film::SCALER);
599 film_changed (Film::AUDIO_GAIN);
600 film_changed (Film::AUDIO_DELAY);
601 film_changed (Film::STILL_DURATION);
602 film_changed (Film::WITH_SUBTITLES);
603 film_changed (Film::HAS_SUBTITLES);
604 film_changed (Film::SUBTITLE_OFFSET);
605 film_changed (Film::SUBTITLE_SCALE);
606 film_changed (Film::USE_DCI_NAME);
607 film_changed (Film::DCI_METADATA);
610 /** Updates the sensitivity of lots of widgets to a given value.
611 * @param s true to make sensitive, false to make insensitive.
614 FilmEditor::set_things_sensitive (bool s)
616 _generally_sensitive = s;
619 _use_dci_name->Enable (s);
620 _edit_dci_button->Enable (s);
622 _content->Enable (s);
623 _left_crop->Enable (s);
624 _right_crop->Enable (s);
625 _top_crop->Enable (s);
626 _bottom_crop->Enable (s);
627 _filters_button->Enable (s);
629 _audio_stream->Enable (s);
630 _dcp_content_type->Enable (s);
631 _dcp_trim_start->Enable (s);
632 _dcp_trim_end->Enable (s);
634 _audio_gain->Enable (s);
635 _audio_gain_calculate_button->Enable (s);
636 _audio_delay->Enable (s);
637 _still_duration->Enable (s);
639 setup_subtitle_control_sensitivity ();
642 /** Called when the `Edit filters' button has been clicked */
644 FilmEditor::edit_filters_clicked (wxCommandEvent &)
646 FilterDialog* d = new FilterDialog (this, _film->filters());
647 d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
652 /** Called when the scaler widget has been changed */
654 FilmEditor::scaler_changed (wxCommandEvent &)
660 int const n = _scaler->GetSelection ();
662 _film->set_scaler (Scaler::from_index (n));
667 FilmEditor::audio_gain_changed (wxCommandEvent &)
673 _film->set_audio_gain (_audio_gain->GetValue ());
677 FilmEditor::audio_delay_changed (wxCommandEvent &)
683 _film->set_audio_delay (_audio_delay->GetValue ());
687 FilmEditor::video_control (wxControl* c)
689 _video_controls.push_back (c);
694 FilmEditor::still_control (wxControl* c)
696 _still_controls.push_back (c);
701 FilmEditor::setup_visibility ()
703 ContentType c = VIDEO;
706 c = _film->content_type ();
709 for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
710 (*i)->Show (c == VIDEO);
713 for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
714 (*i)->Show (c == STILL);
721 FilmEditor::still_duration_changed (wxCommandEvent &)
727 _film->set_still_duration (_still_duration->GetValue ());
731 FilmEditor::dcp_trim_start_changed (wxCommandEvent &)
737 _film->set_dcp_trim_start (_dcp_trim_start->GetValue ());
741 FilmEditor::dcp_trim_end_changed (wxCommandEvent &)
747 _film->set_dcp_trim_end (_dcp_trim_end->GetValue ());
751 FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
753 GainCalculatorDialog* d = new GainCalculatorDialog (this);
756 if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
761 _audio_gain->SetValue (
762 Config::instance()->sound_processor()->db_for_fader_change (
768 /* This appears to be necessary, as the change is not signalled,
771 wxCommandEvent dummy;
772 audio_gain_changed (dummy);
778 FilmEditor::setup_formats ()
780 ContentType c = VIDEO;
783 c = _film->content_type ();
788 vector<Format const *> fmt = Format::all ();
789 for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
790 if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) {
791 _formats.push_back (*i);
792 } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) {
793 _formats.push_back (*i);
798 for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
799 _format->Append (std_to_wx ((*i)->name ()));
806 FilmEditor::with_subtitles_toggled (wxCommandEvent &)
812 _film->set_with_subtitles (_with_subtitles->GetValue ());
816 FilmEditor::setup_subtitle_control_sensitivity ()
819 if (_generally_sensitive && _film) {
820 h = _film->has_subtitles();
823 _with_subtitles->Enable (h);
824 _subtitle_stream->Enable (h);
825 _subtitle_offset->Enable (h);
826 _subtitle_scale->Enable (h);
830 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
836 _film->set_use_dci_name (_use_dci_name->GetValue ());
840 FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
846 DCINameDialog* d = new DCINameDialog (this, _film);
852 FilmEditor::setup_streams ()
854 _audio_stream->Clear ();
855 vector<AudioStream> a = _film->audio_streams ();
856 for (vector<AudioStream>::iterator i = a.begin(); i != a.end(); ++i) {
857 _audio_stream->Append (std_to_wx (i->name()));
859 _audio_stream->SetSelection (_film->audio_stream_index ());
861 _subtitle_stream->Clear ();
862 vector<SubtitleStream> s = _film->subtitle_streams ();
863 for (vector<SubtitleStream>::iterator i = s.begin(); i != s.end(); ++i) {
864 _subtitle_stream->Append (std_to_wx (i->name()));
866 _subtitle_stream->SetSelection (_film->subtitle_stream_index ());
870 FilmEditor::audio_stream_changed (wxCommandEvent &)
876 _film->set_audio_stream (_audio_stream->GetSelection ());
880 FilmEditor::subtitle_stream_changed (wxCommandEvent &)
886 _film->set_subtitle_stream (_subtitle_stream->GetSelection ());
890 FilmEditor::setup_audio_details ()
892 if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) {
893 _audio->SetLabel (wxT (""));
896 s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz";
897 _audio->SetLabel (std_to_wx (s.str ()));
902 FilmEditor::active_jobs_changed (bool a)
904 set_things_sensitive (!a);