c6758271fe16042d39c32a724c5d22f448d7d437
[dcpomatic.git] / src / wx / film_editor.cc
1 /*
2     Copyright (C) 2012 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 <boost/thread.hpp>
28 #include <boost/filesystem.hpp>
29 #include <boost/lexical_cast.hpp>
30 #include "lib/format.h"
31 #include "lib/film.h"
32 #include "lib/transcode_job.h"
33 #include "lib/exceptions.h"
34 #include "lib/ab_transcode_job.h"
35 #include "lib/thumbs_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"
41 #include "wx_util.h"
42 #include "film_editor.h"
43 #include "dcp_range_dialog.h"
44
45 using namespace std;
46 using namespace boost;
47
48 /** @param f Film to edit */
49 FilmEditor::FilmEditor (Film* f, wxWindow* parent)
50         : wxPanel (parent)
51         , _ignore_changes (false)
52         , _film (f)
53 {
54         _sizer = new wxFlexGridSizer (2, 4, 4);
55         SetSizer (_sizer);
56
57         add_label_to_sizer (_sizer, this, "Name");
58         _name = new wxTextCtrl (this, wxID_ANY);
59         _sizer->Add (_name, 1, wxEXPAND);
60
61         add_label_to_sizer (_sizer, this, "Content");
62         _content = new wxFilePickerCtrl (this, wxID_ANY, wxT (""), wxT ("Select Content File"), wxT("*.*"));
63         _sizer->Add (_content, 1, wxEXPAND);
64
65         add_label_to_sizer (_sizer, this, "Content Type");
66         _dcp_content_type = new wxComboBox (this, wxID_ANY);
67         _sizer->Add (_dcp_content_type);
68
69         add_label_to_sizer (_sizer, this, "Format");
70         _format = new wxComboBox (this, wxID_ANY);
71         _sizer->Add (_format);
72
73         {
74                 add_label_to_sizer (_sizer, this, "Crop");
75                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
76
77                 add_label_to_sizer (s, this, "L");
78                 _left_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
79                 s->Add (_left_crop, 0);
80                 add_label_to_sizer (s, this, "R");
81                 _right_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
82                 s->Add (_right_crop, 0);
83                 add_label_to_sizer (s, this, "T");
84                 _top_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
85                 s->Add (_top_crop, 0);
86                 add_label_to_sizer (s, this, "B");
87                 _bottom_crop = new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1));
88                 s->Add (_bottom_crop, 0);
89
90                 _sizer->Add (s);
91         }
92
93         /* VIDEO-only stuff */
94         {
95                 video_control (add_label_to_sizer (_sizer, this, "Filters"));
96                 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
97                 _filters = new wxStaticText (this, wxID_ANY, wxT ("None"));
98                 video_control (_filters);
99                 s->Add (_filters, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
100                 _filters_button = new wxButton (this, wxID_ANY, wxT ("Edit..."));
101                 video_control (_filters_button);
102                 s->Add (_filters_button, 0);
103                 _sizer->Add (s, 1);
104         }
105
106         video_control (add_label_to_sizer (_sizer, this, "Scaler"));
107         _scaler = new wxComboBox (this, wxID_ANY);
108         _sizer->Add (video_control (_scaler), 1);
109
110         {
111                 video_control (add_label_to_sizer (_sizer, this, "Audio Gain"));
112                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
113                 _audio_gain = new wxSpinCtrl (this);
114                 s->Add (video_control (_audio_gain), 1);
115                 video_control (add_label_to_sizer (s, this, "dB"));
116                 _sizer->Add (s);
117         }
118
119         {
120                 video_control (add_label_to_sizer (_sizer, this, "Audio Delay"));
121                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
122                 _audio_delay = new wxSpinCtrl (this);
123                 s->Add (video_control (_audio_delay), 1);
124                 video_control (add_label_to_sizer (s, this, "ms"));
125                 _sizer->Add (s);
126         }
127
128         video_control (add_label_to_sizer (_sizer, this, "Frames Per Second"));
129         _frames_per_second = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator (wxFILTER_NUMERIC));
130         _sizer->Add (video_control (_frames_per_second));
131         
132         video_control (add_label_to_sizer (_sizer, this, "Original Size"));
133         _original_size = new wxStaticText (this, wxID_ANY, wxT (""));
134         _sizer->Add (video_control (_original_size), 1, wxALIGN_CENTER_VERTICAL);
135         
136         video_control (add_label_to_sizer (_sizer, this, "Length"));
137         _length = new wxStaticText (this, wxID_ANY, wxT (""));
138         _sizer->Add (video_control (_length), 1, wxALIGN_CENTER_VERTICAL);
139
140         video_control (add_label_to_sizer (_sizer, this, "Audio"));
141         _audio = new wxStaticText (this, wxID_ANY, wxT (""));
142         _sizer->Add (video_control (_audio), 1, wxALIGN_CENTER_VERTICAL);
143
144         {
145                 video_control (add_label_to_sizer (_sizer, this, "Range"));
146                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
147                 _dcp_range = new wxStaticText (this, wxID_ANY, wxT (""));
148                 s->Add (video_control (_dcp_range), 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
149                 _change_dcp_range_button = new wxButton (this, wxID_ANY, wxT ("Edit..."));
150                 s->Add (video_control (_change_dcp_range_button), 0, 0, 6);
151                 _sizer->Add (s);
152         }
153
154         _dcp_ab = new wxCheckBox (this, wxID_ANY, wxT ("A/B"));
155         video_control (_dcp_ab);
156         _sizer->Add (_dcp_ab, 1);
157         _sizer->AddSpacer (0);
158
159         /* STILL-only stuff */
160         {
161                 still_control (add_label_to_sizer (_sizer, this, "Duration"));
162                 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
163                 _still_duration = new wxSpinCtrl (this);
164                 still_control (_still_duration);
165                 s->Add (_still_duration, 1, wxEXPAND);
166                 still_control (add_label_to_sizer (s, this, "s"));
167                 _sizer->Add (s);
168         }
169
170         /* Set up our editing widgets */
171         
172         _left_crop->SetRange (0, 1024);
173         _top_crop->SetRange (0, 1024);
174         _right_crop->SetRange (0, 1024);
175         _bottom_crop->SetRange (0, 1024);
176         _audio_gain->SetRange (-60, 60);
177         _audio_delay->SetRange (-1000, 1000);
178         _still_duration->SetRange (0, 60 * 60);
179
180         vector<Format const *> fmt = Format::all ();
181         for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
182                 _format->Append (std_to_wx ((*i)->name ()));
183         }
184
185         vector<DCPContentType const *> const ct = DCPContentType::all ();
186         for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
187                 _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
188         }
189
190         vector<Scaler const *> const sc = Scaler::all ();
191         for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
192                 _scaler->Append (std_to_wx ((*i)->name()));
193         }
194
195         /* And set their values from the Film */
196         set_film (f);
197         
198         /* Now connect to them, since initial values are safely set */
199         _name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
200         _frames_per_second->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::frames_per_second_changed), 0, this);
201         _format->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
202         _content->Connect (wxID_ANY, wxEVT_COMMAND_FILEPICKER_CHANGED, wxCommandEventHandler (FilmEditor::content_changed), 0, this);
203         _left_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::left_crop_changed), 0, this);
204         _right_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::right_crop_changed), 0, this);
205         _top_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::top_crop_changed), 0, this);
206         _bottom_crop->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::bottom_crop_changed), 0, this);
207         _filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_filters_clicked), 0, this);
208         _scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::scaler_changed), 0, this);
209         _dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (FilmEditor::dcp_content_type_changed), 0, this);
210         _dcp_ab->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::dcp_ab_toggled), 0, this);
211         _audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
212         _audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
213         _still_duration->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::still_duration_changed), 0, this);
214         _change_dcp_range_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::change_dcp_range_clicked), 0, this);
215
216         setup_visibility ();
217 }
218
219 /** Called when the left crop widget has been changed */
220 void
221 FilmEditor::left_crop_changed (wxCommandEvent &)
222 {
223         if (!_film) {
224                 return;
225         }
226
227         _ignore_changes = true;
228         _film->set_left_crop (_left_crop->GetValue ());
229         _ignore_changes = false;
230 }
231
232 /** Called when the right crop widget has been changed */
233 void
234 FilmEditor::right_crop_changed (wxCommandEvent &)
235 {
236         if (!_film) {
237                 return;
238         }
239
240         _ignore_changes = true;
241         _film->set_right_crop (_right_crop->GetValue ());
242         _ignore_changes = false;
243 }
244
245 /** Called when the top crop widget has been changed */
246 void
247 FilmEditor::top_crop_changed (wxCommandEvent &)
248 {
249         if (!_film) {
250                 return;
251         }
252
253         _ignore_changes = true;
254         _film->set_top_crop (_top_crop->GetValue ());
255         _ignore_changes = false;
256 }
257
258 /** Called when the bottom crop value has been changed */
259 void
260 FilmEditor::bottom_crop_changed (wxCommandEvent &)
261 {
262         if (!_film) {
263                 return;
264         }
265
266         _ignore_changes = true;
267         _film->set_bottom_crop (_bottom_crop->GetValue ());
268         _ignore_changes = false;
269 }
270
271 /** Called when the content filename has been changed */
272 void
273 FilmEditor::content_changed (wxCommandEvent &)
274 {
275         if (!_film) {
276                 return;
277         }
278
279         _ignore_changes = true;
280         
281         try {
282                 _film->set_content (wx_to_std (_content->GetPath ()));
283         } catch (std::exception& e) {
284                 _content->SetPath (std_to_wx (_film->directory ()));
285                 stringstream m;
286                 m << "Could not set content: " << e.what() << ".";
287                 error_dialog (this, m.str ());
288         }
289
290         _ignore_changes = false;
291
292         setup_visibility ();
293 }
294
295 /** Called when the DCP A/B switch has been toggled */
296 void
297 FilmEditor::dcp_ab_toggled (wxCommandEvent &)
298 {
299         if (!_film) {
300                 return;
301         }
302         
303         _ignore_changes = true;
304         _film->set_dcp_ab (_dcp_ab->GetValue ());
305         _ignore_changes = false;
306 }
307
308 /** Called when the name widget has been changed */
309 void
310 FilmEditor::name_changed (wxCommandEvent &)
311 {
312         if (!_film) {
313                 return;
314         }
315
316         _ignore_changes = true;
317         _film->set_name (string (_name->GetValue().mb_str()));
318         _ignore_changes = false;
319 }
320
321 /** Called when the metadata stored in the Film object has changed;
322  *  so that we can update the GUI.
323  *  @param p Property of the Film that has changed.
324  */
325 void
326 FilmEditor::film_changed (Film::Property p)
327 {
328         if (!_film || _ignore_changes) {
329                 return;
330         }
331
332         stringstream s;
333                 
334         switch (p) {
335         case Film::CONTENT:
336                 _content->SetPath (std_to_wx (_film->content ()));
337                 setup_visibility ();
338                 break;
339         case Film::FORMAT:
340                 _format->SetSelection (Format::as_index (_film->format ()));
341                 break;
342         case Film::LEFT_CROP:
343                 _left_crop->SetValue (_film->left_crop ());
344                 break;
345         case Film::RIGHT_CROP:
346                 _right_crop->SetValue (_film->right_crop ());
347                 break;
348         case Film::TOP_CROP:
349                 _top_crop->SetValue (_film->top_crop ());
350                 break;
351         case Film::BOTTOM_CROP:
352                 _bottom_crop->SetValue (_film->bottom_crop ());
353                 break;
354         case Film::FILTERS:
355         {
356                 pair<string, string> p = Filter::ffmpeg_strings (_film->filters ());
357                 if (p.first.empty () && p.second.empty ()) {
358                         _filters->SetLabel (_("None"));
359                 } else {
360                         string const b = p.first + " " + p.second;
361                         _filters->SetLabel (std_to_wx (b));
362                 }
363                 _sizer->Layout ();
364                 break;
365         }
366         case Film::NAME:
367                 _name->ChangeValue (std_to_wx (_film->name ()));
368                 break;
369         case Film::FRAMES_PER_SECOND:
370         {
371                 stringstream s;
372                 s << fixed << setprecision(2) << _film->frames_per_second();
373                 _frames_per_second->ChangeValue (std_to_wx (s.str ()));
374                 break;
375         }
376         case Film::AUDIO_CHANNELS:
377         case Film::AUDIO_SAMPLE_RATE:
378                 if (_film->audio_channels() == 0 && _film->audio_sample_rate() == 0) {
379                         _audio->SetLabel (wxT (""));
380                 } else {
381                         s << _film->audio_channels () << " channels, " << _film->audio_sample_rate() << "Hz";
382                         _audio->SetLabel (std_to_wx (s.str ()));
383                 }
384                 break;
385         case Film::SIZE:
386                 if (_film->size().width == 0 && _film->size().height == 0) {
387                         _original_size->SetLabel (wxT (""));
388                 } else {
389                         s << _film->size().width << " x " << _film->size().height;
390                         _original_size->SetLabel (std_to_wx (s.str ()));
391                 }
392                 break;
393         case Film::LENGTH:
394                 if (_film->frames_per_second() > 0 && _film->length() > 0) {
395                         s << _film->length() << " frames; " << seconds_to_hms (_film->length() / _film->frames_per_second());
396                 } else if (_film->length() > 0) {
397                         s << _film->length() << " frames";
398                 } 
399                 _length->SetLabel (std_to_wx (s.str ()));
400                 break;
401         case Film::DCP_CONTENT_TYPE:
402                 _dcp_content_type->SetSelection (DCPContentType::as_index (_film->dcp_content_type ()));
403                 break;
404         case Film::THUMBS:
405                 break;
406         case Film::DCP_FRAMES:
407                 if (_film->dcp_frames() == 0) {
408                         _dcp_range->SetLabel (wxT ("Whole film"));
409                 } else {
410                         stringstream s;
411                         s << "First " << _film->dcp_frames() << " frames";
412                         _dcp_range->SetLabel (std_to_wx (s.str ()));
413                 }
414                 _sizer->Layout ();
415                 break;
416         case Film::DCP_TRIM_ACTION:
417                 break;
418         case Film::DCP_AB:
419                 _dcp_ab->SetValue (_film->dcp_ab ());
420                 break;
421         case Film::SCALER:
422                 _scaler->SetSelection (Scaler::as_index (_film->scaler ()));
423                 break;
424         case Film::AUDIO_GAIN:
425                 _audio_gain->SetValue (_film->audio_gain ());
426                 break;
427         case Film::AUDIO_DELAY:
428                 _audio_delay->SetValue (_film->audio_delay ());
429                 break;
430         case Film::STILL_DURATION:
431                 _still_duration->SetValue (_film->still_duration ());
432                 break;
433         }
434 }
435
436 /** Called when the format widget has been changed */
437 void
438 FilmEditor::format_changed (wxCommandEvent &)
439 {
440         if (!_film) {
441                 return;
442         }
443
444         _ignore_changes = true;
445         int const n = _format->GetSelection ();
446         if (n >= 0) {
447                 _film->set_format (Format::from_index (n));
448         }
449         _ignore_changes = false;
450 }
451
452 /** Called when the DCP content type widget has been changed */
453 void
454 FilmEditor::dcp_content_type_changed (wxCommandEvent &)
455 {
456         if (!_film) {
457                 return;
458         }
459
460         _ignore_changes = true;
461         int const n = _dcp_content_type->GetSelection ();
462         if (n >= 0) {
463                 _film->set_dcp_content_type (DCPContentType::from_index (n));
464         }
465         _ignore_changes = false;
466 }
467
468 /** Sets the Film that we are editing */
469 void
470 FilmEditor::set_film (Film* f)
471 {
472         _film = f;
473
474         set_things_sensitive (_film != 0);
475
476         if (_film) {
477                 _film->Changed.connect (sigc::mem_fun (*this, &FilmEditor::film_changed));
478         }
479
480         if (_film) {
481                 FileChanged (_film->directory ());
482         } else {
483                 FileChanged ("");
484         }
485         
486         film_changed (Film::NAME);
487         film_changed (Film::CONTENT);
488         film_changed (Film::DCP_CONTENT_TYPE);
489         film_changed (Film::FORMAT);
490         film_changed (Film::LEFT_CROP);
491         film_changed (Film::RIGHT_CROP);
492         film_changed (Film::TOP_CROP);
493         film_changed (Film::BOTTOM_CROP);
494         film_changed (Film::FILTERS);
495         film_changed (Film::DCP_FRAMES);
496         film_changed (Film::DCP_TRIM_ACTION);
497         film_changed (Film::DCP_AB);
498         film_changed (Film::SIZE);
499         film_changed (Film::LENGTH);
500         film_changed (Film::FRAMES_PER_SECOND);
501         film_changed (Film::AUDIO_CHANNELS);
502         film_changed (Film::AUDIO_SAMPLE_RATE);
503         film_changed (Film::SCALER);
504         film_changed (Film::AUDIO_GAIN);
505         film_changed (Film::AUDIO_DELAY);
506         film_changed (Film::STILL_DURATION);
507 }
508
509 /** Updates the sensitivity of lots of widgets to a given value.
510  *  @param s true to make sensitive, false to make insensitive.
511  */
512 void
513 FilmEditor::set_things_sensitive (bool s)
514 {
515         _name->Enable (s);
516         _frames_per_second->Enable (s);
517         _format->Enable (s);
518         _content->Enable (s);
519         _left_crop->Enable (s);
520         _right_crop->Enable (s);
521         _top_crop->Enable (s);
522         _bottom_crop->Enable (s);
523         _filters_button->Enable (s);
524         _scaler->Enable (s);
525         _dcp_content_type->Enable (s);
526         _dcp_range->Enable (s);
527         _change_dcp_range_button->Enable (s);
528         _dcp_ab->Enable (s);
529         _audio_gain->Enable (s);
530         _audio_delay->Enable (s);
531         _still_duration->Enable (s);
532 }
533
534 /** Called when the `Edit filters' button has been clicked */
535 void
536 FilmEditor::edit_filters_clicked (wxCommandEvent &)
537 {
538         FilterDialog* d = new FilterDialog (this, _film->filters ());
539         d->ActiveChanged.connect (sigc::mem_fun (*_film, &Film::set_filters));
540         d->ShowModal ();
541         d->Destroy ();
542 }
543
544 /** Called when the scaler widget has been changed */
545 void
546 FilmEditor::scaler_changed (wxCommandEvent &)
547 {
548         if (!_film) {
549                 return;
550         }
551
552         _ignore_changes = true;
553         int const n = _scaler->GetSelection ();
554         if (n >= 0) {
555                 _film->set_scaler (Scaler::from_index (n));
556         }
557         _ignore_changes = false;
558 }
559
560 /** Called when the frames per second widget has been changed */
561 void
562 FilmEditor::frames_per_second_changed (wxCommandEvent &)
563 {
564         if (!_film) {
565                 return;
566         }
567
568         _ignore_changes = true;
569         _film->set_frames_per_second (boost::lexical_cast<float> (wx_to_std (_frames_per_second->GetValue ())));
570         _ignore_changes = false;
571 }
572
573 void
574 FilmEditor::audio_gain_changed (wxCommandEvent &)
575 {
576         if (!_film) {
577                 return;
578         }
579
580         _ignore_changes = true;
581         _film->set_audio_gain (_audio_gain->GetValue ());
582         _ignore_changes = false;
583 }
584
585 void
586 FilmEditor::audio_delay_changed (wxCommandEvent &)
587 {
588         if (!_film) {
589                 return;
590         }
591
592         _ignore_changes = true;
593         _film->set_audio_delay (_audio_delay->GetValue ());
594         _ignore_changes = false;
595 }
596
597 wxControl *
598 FilmEditor::video_control (wxControl* c)
599 {
600         _video_controls.push_back (c);
601         return c;
602 }
603
604 wxControl *
605 FilmEditor::still_control (wxControl* c)
606 {
607         _still_controls.push_back (c);
608         return c;
609 }
610
611 void
612 FilmEditor::setup_visibility ()
613 {
614         ContentType c = VIDEO;
615
616         if (_film) {
617                 c = _film->content_type ();
618         }
619
620         for (list<wxControl*>::iterator i = _video_controls.begin(); i != _video_controls.end(); ++i) {
621                 (*i)->Show (c == VIDEO);
622         }
623
624         for (list<wxControl*>::iterator i = _still_controls.begin(); i != _still_controls.end(); ++i) {
625                 (*i)->Show (c == STILL);
626         }
627
628         _sizer->Layout ();
629 }
630
631 void
632 FilmEditor::still_duration_changed (wxCommandEvent &)
633 {
634         if (!_film) {
635                 return;
636         }
637
638         _ignore_changes = true;
639         _film->set_still_duration (_still_duration->GetValue ());
640         _ignore_changes = false;
641 }
642
643 void
644 FilmEditor::change_dcp_range_clicked (wxCommandEvent &)
645 {
646         DCPRangeDialog* d = new DCPRangeDialog (this, _film);
647         d->Changed.connect (sigc::mem_fun (*this, &FilmEditor::dcp_range_changed));
648         d->ShowModal ();
649 }
650
651 void
652 FilmEditor::dcp_range_changed (int frames, TrimAction action)
653 {
654         _film->set_dcp_frames (frames);
655         _film->set_dcp_trim_action (action);
656 }