Merge master.
[dcpomatic.git] / src / wx / film_editor.cc
1 /*
2     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 /** @file src/film_editor.cc
21  *  @brief A wx widget to edit a film's metadata, and perform various functions.
22  */
23
24 #include <iostream>
25 #include <iomanip>
26 #include <wx/wx.h>
27 #include <wx/notebook.h>
28 #include <wx/listctrl.h>
29 #include <boost/thread.hpp>
30 #include <boost/filesystem.hpp>
31 #include <boost/lexical_cast.hpp>
32 #include "lib/film.h"
33 #include "lib/transcode_job.h"
34 #include "lib/exceptions.h"
35 #include "lib/job_manager.h"
36 #include "lib/filter.h"
37 #include "lib/ratio.h"
38 #include "lib/config.h"
39 #include "lib/image_content.h"
40 #include "lib/ffmpeg_content.h"
41 #include "lib/sndfile_content.h"
42 #include "lib/dcp_content_type.h"
43 #include "lib/scaler.h"
44 #include "lib/playlist.h"
45 #include "lib/content.h"
46 #include "lib/content_factory.h"
47 #include "lib/dcp_content.h"
48 #include "timecode.h"
49 #include "wx_util.h"
50 #include "film_editor.h"
51 #include "isdcf_metadata_dialog.h"
52 #include "timeline_dialog.h"
53 #include "timing_panel.h"
54 #include "subtitle_panel.h"
55 #include "audio_panel.h"
56 #include "video_panel.h"
57
58 using std::string;
59 using std::cout;
60 using std::stringstream;
61 using std::pair;
62 using std::fixed;
63 using std::setprecision;
64 using std::list;
65 using std::vector;
66 using std::max;
67 using boost::shared_ptr;
68 using boost::weak_ptr;
69 using boost::dynamic_pointer_cast;
70 using boost::lexical_cast;
71
72 /** @param f Film to edit */
73 FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
74         : wxPanel (parent)
75         , _generally_sensitive (true)
76 {
77         wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
78
79         _main_notebook = new wxNotebook (this, wxID_ANY);
80         s->Add (_main_notebook, 1);
81
82         _content_panel = new ContentPanel (_main_notebook, _film);
83         _main_notebook->AddPage (_content_panel->panel (), _("Content"), true);
84         make_dcp_panel ();
85         _main_notebook->AddPage (_dcp_panel, _("DCP"), false);
86         
87         set_film (f);
88         connect_to_widgets ();
89
90         JobManager::instance()->ActiveJobsChanged.connect (
91                 bind (&FilmEditor::active_jobs_changed, this, _1)
92                 );
93
94         Config::instance()->Changed.connect (boost::bind (&FilmEditor::config_changed, this));
95         
96         SetSizerAndFit (s);
97 }
98
99 void
100 FilmEditor::make_dcp_panel ()
101 {
102         _dcp_panel = new wxPanel (_main_notebook);
103         _dcp_sizer = new wxBoxSizer (wxVERTICAL);
104         _dcp_panel->SetSizer (_dcp_sizer);
105
106         wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
107         _dcp_sizer->Add (grid, 0, wxEXPAND | wxALL, 8);
108
109         int r = 0;
110         
111         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Name"), true, wxGBPosition (r, 0));
112         _name = new wxTextCtrl (_dcp_panel, wxID_ANY);
113         grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND | wxLEFT | wxRIGHT);
114         ++r;
115         
116         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("DCP Name"), true, wxGBPosition (r, 0));
117         _dcp_name = new wxStaticText (_dcp_panel, wxID_ANY, wxT (""));
118         grid->Add (_dcp_name, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
119         ++r;
120
121         int flags = wxALIGN_CENTER_VERTICAL;
122 #ifdef __WXOSX__
123         flags |= wxALIGN_RIGHT;
124 #endif  
125
126         _use_isdcf_name = new wxCheckBox (_dcp_panel, wxID_ANY, _("Use ISDCF name"));
127         grid->Add (_use_isdcf_name, wxGBPosition (r, 0), wxDefaultSpan, flags);
128         _edit_isdcf_button = new wxButton (_dcp_panel, wxID_ANY, _("Details..."));
129         grid->Add (_edit_isdcf_button, wxGBPosition (r, 1), wxDefaultSpan);
130         ++r;
131
132         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Container"), true, wxGBPosition (r, 0));
133         _container = new wxChoice (_dcp_panel, wxID_ANY);
134         grid->Add (_container, wxGBPosition (r, 1), wxDefaultSpan, wxEXPAND);
135         ++r;
136
137         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Content Type"), true, wxGBPosition (r, 0));
138         _dcp_content_type = new wxChoice (_dcp_panel, wxID_ANY);
139         grid->Add (_dcp_content_type, wxGBPosition (r, 1));
140         ++r;
141
142         {
143                 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Frame Rate"), true, wxGBPosition (r, 0));
144                 _frame_rate_sizer = new wxBoxSizer (wxHORIZONTAL);
145                 _frame_rate_choice = new wxChoice (_dcp_panel, wxID_ANY);
146                 _frame_rate_sizer->Add (_frame_rate_choice, 1, wxALIGN_CENTER_VERTICAL);
147                 _frame_rate_spin = new wxSpinCtrl (_dcp_panel, wxID_ANY);
148                 _frame_rate_sizer->Add (_frame_rate_spin, 1, wxALIGN_CENTER_VERTICAL);
149                 setup_frame_rate_widget ();
150                 _best_frame_rate = new wxButton (_dcp_panel, wxID_ANY, _("Use best"));
151                 _frame_rate_sizer->Add (_best_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
152                 grid->Add (_frame_rate_sizer, wxGBPosition (r, 1));
153         }
154         ++r;
155
156         _burn_subtitles = new wxCheckBox (_dcp_panel, wxID_ANY, _("Burn subtitles into image"));
157         grid->Add (_burn_subtitles, wxGBPosition (r, 0), wxGBSpan (1, 2));
158         ++r;
159
160         _signed = new wxCheckBox (_dcp_panel, wxID_ANY, _("Signed"));
161         grid->Add (_signed, wxGBPosition (r, 0), wxGBSpan (1, 2));
162         ++r;
163         
164         _encrypted = new wxCheckBox (_dcp_panel, wxID_ANY, _("Encrypted"));
165         grid->Add (_encrypted, wxGBPosition (r, 0), wxGBSpan (1, 2));
166         ++r;
167
168         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Audio channels"), true, wxGBPosition (r, 0));
169         _audio_channels = new wxSpinCtrl (_dcp_panel, wxID_ANY);
170         grid->Add (_audio_channels, wxGBPosition (r, 1));
171         ++r;
172
173         _three_d = new wxCheckBox (_dcp_panel, wxID_ANY, _("3D"));
174         grid->Add (_three_d, wxGBPosition (r, 0), wxGBSpan (1, 2));
175         ++r;
176
177         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Resolution"), true, wxGBPosition (r, 0));
178         _resolution = new wxChoice (_dcp_panel, wxID_ANY);
179         grid->Add (_resolution, wxGBPosition (r, 1));
180         ++r;
181
182         {
183                 add_label_to_grid_bag_sizer (grid, _dcp_panel, _("JPEG2000 bandwidth"), true, wxGBPosition (r, 0));
184                 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
185                 _j2k_bandwidth = new wxSpinCtrl (_dcp_panel, wxID_ANY);
186                 s->Add (_j2k_bandwidth, 1);
187                 add_label_to_sizer (s, _dcp_panel, _("Mbit/s"), false);
188                 grid->Add (s, wxGBPosition (r, 1));
189         }
190         ++r;
191
192         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Standard"), true, wxGBPosition (r, 0));
193         _standard = new wxChoice (_dcp_panel, wxID_ANY);
194         grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
195         ++r;
196
197         add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Scaler"), true, wxGBPosition (r, 0));
198         _scaler = new wxChoice (_dcp_panel, wxID_ANY);
199         grid->Add (_scaler, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
200         ++r;
201
202         vector<Scaler const *> const sc = Scaler::all ();
203         for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
204                 _scaler->Append (std_to_wx ((*i)->name()));
205         }
206
207         vector<Ratio const *> const ratio = Ratio::all ();
208         for (vector<Ratio const *>::const_iterator i = ratio.begin(); i != ratio.end(); ++i) {
209                 _container->Append (std_to_wx ((*i)->nickname ()));
210         }
211
212         vector<DCPContentType const *> const ct = DCPContentType::all ();
213         for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
214                 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
215         }
216
217         list<int> const dfr = Config::instance()->allowed_dcp_frame_rates ();
218         for (list<int>::const_iterator i = dfr.begin(); i != dfr.end(); ++i) {
219                 _frame_rate_choice->Append (std_to_wx (boost::lexical_cast<string> (*i)));
220         }
221
222         _audio_channels->SetRange (0, MAX_DCP_AUDIO_CHANNELS);
223         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
224         _frame_rate_spin->SetRange (1, 480);
225
226         _resolution->Append (_("2K"));
227         _resolution->Append (_("4K"));
228
229         _standard->Append (_("SMPTE"));
230         _standard->Append (_("Interop"));
231 }
232
233 void
234 FilmEditor::connect_to_widgets ()
235 {
236         _name->Bind             (wxEVT_COMMAND_TEXT_UPDATED,          boost::bind (&FilmEditor::name_changed, this));
237         _use_isdcf_name->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::use_isdcf_name_toggled, this));
238         _edit_isdcf_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::edit_isdcf_button_clicked, this));
239         _container->Bind        (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::container_changed, this));
240         _scaler->Bind           (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::scaler_changed, this));
241         _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::dcp_content_type_changed, this));
242         _frame_rate_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::frame_rate_choice_changed, this));
243         _frame_rate_spin->Bind  (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::frame_rate_spin_changed, this));
244         _best_frame_rate->Bind  (wxEVT_COMMAND_BUTTON_CLICKED,        boost::bind (&FilmEditor::best_frame_rate_clicked, this));
245         _burn_subtitles->Bind   (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::burn_subtitles_toggled, this));
246         _signed->Bind           (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::signed_toggled, this));
247         _encrypted->Bind        (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::encrypted_toggled, this));
248         _audio_channels->Bind   (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::audio_channels_changed, this));
249         _j2k_bandwidth->Bind    (wxEVT_COMMAND_SPINCTRL_UPDATED,      boost::bind (&FilmEditor::j2k_bandwidth_changed, this));
250         _resolution->Bind       (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::resolution_changed, this));
251         _three_d->Bind          (wxEVT_COMMAND_CHECKBOX_CLICKED,      boost::bind (&FilmEditor::three_d_changed, this));
252         _standard->Bind         (wxEVT_COMMAND_CHOICE_SELECTED,       boost::bind (&FilmEditor::standard_changed, this));
253 }
254
255 /** Called when the name widget has been changed */
256 void
257 FilmEditor::name_changed ()
258 {
259         if (!_film) {
260                 return;
261         }
262
263         _film->set_name (string (_name->GetValue().mb_str()));
264 }
265
266 void
267 FilmEditor::j2k_bandwidth_changed ()
268 {
269         if (!_film) {
270                 return;
271         }
272         
273         _film->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
274 }
275
276 void
277 FilmEditor::signed_toggled ()
278 {
279         if (!_film) {
280                 return;
281         }
282
283         _film->set_signed (_signed->GetValue ());
284 }
285
286 void
287 FilmEditor::burn_subtitles_toggled ()
288 {
289         if (!_film) {
290                 return;
291         }
292
293         _film->set_burn_subtitles (_burn_subtitles->GetValue ());
294 }
295
296 void
297 FilmEditor::encrypted_toggled ()
298 {
299         if (!_film) {
300                 return;
301         }
302
303         _film->set_encrypted (_encrypted->GetValue ());
304 }
305                                
306 /** Called when the frame rate choice widget has been changed */
307 void
308 FilmEditor::frame_rate_choice_changed ()
309 {
310         if (!_film) {
311                 return;
312         }
313
314         _film->set_video_frame_rate (
315                 boost::lexical_cast<int> (
316                         wx_to_std (_frame_rate_choice->GetString (_frame_rate_choice->GetSelection ()))
317                         )
318                 );
319 }
320
321 /** Called when the frame rate spin widget has been changed */
322 void
323 FilmEditor::frame_rate_spin_changed ()
324 {
325         if (!_film) {
326                 return;
327         }
328
329         _film->set_video_frame_rate (_frame_rate_spin->GetValue ());
330 }
331
332 void
333 FilmEditor::audio_channels_changed ()
334 {
335         if (!_film) {
336                 return;
337         }
338
339         _film->set_audio_channels (_audio_channels->GetValue ());
340 }
341
342 void
343 FilmEditor::resolution_changed ()
344 {
345         if (!_film) {
346                 return;
347         }
348
349         _film->set_resolution (_resolution->GetSelection() == 0 ? RESOLUTION_2K : RESOLUTION_4K);
350 }
351
352 void
353 FilmEditor::standard_changed ()
354 {
355         if (!_film) {
356                 return;
357         }
358
359         _film->set_interop (_standard->GetSelection() == 1);
360 }
361
362 /** Called when the metadata stored in the Film object has changed;
363  *  so that we can update the GUI.
364  *  @param p Property of the Film that has changed.
365  */
366 void
367 FilmEditor::film_changed (Film::Property p)
368 {
369         ensure_ui_thread ();
370         
371         if (!_film) {
372                 return;
373         }
374
375         stringstream s;
376
377         _content_panel->film_changed (p);
378
379         switch (p) {
380         case Film::NONE:
381                 break;
382         case Film::CONTAINER:
383                 setup_container ();
384                 break;
385         case Film::NAME:
386                 checked_set (_name, _film->name());
387                 setup_dcp_name ();
388                 break;
389         case Film::DCP_CONTENT_TYPE:
390                 checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
391                 setup_dcp_name ();
392                 break;
393         case Film::SCALER:
394                 checked_set (_scaler, Scaler::as_index (_film->scaler ()));
395                 break;
396         case Film::BURN_SUBTITLES:
397                 checked_set (_burn_subtitles, _film->burn_subtitles ());
398                 break;
399         case Film::SIGNED:
400                 checked_set (_signed, _film->is_signed ());
401                 break;
402         case Film::ENCRYPTED:
403                 checked_set (_encrypted, _film->encrypted ());
404                 if (_film->encrypted ()) {
405                         _film->set_signed (true);
406                         _signed->Enable (false);
407                 } else {
408                         _signed->Enable (_generally_sensitive);
409                 }
410                 break;
411         case Film::RESOLUTION:
412                 checked_set (_resolution, _film->resolution() == RESOLUTION_2K ? 0 : 1);
413                 setup_dcp_name ();
414                 break;
415         case Film::J2K_BANDWIDTH:
416                 checked_set (_j2k_bandwidth, _film->j2k_bandwidth() / 1000000);
417                 break;
418         case Film::USE_ISDCF_NAME:
419                 checked_set (_use_isdcf_name, _film->use_isdcf_name ());
420                 setup_dcp_name ();
421                 break;
422         case Film::ISDCF_METADATA:
423                 setup_dcp_name ();
424                 break;
425         case Film::VIDEO_FRAME_RATE:
426         {
427                 bool done = false;
428                 for (unsigned int i = 0; i < _frame_rate_choice->GetCount(); ++i) {
429                         if (wx_to_std (_frame_rate_choice->GetString(i)) == boost::lexical_cast<string> (_film->video_frame_rate())) {
430                                 checked_set (_frame_rate_choice, i);
431                                 done = true;
432                                 break;
433                         }
434                 }
435
436                 if (!done) {
437                         checked_set (_frame_rate_choice, -1);
438                 }
439
440                 _frame_rate_spin->SetValue (_film->video_frame_rate ());
441
442                 _best_frame_rate->Enable (_film->best_video_frame_rate () != _film->video_frame_rate ());
443                 break;
444         }
445         case Film::AUDIO_CHANNELS:
446                 checked_set (_audio_channels, _film->audio_channels ());
447                 setup_dcp_name ();
448                 break;
449         case Film::THREE_D:
450                 checked_set (_three_d, _film->three_d ());
451                 setup_dcp_name ();
452                 break;
453         case Film::INTEROP:
454                 checked_set (_standard, _film->interop() ? 1 : 0);
455                 break;
456         default:
457                 break;
458         }
459 }
460
461 void
462 FilmEditor::film_content_changed (int property)
463 {
464         ensure_ui_thread ();
465         
466         if (!_film) {
467                 /* We call this method ourselves (as well as using it as a signal handler)
468                    so _film can be 0.
469                 */
470                 return;
471         }
472
473         _content_panel->film_content_changed (property);
474
475         if (property == FFmpegContentProperty::AUDIO_STREAM || property == SubtitleContentProperty::USE_SUBTITLES) {
476                 setup_dcp_name ();
477         }
478 }
479
480 void
481 FilmEditor::setup_container ()
482 {
483         int n = 0;
484         vector<Ratio const *> ratios = Ratio::all ();
485         vector<Ratio const *>::iterator i = ratios.begin ();
486         while (i != ratios.end() && *i != _film->container ()) {
487                 ++i;
488                 ++n;
489         }
490         
491         if (i == ratios.end()) {
492                 checked_set (_container, -1);
493         } else {
494                 checked_set (_container, n);
495         }
496         
497         setup_dcp_name ();
498 }       
499
500 /** Called when the container widget has been changed */
501 void
502 FilmEditor::container_changed ()
503 {
504         if (!_film) {
505                 return;
506         }
507
508         int const n = _container->GetSelection ();
509         if (n >= 0) {
510                 vector<Ratio const *> ratios = Ratio::all ();
511                 assert (n < int (ratios.size()));
512                 _film->set_container (ratios[n]);
513         }
514 }
515
516 /** Called when the DCP content type widget has been changed */
517 void
518 FilmEditor::dcp_content_type_changed ()
519 {
520         if (!_film) {
521                 return;
522         }
523
524         int const n = _dcp_content_type->GetSelection ();
525         if (n != wxNOT_FOUND) {
526                 _film->set_dcp_content_type (DCPContentType::from_index (n));
527         }
528 }
529
530 /** Sets the Film that we are editing */
531 void
532 FilmEditor::set_film (shared_ptr<Film> f)
533 {
534         set_general_sensitivity (f != 0);
535
536         if (_film == f) {
537                 return;
538         }
539         
540         _film = f;
541
542         _content_panel->set_film (_film);
543
544         if (_film) {
545                 _film->Changed.connect (bind (&FilmEditor::film_changed, this, _1));
546                 _film->ContentChanged.connect (bind (&FilmEditor::film_content_changed, this, _2));
547         }
548
549         if (_film) {
550                 FileChanged (_film->directory ());
551         } else {
552                 FileChanged ("");
553         }
554
555         film_changed (Film::NAME);
556         film_changed (Film::USE_ISDCF_NAME);
557         film_changed (Film::CONTENT);
558         film_changed (Film::DCP_CONTENT_TYPE);
559         film_changed (Film::CONTAINER);
560         film_changed (Film::RESOLUTION);
561         film_changed (Film::SCALER);
562         film_changed (Film::SIGNED);
563         film_changed (Film::BURN_SUBTITLES);
564         film_changed (Film::ENCRYPTED);
565         film_changed (Film::J2K_BANDWIDTH);
566         film_changed (Film::ISDCF_METADATA);
567         film_changed (Film::VIDEO_FRAME_RATE);
568         film_changed (Film::AUDIO_CHANNELS);
569         film_changed (Film::SEQUENCE_VIDEO);
570         film_changed (Film::THREE_D);
571         film_changed (Film::INTEROP);
572
573         if (!_film->content().empty ()) {
574                 _content_panel->set_selection (_film->content().front ());
575         }
576 }
577
578 void
579 FilmEditor::set_general_sensitivity (bool s)
580 {
581         _generally_sensitive = s;
582
583         _content_panel->set_general_sensitivity (s);
584
585         /* Stuff in the Content / DCP tabs */
586         _name->Enable (s);
587         _use_isdcf_name->Enable (s);
588         _edit_isdcf_button->Enable (s);
589         _dcp_content_type->Enable (s);
590
591         bool si = s;
592         if (_film && _film->encrypted ()) {
593                 si = false;
594         }
595         _burn_subtitles->Enable (s);
596         _signed->Enable (si);
597         
598         _encrypted->Enable (s);
599         _frame_rate_choice->Enable (s);
600         _frame_rate_spin->Enable (s);
601         _audio_channels->Enable (s);
602         _j2k_bandwidth->Enable (s);
603         _container->Enable (s);
604         _best_frame_rate->Enable (s && _film && _film->best_video_frame_rate () != _film->video_frame_rate ());
605         _resolution->Enable (s);
606         _scaler->Enable (s);
607         _three_d->Enable (s);
608         _standard->Enable (s);
609 }
610
611 /** Called when the scaler widget has been changed */
612 void
613 FilmEditor::scaler_changed ()
614 {
615         if (!_film) {
616                 return;
617         }
618
619         int const n = _scaler->GetSelection ();
620         if (n >= 0) {
621                 _film->set_scaler (Scaler::from_index (n));
622         }
623 }
624
625 void
626 FilmEditor::use_isdcf_name_toggled ()
627 {
628         if (!_film) {
629                 return;
630         }
631
632         _film->set_use_isdcf_name (_use_isdcf_name->GetValue ());
633 }
634
635 void
636 FilmEditor::edit_isdcf_button_clicked ()
637 {
638         if (!_film) {
639                 return;
640         }
641
642         ISDCFMetadataDialog* d = new ISDCFMetadataDialog (this, _film->isdcf_metadata ());
643         d->ShowModal ();
644         _film->set_isdcf_metadata (d->isdcf_metadata ());
645         d->Destroy ();
646 }
647
648 void
649 FilmEditor::active_jobs_changed (bool a)
650 {
651         set_general_sensitivity (!a);
652 }
653
654 void
655 FilmEditor::setup_dcp_name ()
656 {
657         string s = _film->dcp_name (true);
658         if (s.length() > 28) {
659                 _dcp_name->SetLabel (std_to_wx (s.substr (0, 28)) + N_("..."));
660                 _dcp_name->SetToolTip (std_to_wx (s));
661         } else {
662                 _dcp_name->SetLabel (std_to_wx (s));
663         }
664 }
665
666 void
667 FilmEditor::best_frame_rate_clicked ()
668 {
669         if (!_film) {
670                 return;
671         }
672         
673         _film->set_video_frame_rate (_film->best_video_frame_rate ());
674 }
675
676 void
677 FilmEditor::three_d_changed ()
678 {
679         if (!_film) {
680                 return;
681         }
682
683         _film->set_three_d (_three_d->GetValue ());
684 }
685
686 void
687 FilmEditor::config_changed ()
688 {
689         _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000);
690         setup_frame_rate_widget ();
691 }
692
693 void
694 FilmEditor::setup_frame_rate_widget ()
695 {
696         if (Config::instance()->allow_any_dcp_frame_rate ()) {
697                 _frame_rate_choice->Hide ();
698                 _frame_rate_spin->Show ();
699         } else {
700                 _frame_rate_choice->Show ();
701                 _frame_rate_spin->Hide ();
702         }
703
704         _frame_rate_sizer->Layout ();
705 }