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 <wx/notebook.h>
28 #include <boost/thread.hpp>
29 #include <boost/filesystem.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include "lib/format.h"
33 #include "lib/transcode_job.h"
34 #include "lib/exceptions.h"
35 #include "lib/ab_transcode_job.h"
36 #include "lib/job_manager.h"
37 #include "lib/filter.h"
38 #include "lib/screen.h"
39 #include "lib/config.h"
40 #include "filter_dialog.h"
42 #include "film_editor.h"
43 #include "gain_calculator_dialog.h"
44 #include "sound_processor.h"
45 #include "dci_name_dialog.h"
49 using std::stringstream;
52 using std::setprecision;
55 using boost::shared_ptr;
57 /** @param f Film to edit */
58 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
61 , _generally_sensitive (true)
63 wxSizer* s = new wxBoxSizer (wxVERTICAL);
65 _notebook = new wxNotebook (this, wxID_ANY);
66 s->Add (_notebook, 1);
69 _notebook->AddPage (_film_panel, _("Film"), true);
71 _notebook->AddPage (_video_panel, _("Video"), false);
73 _notebook->AddPage (_audio_panel, _("Audio"), false);
74 make_subtitle_panel ();
75 _notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
78 connect_to_widgets ();
80 JobManager::instance()->ActiveJobsChanged.connect (
81 bind (&FilmEditor::active_jobs_changed, this, _1)
89 FilmEditor::make_film_panel ()
91 _film_panel = new wxPanel (_notebook);
92 _film_sizer = new wxFlexGridSizer (2, 4, 4);
93 _film_panel->SetSizer (_film_sizer);
95 add_label_to_sizer (_film_sizer, _film_panel, "Name");
96 _name = new wxTextCtrl (_film_panel, wxID_ANY);
97 _film_sizer->Add (_name, 1, wxEXPAND);
99 add_label_to_sizer (_film_sizer, _film_panel, "DCP Name");
100 _dcp_name = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
101 _film_sizer->Add (_dcp_name, 0, wxALIGN_CENTER_VERTICAL | wxSHRINK);
103 _use_dci_name = new wxCheckBox (_film_panel, wxID_ANY, wxT ("Use DCI name"));
104 _film_sizer->Add (_use_dci_name, 1, wxEXPAND);
105 _edit_dci_button = new wxButton (_film_panel, wxID_ANY, wxT ("Details..."));
106 _film_sizer->Add (_edit_dci_button, 0);
108 add_label_to_sizer (_film_sizer, _film_panel, "Content");
109 _content = new wxFilePickerCtrl (_film_panel, wxID_ANY, wxT (""), wxT ("Select Content File"), wxT("*.*"));
110 _film_sizer->Add (_content, 1, wxEXPAND);
112 add_label_to_sizer (_film_sizer, _film_panel, "Content Type");
113 _dcp_content_type = new wxComboBox (_film_panel, wxID_ANY);
114 _film_sizer->Add (_dcp_content_type);
116 video_control (add_label_to_sizer (_film_sizer, _film_panel, "Frames Per Second"));
117 _frames_per_second = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
118 _film_sizer->Add (video_control (_frames_per_second), 1, wxALIGN_CENTER_VERTICAL);
120 video_control (add_label_to_sizer (_film_sizer, _film_panel, "Original Size"));
121 _original_size = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
122 _film_sizer->Add (video_control (_original_size), 1, wxALIGN_CENTER_VERTICAL);
124 video_control (add_label_to_sizer (_film_sizer, _film_panel, "Length"));
125 _length = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
126 _film_sizer->Add (video_control (_length), 1, wxALIGN_CENTER_VERTICAL);
130 video_control (add_label_to_sizer (_film_sizer, _film_panel, "Trim frames"));
131 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
132 add_label_to_sizer (s, _film_panel, "Start");
133 _dcp_trim_start = new wxSpinCtrl (_film_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
134 s->Add (_dcp_trim_start);
135 add_label_to_sizer (s, _film_panel, "End");
136 _dcp_trim_end = new wxSpinCtrl (_film_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
137 s->Add (_dcp_trim_end);
139 _film_sizer->Add (s);
142 _dcp_ab = new wxCheckBox (_film_panel, wxID_ANY, wxT ("A/B"));
143 video_control (_dcp_ab);
144 _film_sizer->Add (_dcp_ab, 1);
145 _film_sizer->AddSpacer (0);
147 /* STILL-only stuff */
149 still_control (add_label_to_sizer (_film_sizer, _film_panel, "Duration"));
150 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
151 _still_duration = new wxSpinCtrl (_film_panel);
152 still_control (_still_duration);
153 s->Add (_still_duration, 1, wxEXPAND);
154 still_control (add_label_to_sizer (s, _film_panel, "s"));
155 _film_sizer->Add (s);
158 vector<DCPContentType const *> const ct = DCPContentType::all ();
159 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
160 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
165 FilmEditor::connect_to_widgets ()
167 _name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
168 _use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
169 _edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
170 _format->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
171 _content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this);
172 _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
173 _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
174 _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
175 _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
176 _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
177 _scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
178 _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
179 _dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this);
180 _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
181 _dcp_trim_start->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::dcp_trim_start_changed), 0, this);
182 _dcp_trim_end->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::dcp_trim_end_changed), 0, this);
183 _with_subtitles->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::with_subtitles_toggled), 0, this);
184 _subtitle_offset->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_offset_changed), 0, this);
185 _subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
186 _subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::subtitle_stream_changed), 0, this);
187 _audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
188 _audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
189 _audio_gain_calculate_button->Connect (
190 wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
192 _audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
196 FilmEditor::make_video_panel ()
198 _video_panel = new wxPanel (_notebook);
199 _video_sizer = new wxFlexGridSizer (2, 4, 4);
200 _video_panel->SetSizer (_video_sizer);
202 add_label_to_sizer (_video_sizer, _video_panel, "Format");
203 _format = new wxComboBox (_video_panel, wxID_ANY);
204 _video_sizer->Add (_format);
207 add_label_to_sizer (_video_sizer, _video_panel, "Crop");
208 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
210 add_label_to_sizer (s, _video_panel, "L");
211 _left_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
212 s->Add (_left_crop, 0);
213 add_label_to_sizer (s, _video_panel, "R");
214 _right_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
215 s->Add (_right_crop, 0);
216 add_label_to_sizer (s, _video_panel, "T");
217 _top_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
218 s->Add (_top_crop, 0);
219 add_label_to_sizer (s, _video_panel, "B");
220 _bottom_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
221 s->Add (_bottom_crop, 0);
223 _video_sizer->Add (s);
226 /* VIDEO-only stuff */
228 video_control (add_label_to_sizer (_video_sizer, _video_panel, "Filters"));
229 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
230 _filters = new wxStaticText (_video_panel, wxID_ANY, wxT ("None"));
231 video_control (_filters);
232 s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
233 _filters_button = new wxButton (_video_panel, wxID_ANY, wxT ("Edit..."));
234 video_control (_filters_button);
235 s->Add (_filters_button, 0);
236 _video_sizer->Add (s, 1);
239 video_control (add_label_to_sizer (_video_sizer, _video_panel, "Scaler"));
240 _scaler = new wxComboBox (_video_panel, wxID_ANY);
241 _video_sizer->Add (video_control (_scaler), 1);
243 vector<Scaler const *> const sc = Scaler::all ();
244 for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
245 _scaler->Append (std_to_wx ((*i)->name()));
248 _left_crop->SetRange (0, 1024);
249 _top_crop->SetRange (0, 1024);
250 _right_crop->SetRange (0, 1024);
251 _bottom_crop->SetRange (0, 1024);
252 _still_duration->SetRange (0, 60 * 60);
253 _dcp_trim_start->SetRange (0, 100);
254 _dcp_trim_end->SetRange (0, 100);
258 FilmEditor::make_audio_panel ()
260 _audio_panel = new wxPanel (_notebook);
261 _audio_sizer = new wxFlexGridSizer (2, 4, 4);
262 _audio_panel->SetSizer (_audio_sizer);
265 video_control (add_label_to_sizer (_audio_sizer, _audio_panel, "Audio Stream"));
266 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
267 _audio_stream = new wxComboBox (_audio_panel, wxID_ANY);
268 s->Add (video_control (_audio_stream), 1);
269 _audio = new wxStaticText (_audio_panel, wxID_ANY, wxT (""));
270 s->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
271 _audio_sizer->Add (s, 1, wxEXPAND);
275 video_control (add_label_to_sizer (_audio_sizer, _audio_panel, "Audio Gain"));
276 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
277 _audio_gain = new wxSpinCtrl (_audio_panel);
278 s->Add (video_control (_audio_gain), 1);
279 video_control (add_label_to_sizer (s, _audio_panel, "dB"));
280 _audio_gain_calculate_button = new wxButton (_audio_panel, wxID_ANY, _("Calculate..."));
281 video_control (_audio_gain_calculate_button);
282 s->Add (_audio_gain_calculate_button, 1, wxEXPAND);
283 _audio_sizer->Add (s);
287 video_control (add_label_to_sizer (_audio_sizer, _audio_panel, "Audio Delay"));
288 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
289 _audio_delay = new wxSpinCtrl (_audio_panel);
290 s->Add (video_control (_audio_delay), 1);
291 video_control (add_label_to_sizer (s, _audio_panel, "ms"));
292 _audio_sizer->Add (s);
295 _audio_gain->SetRange (-60, 60);
296 _audio_delay->SetRange (-1000, 1000);
300 FilmEditor::make_subtitle_panel ()
302 _subtitle_panel = new wxPanel (_notebook);
303 _subtitle_sizer = new wxFlexGridSizer (2, 4, 4);
304 _subtitle_panel->SetSizer (_subtitle_sizer);
306 _with_subtitles = new wxCheckBox (_subtitle_panel, wxID_ANY, wxT("With Subtitles"));
307 video_control (_with_subtitles);
308 _subtitle_sizer->Add (_with_subtitles, 1);
310 _subtitle_stream = new wxComboBox (_subtitle_panel, wxID_ANY);
311 _subtitle_sizer->Add (_subtitle_stream);
313 video_control (add_label_to_sizer (_subtitle_sizer, _subtitle_panel, "Subtitle Offset"));
314 _subtitle_offset = new wxSpinCtrl (_subtitle_panel);
315 _subtitle_sizer->Add (video_control (_subtitle_offset), 1);
318 video_control (add_label_to_sizer (_subtitle_sizer, _subtitle_panel, "Subtitle Scale"));
319 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
320 _subtitle_scale = new wxSpinCtrl (_subtitle_panel);
321 s->Add (video_control (_subtitle_scale));
322 video_control (add_label_to_sizer (s, _subtitle_panel, "%"));
323 _subtitle_sizer->Add (s);
326 _subtitle_offset->SetRange (-1024, 1024);
327 _subtitle_scale->SetRange (1, 1000);
330 /** Called when the left crop widget has been changed */
332 FilmEditor::left_crop_changed (wxCommandEvent &)
338 _film->set_left_crop (_left_crop->GetValue ());
341 /** Called when the right crop widget has been changed */
343 FilmEditor::right_crop_changed (wxCommandEvent &)
349 _film->set_right_crop (_right_crop->GetValue ());
352 /** Called when the top crop widget has been changed */
354 FilmEditor::top_crop_changed (wxCommandEvent &)
360 _film->set_top_crop (_top_crop->GetValue ());
363 /** Called when the bottom crop value has been changed */
365 FilmEditor::bottom_crop_changed (wxCommandEvent &)
371 _film->set_bottom_crop (_bottom_crop->GetValue ());
374 /** Called when the content filename has been changed */
376 FilmEditor::content_changed (wxCommandEvent &)
383 _film->set_content (wx_to_std (_content->GetPath ()));
384 } catch (std::exception& e) {
385 _content->SetPath (std_to_wx (_film->directory ()));
386 error_dialog (this, String::compose ("Could not set content: %1", e.what ()));
390 /** Called when the DCP A/B switch has been toggled */
392 FilmEditor::dcp_ab_toggled (wxCommandEvent &)
398 _film->set_dcp_ab (_dcp_ab->GetValue ());
401 /** Called when the name widget has been changed */
403 FilmEditor::name_changed (wxCommandEvent &)
409 _film->set_name (string (_name->GetValue().mb_str()));
413 FilmEditor::subtitle_offset_changed (wxCommandEvent &)
419 _film->set_subtitle_offset (_subtitle_offset->GetValue ());
423 FilmEditor::subtitle_scale_changed (wxCommandEvent &)
429 _film->set_subtitle_scale (_subtitle_scale->GetValue() / 100.0);
433 /** Called when the metadata stored in the Film object has changed;
434 * so that we can update the GUI.
435 * @param p Property of the Film that has changed.
438 FilmEditor::film_changed (Film::Property p)
452 checked_set (_content, _film->content ());
455 setup_subtitle_control_sensitivity ();
458 case Film::HAS_SUBTITLES:
459 setup_subtitle_control_sensitivity ();
462 case Film::AUDIO_STREAMS:
463 case Film::SUBTITLE_STREAMS:
469 vector<Format const *>::iterator i = _formats.begin ();
470 while (i != _formats.end() && *i != _film->format ()) {
474 checked_set (_format, n);
475 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
479 checked_set (_left_crop, _film->crop().left);
480 checked_set (_right_crop, _film->crop().right);
481 checked_set (_top_crop, _film->crop().top);
482 checked_set (_bottom_crop, _film->crop().bottom);
486 pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
487 if (p.first.empty () && p.second.empty ()) {
488 _filters->SetLabel (_("None"));
490 string const b = p.first + " " + p.second;
491 _filters->SetLabel (std_to_wx (b));
493 _film_sizer->Layout ();
497 checked_set (_name, _film->name());
498 _film->set_dci_date_today ();
499 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
501 case Film::FRAMES_PER_SECOND:
502 s << fixed << setprecision(2) << _film->frames_per_second();
503 _frames_per_second->SetLabel (std_to_wx (s.str ()));
505 case Film::AUDIO_SAMPLE_RATE:
506 setup_audio_details ();
509 if (_film->size().width == 0 && _film->size().height == 0) {
510 _original_size->SetLabel (wxT (""));
512 s << _film->size().width << " x " << _film->size().height;
513 _original_size->SetLabel (std_to_wx (s.str ()));
517 if (_film->frames_per_second() > 0 && _film->length()) {
518 s << _film->length().get() << " frames; " << seconds_to_hms (_film->length().get() / _film->frames_per_second());
519 } else if (_film->length()) {
520 s << _film->length().get() << " frames";
522 _length->SetLabel (std_to_wx (s.str ()));
523 if (_film->length()) {
524 _dcp_trim_start->SetRange (0, _film->length().get());
525 _dcp_trim_end->SetRange (0, _film->length().get());
528 case Film::DCP_CONTENT_TYPE:
529 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
530 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
535 checked_set (_dcp_ab, _film->dcp_ab ());
538 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
540 case Film::DCP_TRIM_START:
541 checked_set (_dcp_trim_start, _film->dcp_trim_start());
543 case Film::DCP_TRIM_END:
544 checked_set (_dcp_trim_end, _film->dcp_trim_end());
546 case Film::AUDIO_GAIN:
547 checked_set (_audio_gain, _film->audio_gain ());
549 case Film::AUDIO_DELAY:
550 checked_set (_audio_delay, _film->audio_delay ());
552 case Film::STILL_DURATION:
553 checked_set (_still_duration, _film->still_duration ());
555 case Film::WITH_SUBTITLES:
556 checked_set (_with_subtitles, _film->with_subtitles ());
557 _subtitle_stream->Enable (_film->with_subtitles ());
558 _subtitle_scale->Enable (_film->with_subtitles ());
559 _subtitle_offset->Enable (_film->with_subtitles ());
560 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
562 case Film::SUBTITLE_OFFSET:
563 checked_set (_subtitle_offset, _film->subtitle_offset ());
565 case Film::SUBTITLE_SCALE:
566 checked_set (_subtitle_scale, _film->subtitle_scale() * 100);
568 case Film::USE_DCI_NAME:
569 checked_set (_use_dci_name, _film->use_dci_name ());
570 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
572 case Film::DCI_METADATA:
573 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
575 case Film::AUDIO_STREAM:
576 checked_set (_audio_stream, _film->audio_stream_index ());
577 _dcp_name->SetLabel (std_to_wx (_film->dcp_name ()));
578 setup_audio_details ();
580 case Film::SUBTITLE_STREAM:
581 checked_set (_subtitle_stream, _film->subtitle_stream_index ());
586 /** Called when the format widget has been changed */
588 FilmEditor::format_changed (wxCommandEvent &)
594 int const n = _format->GetSelection ();
596 assert (n < int (_formats.size()));
597 _film->set_format (_formats[n]);
601 /** Called when the DCP content type widget has been changed */
603 FilmEditor::dcp_content_type_changed (wxCommandEvent &)
609 int const n = _dcp_content_type->GetSelection ();
611 _film->set_dcp_content_type (DCPContentType::from_index (n));
615 /** Sets the Film that we are editing */
617 FilmEditor::set_film (shared_ptr<Film> f)
621 set_things_sensitive (_film != 0);
624 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
628 FileChanged (_film->directory ());
633 film_changed (Film::NAME);
634 film_changed (Film::CONTENT);
635 film_changed (Film::DCP_CONTENT_TYPE);
636 film_changed (Film::FORMAT);
637 film_changed (Film::CROP);
638 film_changed (Film::FILTERS);
639 film_changed (Film::DCP_TRIM_START);
640 film_changed (Film::DCP_TRIM_END);
641 film_changed (Film::DCP_AB);
642 film_changed (Film::SIZE);
643 film_changed (Film::LENGTH);
644 film_changed (Film::FRAMES_PER_SECOND);
645 film_changed (Film::AUDIO_SAMPLE_RATE);
646 film_changed (Film::SCALER);
647 film_changed (Film::AUDIO_GAIN);
648 film_changed (Film::AUDIO_DELAY);
649 film_changed (Film::STILL_DURATION);
650 film_changed (Film::WITH_SUBTITLES);
651 film_changed (Film::HAS_SUBTITLES);
652 film_changed (Film::SUBTITLE_OFFSET);
653 film_changed (Film::SUBTITLE_SCALE);
654 film_changed (Film::USE_DCI_NAME);
655 film_changed (Film::DCI_METADATA);
658 /** Updates the sensitivity of lots of widgets to a given value.
659 * @param s true to make sensitive, false to make insensitive.
662 FilmEditor::set_things_sensitive (bool s)
664 _generally_sensitive = s;
667 _use_dci_name->Enable (s);
668 _edit_dci_button->Enable (s);
670 _content->Enable (s);
671 _left_crop->Enable (s);
672 _right_crop->Enable (s);
673 _top_crop->Enable (s);
674 _bottom_crop->Enable (s);
675 _filters_button->Enable (s);
677 _audio_stream->Enable (s);
678 _dcp_content_type->Enable (s);
679 _dcp_trim_start->Enable (s);
680 _dcp_trim_end->Enable (s);
682 _audio_gain->Enable (s);
683 _audio_gain_calculate_button->Enable (s);
684 _audio_delay->Enable (s);
685 _still_duration->Enable (s);
687 setup_subtitle_control_sensitivity ();
690 /** Called when the `Edit filters' button has been clicked */
692 FilmEditor::edit_filters_clicked (wxCommandEvent &)
694 FilterDialog* d = new FilterDialog (this, _film->filters());
695 d->ActiveChanged.connect (bind (&Film::set_filters, _film, _1));
700 /** Called when the scaler widget has been changed */
702 FilmEditor::scaler_changed (wxCommandEvent &)
708 int const n = _scaler->GetSelection ();
710 _film->set_scaler (Scaler::from_index (n));
715 FilmEditor::audio_gain_changed (wxCommandEvent &)
721 _film->set_audio_gain (_audio_gain->GetValue ());
725 FilmEditor::audio_delay_changed (wxCommandEvent &)
731 _film->set_audio_delay (_audio_delay->GetValue ());
735 FilmEditor::video_control (wxControl* c)
737 _video_controls.push_back (c);
742 FilmEditor::still_control (wxControl* c)
744 _still_controls.push_back (c);
749 FilmEditor::setup_visibility ()
751 ContentType c = VIDEO;
754 c = _film->content_type ();
757 for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
758 (*i)->Show (c == VIDEO);
761 for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
762 (*i)->Show (c == STILL);
765 _film_sizer->Layout ();
769 FilmEditor::still_duration_changed (wxCommandEvent &)
775 _film->set_still_duration (_still_duration->GetValue ());
779 FilmEditor::dcp_trim_start_changed (wxCommandEvent &)
785 _film->set_dcp_trim_start (_dcp_trim_start->GetValue ());
789 FilmEditor::dcp_trim_end_changed (wxCommandEvent &)
795 _film->set_dcp_trim_end (_dcp_trim_end->GetValue ());
799 FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
801 GainCalculatorDialog* d = new GainCalculatorDialog (this);
804 if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
809 _audio_gain->SetValue (
810 Config::instance()->sound_processor()->db_for_fader_change (
816 /* This appears to be necessary, as the change is not signalled,
819 wxCommandEvent dummy;
820 audio_gain_changed (dummy);
826 FilmEditor::setup_formats ()
828 ContentType c = VIDEO;
831 c = _film->content_type ();
836 vector<Format const *> fmt = Format::all ();
837 for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
838 if (c == VIDEO && dynamic_cast<FixedFormat const *> (*i)) {
839 _formats.push_back (*i);
840 } else if (c == STILL && dynamic_cast<VariableFormat const *> (*i)) {
841 _formats.push_back (*i);
846 for (vector<Format const *>::iterator i = _formats.begin(); i != _formats.end(); ++i) {
847 _format->Append (std_to_wx ((*i)->name ()));
850 _film_sizer->Layout ();
854 FilmEditor::with_subtitles_toggled (wxCommandEvent &)
860 _film->set_with_subtitles (_with_subtitles->GetValue ());
864 FilmEditor::setup_subtitle_control_sensitivity ()
867 if (_generally_sensitive && _film) {
868 h = _film->has_subtitles();
871 _with_subtitles->Enable (h);
872 _subtitle_stream->Enable (h);
873 _subtitle_offset->Enable (h);
874 _subtitle_scale->Enable (h);
878 FilmEditor::use_dci_name_toggled (wxCommandEvent &)
884 _film->set_use_dci_name (_use_dci_name->GetValue ());
888 FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
894 DCINameDialog* d = new DCINameDialog (this, _film);
900 FilmEditor::setup_streams ()
902 _audio_stream->Clear ();
903 vector<AudioStream> a = _film->audio_streams ();
904 for (vector<AudioStream>::iterator i = a.begin(); i != a.end(); ++i) {
905 _audio_stream->Append (std_to_wx (i->name()));
907 _audio_stream->SetSelection (_film->audio_stream_index ());
909 _subtitle_stream->Clear ();
910 vector<SubtitleStream> s = _film->subtitle_streams ();
911 for (vector<SubtitleStream>::iterator i = s.begin(); i != s.end(); ++i) {
912 _subtitle_stream->Append (std_to_wx (i->name()));
914 _subtitle_stream->SetSelection (_film->subtitle_stream_index ());
918 FilmEditor::audio_stream_changed (wxCommandEvent &)
924 _film->set_audio_stream (_audio_stream->GetSelection ());
928 FilmEditor::subtitle_stream_changed (wxCommandEvent &)
934 _film->set_subtitle_stream (_subtitle_stream->GetSelection ());
938 FilmEditor::setup_audio_details ()
940 if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) {
941 _audio->SetLabel (wxT (""));
944 s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz";
945 _audio->SetLabel (std_to_wx (s.str ()));
950 FilmEditor::active_jobs_changed (bool a)
952 set_things_sensitive (!a);