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)
60 , _generally_sensitive (true)
62 _sizer = new wxFlexGridSizer (2, 4, 4);
65 add_label_to_sizer (_sizer, this, "Name");
66 _name = new wxTextCtrl (this, wxID_ANY);
67 _sizer->Add (_name, 1, wxEXPAND);
69 add_label_to_sizer (_sizer, this, "DCP Name");
70 _dcp_name = new wxStaticText (this, wxID_ANY, wxT (""));
71 _sizer->Add (_dcp_name, 0, wxALIGN_CENTER_VERTICAL | wxSHRINK);
73 _use_dci_name = new wxCheckBox (this, wxID_ANY, wxT ("Use DCI name"));
74 _sizer->Add (_use_dci_name, 1, wxEXPAND);
75 _edit_dci_button = new wxButton (this, wxID_ANY, wxT ("Details..."));
76 _sizer->Add (_edit_dci_button, 0);
78 add_label_to_sizer (_sizer, this, "Content");
79 _content = new wxFilePickerCtrl (this, wxID_ANY, wxT (""), wxT ("Select Content File"), wxT("*.*"));
80 _sizer->Add (_content, 1, wxEXPAND);
82 add_label_to_sizer (_sizer, this, "Content Type");
83 _dcp_content_type = new wxComboBox (this, wxID_ANY);
84 _sizer->Add (_dcp_content_type);
86 add_label_to_sizer (_sizer, this, "Format");
87 _format = new wxComboBox (this, wxID_ANY);
88 _sizer->Add (_format);
91 add_label_to_sizer (_sizer, this, "Crop");
92 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
94 add_label_to_sizer (s, this, "L");
95 _left_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
96 s->Add (_left_crop, 0);
97 add_label_to_sizer (s, this, "R");
98 _right_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
99 s->Add (_right_crop, 0);
100 add_label_to_sizer (s, this, "T");
101 _top_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
102 s->Add (_top_crop, 0);
103 add_label_to_sizer (s, this, "B");
104 _bottom_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
105 s->Add (_bottom_crop, 0);
110 /* VIDEO-only stuff */
112 video_control (add_label_to_sizer (_sizer, this, "Filters"));
113 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
114 _filters = new wxStaticText (this, wxID_ANY, wxT ("None"));
115 video_control (_filters);
116 s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
117 _filters_button = new wxButton (this, wxID_ANY, wxT ("Edit..."));
118 video_control (_filters_button);
119 s->Add (_filters_button, 0);
123 video_control (add_label_to_sizer (_sizer, this, "Scaler"));
124 _scaler = new wxComboBox (this, wxID_ANY);
125 _sizer->Add (video_control (_scaler), 1);
128 video_control (add_label_to_sizer (_sizer, this, "Audio Stream"));
129 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
130 _audio_stream = new wxComboBox (this, wxID_ANY);
131 s->Add (video_control (_audio_stream), 1);
132 _audio = new wxStaticText (this, wxID_ANY, wxT (""));
133 s->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
134 _sizer->Add (s, 1, wxEXPAND);
138 video_control (add_label_to_sizer (_sizer, this, "Audio Gain"));
139 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
140 _audio_gain = new wxSpinCtrl (this);
141 s->Add (video_control (_audio_gain), 1);
142 video_control (add_label_to_sizer (s, this, "dB"));
143 _audio_gain_calculate_button = new wxButton (this, wxID_ANY, _("Calculate..."));
144 video_control (_audio_gain_calculate_button);
145 s->Add (_audio_gain_calculate_button, 1, wxEXPAND);
150 video_control (add_label_to_sizer (_sizer, this, "Audio Delay"));
151 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
152 _audio_delay = new wxSpinCtrl (this);
153 s->Add (video_control (_audio_delay), 1);
154 video_control (add_label_to_sizer (s, this, "ms"));
158 _with_subtitles = new wxCheckBox (this, wxID_ANY, wxT("With Subtitles"));
159 video_control (_with_subtitles);
160 _sizer->Add (_with_subtitles, 1);
162 _subtitle_stream = new wxComboBox (this, wxID_ANY);
163 _sizer->Add (_subtitle_stream);
165 video_control (add_label_to_sizer (_sizer, this, "Subtitle Offset"));
166 _subtitle_offset = new wxSpinCtrl (this);
167 _sizer->Add (video_control (_subtitle_offset), 1);
170 video_control (add_label_to_sizer (_sizer, this, "Subtitle Scale"));
171 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
172 _subtitle_scale = new wxSpinCtrl (this);
173 s->Add (video_control (_subtitle_scale));
174 video_control (add_label_to_sizer (s, this, "%"));
178 video_control (add_label_to_sizer (_sizer, this, "Frames Per Second"));
179 _frames_per_second = new wxStaticText (this, wxID_ANY, wxT (""));
180 _sizer->Add (video_control (_frames_per_second), 1, wxALIGN_CENTER_VERTICAL);
182 video_control (add_label_to_sizer (_sizer, this, "Original Size"));
183 _original_size = new wxStaticText (this, wxID_ANY, wxT (""));
184 _sizer->Add (video_control (_original_size), 1, wxALIGN_CENTER_VERTICAL);
186 video_control (add_label_to_sizer (_sizer, this, "Length"));
187 _length = new wxStaticText (this, wxID_ANY, wxT (""));
188 _sizer->Add (video_control (_length), 1, wxALIGN_CENTER_VERTICAL);
192 video_control (add_label_to_sizer (_sizer, this, "Trim frames"));
193 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
194 add_label_to_sizer (s, this, "Start");
195 _dcp_trim_start = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
196 s->Add (_dcp_trim_start);
197 add_label_to_sizer (s, this, "End");
198 _dcp_trim_end = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
199 s->Add (_dcp_trim_end);
204 _dcp_ab = new wxCheckBox (this, wxID_ANY, wxT ("A/B"));
205 video_control (_dcp_ab);
206 _sizer->Add (_dcp_ab, 1);
207 _sizer->AddSpacer (0);
209 /* STILL-only stuff */
211 still_control (add_label_to_sizer (_sizer, this, "Duration"));
212 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
213 _still_duration = new wxSpinCtrl (this);
214 still_control (_still_duration);
215 s->Add (_still_duration, 1, wxEXPAND);
216 still_control (add_label_to_sizer (s, this, "s"));
220 /* Set up our editing widgets */
222 _left_crop->SetRange (0, 1024);
223 _top_crop->SetRange (0, 1024);
224 _right_crop->SetRange (0, 1024);
225 _bottom_crop->SetRange (0, 1024);
226 _audio_gain->SetRange (-60, 60);
227 _audio_delay->SetRange (-1000, 1000);
228 _still_duration->SetRange (0, 60 * 60);
229 _subtitle_offset->SetRange (-1024, 1024);
230 _subtitle_scale->SetRange (1, 1000);
231 _dcp_trim_start->SetRange (0, 100);
232 _dcp_trim_end->SetRange (0, 100);
234 vector<DCPContentType const *> const ct = DCPContentType::all ();
235 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
236 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
239 vector<Scaler const *> const sc = Scaler::all ();
240 for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
241 _scaler->Append (std_to_wx ((*i)->name()));
244 JobManager::instance()->ActiveJobsChanged.connect (
245 bind (&FilmEditor::active_jobs_changed, this, _1)
248 /* And set their values from the Film */
251 /* Now connect to them, since initial values are safely set */
252 _name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
253 _use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
254 _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
255 _format->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
256 _content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this);
257 _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
258 _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
259 _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
260 _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
261 _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
262 _scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
263 _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
264 _dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this);
265 _audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
266 _audio_gain_calculate_button->Connect (
267 wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
269 _audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
270 _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
271 _dcp_trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::dcp_trim_start_changed), 0, this);
272 _dcp_trim_end->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::dcp_trim_end_changed), 0, this);
273 _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
274 _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
275 _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
276 _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
277 _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
283 /** Called when the left crop widget has been changed */
285 FilmEditor::left_crop_changed (wxCommandEvent &)
291 _film->set_left_crop (_left_crop->GetValue ());
294 /** Called when the right crop widget has been changed */
296 FilmEditor::right_crop_changed (wxCommandEvent &)
302 _film->set_right_crop (_right_crop->GetValue ());
305 /** Called when the top crop widget has been changed */
307 FilmEditor::top_crop_changed (wxCommandEvent &)
313 _film->set_top_crop (_top_crop->GetValue ());
316 /** Called when the bottom crop value has been changed */
318 FilmEditor::bottom_crop_changed (wxCommandEvent &)
324 _film->set_bottom_crop (_bottom_crop->GetValue ());
327 /** Called when the content filename has been changed */
329 FilmEditor::content_changed (wxCommandEvent &)
336 _film->set_content (wx_to_std (_content->GetPath ()));
337 } catch (std::exception& e) {
338 _content->SetPath (std_to_wx (_film->directory ()));
339 error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
343 /** Called when the DCP A/B switch has been toggled */
345 FilmEditor::dcp_ab_toggled (wxCommandEvent &)
351 _film->set_dcp_ab (_dcp_ab->GetValue ());
354 /** Called when the name widget has been changed */
356 FilmEditor::name_changed (wxCommandEvent &)
362 _film->set_name (string (_name->GetValue().mb_str()));
366 FilmEditor::subtitle_offset_changed (wxCommandEvent &)
372 _film->set_subtitle_offset (_subtitle_offset->GetValue ());
376 FilmEditor::subtitle_scale_changed (wxCommandEvent &)
382 _film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
386 /** Called when the metadata stored in the Film object has changed;
387 * so that we can update the GUI.
388 * @param p Property of the Film that has changed.
391 FilmEditor::film_changed (Film::Property p)
405 checked_set (_content, _film->content ());
408 setup_subtitle_control_sensitivity ();
411 case Film::HAS_SUBTITLES:
412 setup_subtitle_control_sensitivity ();
415 case Film::AUDIO_STREAMS:
416 case Film::SUBTITLE_STREAMS:
422 vector<Format const *>::iterator i = _formats.begin ();
423 while (i != _formats.end() && *i != _film->format ()) {
427 checked_set (_format, n);
428 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
432 checked_set (_left_crop, _film->crop().left);
433 checked_set (_right_crop, _film->crop().right);
434 checked_set (_top_crop, _film->crop().top);
435 checked_set (_bottom_crop, _film->crop().bottom);
439 pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
440 if (p.first.empty () && p.second.empty ()) {
441 _filters->SetLabel (_("None"));
443 string const b = p.first + " " + p.second;
444 _filters->SetLabel (std_to_wx (b));
450 checked_set (_name, _film->name());
451 _film->set_dci_date_today ();
452 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
454 case Film::FRAMES_PER_SECOND:
455 s << fixed << setprecision(2) << _film->frames_per_second();
456 _frames_per_second->SetLabel (std_to_wx (s.str ()));
458 case Film::AUDIO_SAMPLE_RATE:
459 setup_audio_details ();
462 if (_film->size().width == 0 && _film->size().height == 0) {
463 _original_size->SetLabel (wxT (""));
465 s << _film->size().width << " x " << _film->size().height;
466 _original_size->SetLabel (std_to_wx (s.str ()));
470 if (_film->frames_per_second() > 0 && _film->length()) {
471 s << _film->length().get() << " frames; " << seconds_to_hms (_film->length().get() / _film->frames_per_second());
472 } else if (_film->length()) {
473 s << _film->length().get() << " frames";
475 _length->SetLabel (std_to_wx (s.str ()));
476 if (_film->length()) {
477 _dcp_trim_start->SetRange (0, _film->length().get());
478 _dcp_trim_end->SetRange (0, _film->length().get());
481 case Film::DCP_CONTENT_TYPE:
482 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
483 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
488 checked_set (_dcp_ab, _film->dcp_ab ());
491 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
493 case Film::DCP_TRIM_START:
494 checked_set (_dcp_trim_start, _film->dcp_trim_start());
496 case Film::DCP_TRIM_END:
497 checked_set (_dcp_trim_end, _film->dcp_trim_end());
499 case Film::AUDIO_GAIN:
500 checked_set (_audio_gain, _film->audio_gain ());
502 case Film::AUDIO_DELAY:
503 checked_set (_audio_delay, _film->audio_delay ());
505 case Film::STILL_DURATION:
506 checked_set (_still_duration, _film->still_duration ());
508 case Film::WITH_SUBTITLES:
509 checked_set (_with_subtitles, _film->with_subtitles ());
510 _subtitle_stream->Enable (_film->with_subtitles ());
511 _subtitle_scale->Enable (_film->with_subtitles ());
512 _subtitle_offset->Enable (_film->with_subtitles ());
513 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
515 case Film::SUBTITLE_OFFSET:
516 checked_set (_subtitle_offset, _film->subtitle_offset ());
518 case Film::SUBTITLE_SCALE:
519 checked_set (_subtitle_scale, _film->subtitle_scale() * 100);
521 case Film::USE_DCI_NAME:
522 checked_set (_use_dci_name, _film->use_dci_name ());
523 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
525 case Film::DCI_METADATA:
526 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
528 case Film::AUDIO_STREAM:
529 checked_set (_audio_stream, _film->audio_stream_index ());
530 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
531 setup_audio_details ();
533 case Film::SUBTITLE_STREAM:
534 checked_set (_subtitle_stream, _film->subtitle_stream_index ());
539 /** Called when the format widget has been changed */
541 FilmEditor::format_changed (wxCommandEvent &)
547 int const n = _format->GetSelection ();
549 assert (n < int (_formats.size()));
550 _film->set_format (_formats[n]);
554 /** Called when the DCP content type widget has been changed */
556 FilmEditor::dcp_content_type_changed (wxCommandEvent &)
562 int const n = _dcp_content_type->GetSelection ();
564 _film->set_dcp_content_type (DCPContentType::from_index (n));
568 /** Sets the Film that we are editing */
570 FilmEditor::set_film (shared_ptr<Film> f)
574 set_things_sensitive (_film != 0);
577 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
581 FileChanged (_film->directory ());
586 film_changed (Film::NAME);
587 film_changed (Film::CONTENT);
588 film_changed (Film::DCP_CONTENT_TYPE);
589 film_changed (Film::FORMAT);
590 film_changed (Film::CROP);
591 film_changed (Film::FILTERS);
592 film_changed (Film::DCP_TRIM_START);
593 film_changed (Film::DCP_TRIM_END);
594 film_changed (Film::DCP_AB);
595 film_changed (Film::SIZE);
596 film_changed (Film::LENGTH);
597 film_changed (Film::FRAMES_PER_SECOND);
598 film_changed (Film::AUDIO_SAMPLE_RATE);
599 film_changed (Film::SCALER);
600 film_changed (Film::AUDIO_GAIN);
601 film_changed (Film::AUDIO_DELAY);
602 film_changed (Film::STILL_DURATION);
603 film_changed (Film::WITH_SUBTITLES);
604 film_changed (Film::HAS_SUBTITLES);
605 film_changed (Film::SUBTITLE_OFFSET);
606 film_changed (Film::SUBTITLE_SCALE);
607 film_changed (Film::USE_DCI_NAME);
608 film_changed (Film::DCI_METADATA);
611 /** Updates the sensitivity of lots of widgets to a given value.
612 * @param s true to make sensitive, false to make insensitive.
615 FilmEditor::set_things_sensitive (bool s)
617 _generally_sensitive = s;
620 _use_dci_name->Enable (s);
621 _edit_dci_button->Enable (s);
623 _content->Enable (s);
624 _left_crop->Enable (s);
625 _right_crop->Enable (s);
626 _top_crop->Enable (s);
627 _bottom_crop->Enable (s);
628 _filters_button->Enable (s);
630 _audio_stream->Enable (s);
631 _dcp_content_type->Enable (s);
632 _dcp_trim_start->Enable (s);
633 _dcp_trim_end->Enable (s);
635 _audio_gain->Enable (s);
636 _audio_gain_calculate_button->Enable (s);
637 _audio_delay->Enable (s);
638 _still_duration->Enable (s);
640 setup_subtitle_control_sensitivity ();
643 /** Called when the `Edit filters' button has been clicked */
645 FilmEditor::edit_filters_clicked (wxCommandEvent &)
647 FilterDialog* d = new FilterDialog (this, _film->filters());
648 d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
653 /** Called when the scaler widget has been changed */
655 FilmEditor::scaler_changed (wxCommandEvent &)
661 int const n = _scaler->GetSelection ();
663 _film->set_scaler (Scaler::from_index (n));
668 FilmEditor::audio_gain_changed (wxCommandEvent &)
674 _film->set_audio_gain (_audio_gain->GetValue ());
678 FilmEditor::audio_delay_changed (wxCommandEvent &)
684 _film->set_audio_delay (_audio_delay->GetValue ());
688 FilmEditor::video_control (wxControl* c)
690 _video_controls.push_back (c);
695 FilmEditor::still_control (wxControl* c)
697 _still_controls.push_back (c);
702 FilmEditor::setup_visibility ()
704 ContentType c = VIDEO;
707 c = _film->content_type ();
710 for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
711 (*i)->Show (c == VIDEO);
714 for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
715 (*i)->Show (c == STILL);
722 FilmEditor::still_duration_changed (wxCommandEvent &)
728 _film->set_still_duration (_still_duration->GetValue ());
732 FilmEditor::dcp_trim_start_changed (wxCommandEvent &)
738 _film->set_dcp_trim_start (_dcp_trim_start->GetValue ());
742 FilmEditor::dcp_trim_end_changed (wxCommandEvent &)
748 _film->set_dcp_trim_end (_dcp_trim_end->GetValue ());
752 FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
754 GainCalculatorDialog* d = new GainCalculatorDialog (this);
757 if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
762 _audio_gain->SetValue (
763 Config::instance()->sound_processor()->db_for_fader_change (
769 /* This appears to be necessary, as the change is not signalled,
772 wxCommandEvent dummy;
773 audio_gain_changed (dummy);
779 FilmEditor::setup_formats ()
781 ContentType c = VIDEO;
784 c = _film->content_type ();
789 vector<Format const *> fmt = Format::all ();
790 for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
791 if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) {
792 _formats.push_back (*i);
793 } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) {
794 _formats.push_back (*i);
799 for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
800 _format->Append (std_to_wx ((*i)->name ()));
807 FilmEditor::with_subtitles_toggled (wxCommandEvent &)
813 _film->set_with_subtitles (_with_subtitles->GetValue ());
817 FilmEditor::setup_subtitle_control_sensitivity ()
820 if (_generally_sensitive && _film) {
821 h = _film->has_subtitles();
824 _with_subtitles->Enable (h);
825 _subtitle_stream->Enable (h);
826 _subtitle_offset->Enable (h);
827 _subtitle_scale->Enable (h);
831 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
837 _film->set_use_dci_name (_use_dci_name->GetValue ());
841 FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
847 DCINameDialog* d = new DCINameDialog (this, _film);
853 FilmEditor::setup_streams ()
855 _audio_stream->Clear ();
856 vector<AudioStream> a = _film->audio_streams ();
857 for (vector<AudioStream>::iterator i = a.begin(); i != a.end(); ++i) {
858 _audio_stream->Append (std_to_wx (i->name()));
860 _audio_stream->SetSelection (_film->audio_stream_index ());
862 _subtitle_stream->Clear ();
863 vector<SubtitleStream> s = _film->subtitle_streams ();
864 for (vector<SubtitleStream>::iterator i = s.begin(); i != s.end(); ++i) {
865 _subtitle_stream->Append (std_to_wx (i->name()));
867 _subtitle_stream->SetSelection (_film->subtitle_stream_index ());
871 FilmEditor::audio_stream_changed (wxCommandEvent &)
877 _film->set_audio_stream (_audio_stream->GetSelection ());
881 FilmEditor::subtitle_stream_changed (wxCommandEvent &)
887 _film->set_subtitle_stream (_subtitle_stream->GetSelection ());
891 FilmEditor::setup_audio_details ()
893 if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) {
894 _audio->SetLabel (wxT (""));
897 s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz";
898 _audio->SetLabel (std_to_wx (s.str ()));
903 FilmEditor::active_jobs_changed (bool a)
905 set_things_sensitive (!a);