Don't truncate active_video_frame_rate to an int otherwise setting fade on non-intege...
[dcpomatic.git] / src / wx / video_panel.cc
1 /*
2     Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "filter_dialog.h"
22 #include "video_panel.h"
23 #include "wx_util.h"
24 #include "content_colour_conversion_dialog.h"
25 #include "content_widget.h"
26 #include "content_panel.h"
27 #include "static_text.h"
28 #include "check_box.h"
29 #include "dcpomatic_button.h"
30 #include "lib/filter.h"
31 #include "lib/ffmpeg_content.h"
32 #include "lib/colour_conversion.h"
33 #include "lib/config.h"
34 #include "lib/util.h"
35 #include "lib/ratio.h"
36 #include "lib/frame_rate_change.h"
37 #include "lib/dcp_content.h"
38 #include "lib/video_content.h"
39 #include <wx/spinctrl.h>
40 #include <boost/foreach.hpp>
41 #include <set>
42 #include <iostream>
43
44 using std::vector;
45 using std::string;
46 using std::pair;
47 using std::cout;
48 using std::list;
49 using std::set;
50 using boost::shared_ptr;
51 using boost::dynamic_pointer_cast;
52 using boost::bind;
53 using boost::optional;
54 using namespace dcpomatic;
55
56 static VideoContentScale
57 index_to_scale (int n)
58 {
59         vector<VideoContentScale> scales = VideoContentScale::all ();
60         DCPOMATIC_ASSERT (n >= 0);
61         DCPOMATIC_ASSERT (n < int (scales.size ()));
62         return scales[n];
63 }
64
65 static int
66 scale_to_index (VideoContentScale scale)
67 {
68         vector<VideoContentScale> scales = VideoContentScale::all ();
69         for (size_t i = 0; i < scales.size(); ++i) {
70                 if (scales[i] == scale) {
71                         return i;
72                 }
73         }
74
75         DCPOMATIC_ASSERT (false);
76 }
77
78 VideoPanel::VideoPanel (ContentPanel* p)
79         : ContentSubPanel (p, _("Video"))
80 {
81         _reference = new CheckBox (this, _("Use this DCP's video as OV and make VF"));
82         _reference_note = new StaticText (this, wxT(""));
83         _reference_note->Wrap (200);
84         wxFont font = _reference_note->GetFont();
85         font.SetStyle(wxFONTSTYLE_ITALIC);
86         font.SetPointSize(font.GetPointSize() - 1);
87         _reference_note->SetFont(font);
88
89         _use = new wxCheckBox (this, wxID_ANY, _("Use"));
90
91         _type_label = create_label (this, _("Type"), true);
92         _frame_type = new ContentChoice<VideoContent, VideoFrameType> (
93                 this,
94                 new wxChoice (this, wxID_ANY),
95                 VideoContentProperty::FRAME_TYPE,
96                 &Content::video,
97                 boost::mem_fn (&VideoContent::frame_type),
98                 boost::mem_fn (&VideoContent::set_frame_type),
99                 &caster<int, VideoFrameType>,
100                 &caster<VideoFrameType, int>
101                 );
102
103         _left_crop_label = create_label (this, _("Left crop"), true);
104         _left_crop = new ContentSpinCtrl<VideoContent> (
105                 this,
106                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
107                 VideoContentProperty::CROP,
108                 &Content::video,
109                 boost::mem_fn (&VideoContent::left_crop),
110                 boost::mem_fn (&VideoContent::set_left_crop)
111                 );
112
113         _right_crop_label = create_label (this, _("Right crop"), true);
114         _right_crop = new ContentSpinCtrl<VideoContent> (
115                 this,
116                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
117                 VideoContentProperty::CROP,
118                 &Content::video,
119                 boost::mem_fn (&VideoContent::right_crop),
120                 boost::mem_fn (&VideoContent::set_right_crop)
121                 );
122
123         _top_crop_label = create_label (this, _("Top crop"), true);
124         _top_crop = new ContentSpinCtrl<VideoContent> (
125                 this,
126                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
127                 VideoContentProperty::CROP,
128                 &Content::video,
129                 boost::mem_fn (&VideoContent::top_crop),
130                 boost::mem_fn (&VideoContent::set_top_crop)
131                 );
132
133         _bottom_crop_label = create_label (this, _("Bottom crop"), true);
134         _bottom_crop = new ContentSpinCtrl<VideoContent> (
135                 this,
136                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)),
137                 VideoContentProperty::CROP,
138                 &Content::video,
139                 boost::mem_fn (&VideoContent::bottom_crop),
140                 boost::mem_fn (&VideoContent::set_bottom_crop)
141                 );
142
143         _fade_in_label = create_label (this, _("Fade in"), true);
144         _fade_in = new Timecode<ContentTime> (this);
145
146         _fade_out_label = create_label (this, _("Fade out"), true);
147         _fade_out = new Timecode<ContentTime> (this);
148
149         _scale_to_label = create_label (this, _("Scale to"), true);
150         _scale = new ContentChoice<VideoContent, VideoContentScale> (
151                 this,
152                 new wxChoice (this, wxID_ANY),
153                 VideoContentProperty::SCALE,
154                 &Content::video,
155                 boost::mem_fn (&VideoContent::scale),
156                 boost::mem_fn (&VideoContent::set_scale),
157                 &index_to_scale,
158                 &scale_to_index
159                 );
160
161         wxClientDC dc (this);
162         wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
163         size.SetHeight (-1);
164
165         _filters_label = create_label (this, _("Filters"), true);
166         _filters = new StaticText (this, _("None"), wxDefaultPosition, size);
167         _filters_button = new Button (this, _("Edit..."));
168
169         _colour_conversion_label = create_label (this, _("Colour conversion"), true);
170         _colour_conversion = new wxChoice (this, wxID_ANY, wxDefaultPosition, size);
171         _colour_conversion->Append (_("None"));
172         BOOST_FOREACH (PresetColourConversion const & i, PresetColourConversion::all()) {
173                 _colour_conversion->Append (std_to_wx (i.name));
174         }
175
176         /// TRANSLATORS: translate the word "Custom" here; do not include the "Colour|" prefix
177         _colour_conversion->Append (S_("Colour|Custom"));
178         _edit_colour_conversion_button = new Button (this, _("Edit..."));
179
180         _range_label = create_label (this, _("Range"), true);
181         _range = new wxChoice (this, wxID_ANY);
182         _range->Append (_("Full (JPEG, 0-255)"));
183         _range->Append (_("Video (MPEG, 16-235)"));
184
185         _description = new StaticText (this, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize);
186         _description->SetFont(font);
187
188         _left_crop->wrapped()->SetRange (0, 4096);
189         _top_crop->wrapped()->SetRange (0, 4096);
190         _right_crop->wrapped()->SetRange (0, 4096);
191         _bottom_crop->wrapped()->SetRange (0, 4096);
192
193         _scale->wrapped()->Clear ();
194         BOOST_FOREACH (VideoContentScale const & i, VideoContentScale::all ()) {
195                 _scale->wrapped()->Append (std_to_wx (i.name ()));
196         }
197
198         _frame_type->wrapped()->Append (_("2D"));
199         _frame_type->wrapped()->Append (_("3D"));
200         _frame_type->wrapped()->Append (_("3D left/right"));
201         _frame_type->wrapped()->Append (_("3D top/bottom"));
202         _frame_type->wrapped()->Append (_("3D alternate"));
203         _frame_type->wrapped()->Append (_("3D left only"));
204         _frame_type->wrapped()->Append (_("3D right only"));
205
206         content_selection_changed ();
207
208         _fade_in->Changed.connect (boost::bind (&VideoPanel::fade_in_changed, this));
209         _fade_out->Changed.connect (boost::bind (&VideoPanel::fade_out_changed, this));
210
211         _use->Bind                           (wxEVT_CHECKBOX, boost::bind (&VideoPanel::use_clicked, this));
212         _reference->Bind                     (wxEVT_CHECKBOX, boost::bind (&VideoPanel::reference_clicked, this));
213         _filters_button->Bind                (wxEVT_BUTTON,   boost::bind (&VideoPanel::edit_filters_clicked, this));
214         _colour_conversion->Bind             (wxEVT_CHOICE,   boost::bind (&VideoPanel::colour_conversion_changed, this));
215         _range->Bind                         (wxEVT_CHOICE,   boost::bind (&VideoPanel::range_changed, this));
216         _edit_colour_conversion_button->Bind (wxEVT_BUTTON,   boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
217
218         add_to_grid ();
219 }
220
221 void
222 VideoPanel::add_to_grid ()
223 {
224         bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
225
226         int r = 0;
227
228         _reference->Show (full);
229         _reference_note->Show (full && !_reference_note->GetLabel().IsEmpty());
230
231         if (full) {
232                 wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
233                 reference_sizer->Add (_reference, 0);
234                 reference_sizer->Add (_reference_note, 0);
235                 _grid->Add (reference_sizer, wxGBPosition(r, 0), wxGBSpan(1, 3));
236                 ++r;
237         }
238
239         _use->Show (full);
240         _grid->Add (_use, wxGBPosition(r, 0), wxGBSpan(1, 2));
241         ++r;
242
243         add_label_to_sizer (_grid, _type_label, true, wxGBPosition(r, 0));
244         _frame_type->add (_grid, wxGBPosition(r, 1), wxGBSpan(1, 2));
245         ++r;
246
247         int cr = 0;
248         wxGridBagSizer* crop = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
249         add_label_to_sizer (crop, _left_crop_label, true, wxGBPosition (cr, 0));
250         _left_crop->add (crop, wxGBPosition (cr, 1));
251         add_label_to_sizer (crop, _right_crop_label, true, wxGBPosition (cr, 2));
252         _right_crop->add (crop, wxGBPosition (cr, 3));
253         ++cr;
254         add_label_to_sizer (crop, _top_crop_label, true, wxGBPosition (cr, 0));
255         _top_crop->add (crop, wxGBPosition (cr, 1));
256         add_label_to_sizer (crop, _bottom_crop_label, true, wxGBPosition (cr, 2));
257         _bottom_crop->add (crop, wxGBPosition (cr, 3));
258         _grid->Add (crop, wxGBPosition (r, 0), wxGBSpan (2, 4));
259         r += 2;
260
261         _scale_to_label->Show (full);
262         _scale->show (full);
263         _filters_label->Show (full);
264         _filters->Show (full);
265         _filters_button->Show (full);
266         _colour_conversion_label->Show (full);
267         _colour_conversion->Show (full);
268         _edit_colour_conversion_button->Show (full);
269         _range_label->Show (full);
270         _range->Show (full);
271
272         add_label_to_sizer (_grid, _fade_in_label, true, wxGBPosition (r, 0));
273         _grid->Add (_fade_in, wxGBPosition (r, 1), wxGBSpan (1, 3));
274         ++r;
275
276         add_label_to_sizer (_grid, _fade_out_label, true, wxGBPosition (r, 0));
277         _grid->Add (_fade_out, wxGBPosition (r, 1), wxGBSpan (1, 3));
278         ++r;
279
280         if (full) {
281                 add_label_to_sizer (_grid, _scale_to_label, true, wxGBPosition (r, 0));
282                 _scale->add (_grid, wxGBPosition (r, 1), wxGBSpan (1, 2));
283                 ++r;
284
285                 add_label_to_sizer (_grid, _filters_label, true, wxGBPosition (r, 0));
286                 {
287                         wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
288                         s->Add (_filters, 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
289                         s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
290                         _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
291                 }
292                 ++r;
293
294                 add_label_to_sizer (_grid, _colour_conversion_label, true, wxGBPosition(r, 0));
295                 {
296                         wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
297                         s->Add (_colour_conversion, 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
298                         s->Add (_edit_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL);
299                         _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
300                 }
301                 ++r;
302
303                 add_label_to_sizer (_grid, _range_label, true, wxGBPosition(r, 0));
304                 _grid->Add (_range, wxGBPosition(r, 1), wxGBSpan(1, 2), wxALIGN_CENTER_VERTICAL);
305                 ++r;
306         }
307
308         _grid->Add (_description, wxGBPosition (r, 0), wxGBSpan (1, 4), wxEXPAND | wxALIGN_CENTER_VERTICAL, 6);
309         ++r;
310 }
311
312 void
313 VideoPanel::range_changed ()
314 {
315         ContentList vc = _parent->selected_video ();
316         if (vc.size() != 1) {
317                 return;
318         }
319
320         switch (_range->GetSelection()) {
321         case 0:
322                 vc.front()->video->set_range (VIDEO_RANGE_FULL);
323                 break;
324         case 1:
325                 vc.front()->video->set_range (VIDEO_RANGE_VIDEO);
326                 break;
327         default:
328                 DCPOMATIC_ASSERT (false);
329         }
330 }
331
332
333 void
334 VideoPanel::film_changed (Film::Property property)
335 {
336         switch (property) {
337         case Film::VIDEO_FRAME_RATE:
338         case Film::CONTAINER:
339         case Film::RESOLUTION:
340                 setup_description ();
341                 setup_sensitivity ();
342                 break;
343         case Film::REEL_TYPE:
344         case Film::INTEROP:
345                 setup_sensitivity ();
346                 break;
347         default:
348                 break;
349         }
350 }
351
352 void
353 VideoPanel::film_content_changed (int property)
354 {
355         ContentList vc = _parent->selected_video ();
356         shared_ptr<Content> vcs;
357         shared_ptr<FFmpegContent> fcs;
358         if (!vc.empty ()) {
359                 vcs = vc.front ();
360                 fcs = dynamic_pointer_cast<FFmpegContent> (vcs);
361         }
362
363         if (property == ContentProperty::VIDEO_FRAME_RATE ||
364             property == VideoContentProperty::FRAME_TYPE ||
365             property == VideoContentProperty::CROP ||
366             property == VideoContentProperty::SCALE) {
367                 setup_description ();
368         } else if (property == VideoContentProperty::COLOUR_CONVERSION) {
369                 if (vcs && vcs->video->colour_conversion ()) {
370                         optional<size_t> preset = vcs->video->colour_conversion().get().preset ();
371                         vector<PresetColourConversion> cc = PresetColourConversion::all ();
372                         if (preset) {
373                                 checked_set (_colour_conversion, preset.get() + 1);
374                         } else {
375                                 checked_set (_colour_conversion, cc.size() + 1);
376                         }
377                 } else {
378                         checked_set (_colour_conversion, 0);
379                 }
380
381                 setup_sensitivity ();
382
383         } else if (property == FFmpegContentProperty::FILTERS) {
384                 if (fcs) {
385                         string p = Filter::ffmpeg_string (fcs->filters ());
386                         if (p.empty ()) {
387                                 checked_set (_filters, _("None"));
388                         } else {
389                                 if (p.length() > 25) {
390                                         p = p.substr (0, 25) + "...";
391                                 }
392                                 checked_set (_filters, p);
393                         }
394                 }
395         } else if (property == VideoContentProperty::USE) {
396                 set<bool> check;
397                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
398                         check.insert (i->video->use());
399                 }
400
401                 if (check.size() == 1) {
402                         checked_set (_use, vc.front()->video->use());
403                 } else {
404                         checked_set (_use, false);
405                 }
406
407                 setup_sensitivity ();
408         } else if (property == VideoContentProperty::FADE_IN) {
409                 set<Frame> check;
410                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
411                         check.insert (i->video->fade_in ());
412                 }
413
414                 if (check.size() == 1) {
415                         _fade_in->set (
416                                 ContentTime::from_frames (vc.front()->video->fade_in(), vc.front()->active_video_frame_rate(_parent->film())),
417                                 vc.front()->active_video_frame_rate(_parent->film())
418                                 );
419                 } else {
420                         _fade_in->clear ();
421                 }
422         } else if (property == VideoContentProperty::FADE_OUT) {
423                 set<Frame> check;
424                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
425                         check.insert (i->video->fade_out ());
426                 }
427
428                 if (check.size() == 1) {
429                         _fade_out->set (
430                                 ContentTime::from_frames (vc.front()->video->fade_out(), vc.front()->active_video_frame_rate(_parent->film())),
431                                 vc.front()->active_video_frame_rate(_parent->film())
432                                 );
433                 } else {
434                         _fade_out->clear ();
435                 }
436         } else if (property == DCPContentProperty::REFERENCE_VIDEO) {
437                 if (vc.size() == 1) {
438                         shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (vc.front ());
439                         checked_set (_reference, dcp ? dcp->reference_video () : false);
440                 } else {
441                         checked_set (_reference, false);
442                 }
443
444                 setup_sensitivity ();
445         } else if (property == VideoContentProperty::RANGE) {
446                 if (vcs) {
447                         checked_set (_range, vcs->video->range() == VIDEO_RANGE_FULL ? 0 : 1);
448                 } else {
449                         checked_set (_range, 0);
450                 }
451
452                 setup_sensitivity ();
453         }
454 }
455
456 /** Called when the `Edit filters' button has been clicked */
457 void
458 VideoPanel::edit_filters_clicked ()
459 {
460         FFmpegContentList c = _parent->selected_ffmpeg ();
461         if (c.size() != 1) {
462                 return;
463         }
464
465         FilterDialog* d = new FilterDialog (this, c.front()->filters());
466         d->ActiveChanged.connect (bind (&FFmpegContent::set_filters, c.front(), _1));
467         d->ShowModal ();
468         d->Destroy ();
469 }
470
471 void
472 VideoPanel::setup_description ()
473 {
474         ContentList vc = _parent->selected_video ();
475         if (vc.empty ()) {
476                 checked_set (_description, wxT (""));
477                 return;
478         } else if (vc.size() > 1) {
479                 checked_set (_description, _("Multiple content selected"));
480                 return;
481         }
482
483         string d = vc.front()->video->processing_description (_parent->film());
484         size_t lines = count (d.begin(), d.end(), '\n');
485
486         for (int i = lines; i < 6; ++i) {
487                 d += "\n ";
488         }
489
490         checked_set (_description, d);
491         _sizer->Layout ();
492 }
493
494 void
495 VideoPanel::colour_conversion_changed ()
496 {
497         ContentList vc = _parent->selected_video ();
498         if (vc.size() != 1) {
499                 return;
500         }
501
502         int const s = _colour_conversion->GetSelection ();
503         vector<PresetColourConversion> all = PresetColourConversion::all ();
504
505         if (s == 0) {
506                 vc.front()->video->unset_colour_conversion ();
507         } else if (s == int (all.size() + 1)) {
508                 edit_colour_conversion_clicked ();
509         } else {
510                 vc.front()->video->set_colour_conversion (all[s - 1].conversion);
511         }
512 }
513
514 void
515 VideoPanel::edit_colour_conversion_clicked ()
516 {
517         ContentList vc = _parent->selected_video ();
518         if (vc.size() != 1) {
519                 return;
520         }
521
522         ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->video->yuv ());
523         d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front().conversion));
524         if (d->ShowModal() == wxID_OK) {
525                 vc.front()->video->set_colour_conversion (d->get ());
526         } else {
527                 /* Reset the colour conversion choice */
528                 film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
529         }
530         d->Destroy ();
531 }
532
533 void
534 VideoPanel::content_selection_changed ()
535 {
536         ContentList video_sel = _parent->selected_video ();
537
538         _frame_type->set_content (video_sel);
539         _left_crop->set_content (video_sel);
540         _right_crop->set_content (video_sel);
541         _top_crop->set_content (video_sel);
542         _bottom_crop->set_content (video_sel);
543         _scale->set_content (video_sel);
544
545         film_content_changed (ContentProperty::VIDEO_FRAME_RATE);
546         film_content_changed (VideoContentProperty::CROP);
547         film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
548         film_content_changed (VideoContentProperty::FADE_IN);
549         film_content_changed (VideoContentProperty::FADE_OUT);
550         film_content_changed (VideoContentProperty::RANGE);
551         film_content_changed (VideoContentProperty::USE);
552         film_content_changed (FFmpegContentProperty::FILTERS);
553         film_content_changed (DCPContentProperty::REFERENCE_VIDEO);
554
555         setup_sensitivity ();
556 }
557
558 void
559 VideoPanel::setup_sensitivity ()
560 {
561         ContentList sel = _parent->selected ();
562
563         shared_ptr<DCPContent> dcp;
564         if (sel.size() == 1) {
565                 dcp = dynamic_pointer_cast<DCPContent> (sel.front ());
566         }
567
568         string why_not;
569         bool const can_reference = dcp && dcp->can_reference_video (_parent->film(), why_not);
570         wxString cannot;
571         if (why_not.empty()) {
572                 cannot = _("Cannot reference this DCP's video.");
573         } else {
574                 cannot = _("Cannot reference this DCP's video: ") + std_to_wx(why_not);
575         }
576         setup_refer_button (_reference, _reference_note, dcp, can_reference, cannot);
577
578         bool const enable = !_reference->GetValue() && _use->GetValue();
579
580         _use->Enable (!_reference->GetValue());
581
582         if (!enable) {
583                 _frame_type->wrapped()->Enable (false);
584                 _left_crop->wrapped()->Enable (false);
585                 _right_crop->wrapped()->Enable (false);
586                 _top_crop->wrapped()->Enable (false);
587                 _bottom_crop->wrapped()->Enable (false);
588                 _fade_in->Enable (false);
589                 _fade_out->Enable (false);
590                 _scale->wrapped()->Enable (false);
591                 _description->Enable (false);
592                 _filters->Enable (false);
593                 _filters_button->Enable (false);
594                 _colour_conversion->Enable (false);
595                 _range->Enable (false);
596         } else {
597                 ContentList video_sel = _parent->selected_video ();
598                 FFmpegContentList ffmpeg_sel = _parent->selected_ffmpeg ();
599                 bool const single = video_sel.size() == 1;
600
601                 _frame_type->wrapped()->Enable (true);
602                 _left_crop->wrapped()->Enable (true);
603                 _right_crop->wrapped()->Enable (true);
604                 _top_crop->wrapped()->Enable (true);
605                 _bottom_crop->wrapped()->Enable (true);
606                 _fade_in->Enable (!video_sel.empty ());
607                 _fade_out->Enable (!video_sel.empty ());
608                 _scale->wrapped()->Enable (true);
609                 _description->Enable (true);
610                 _filters->Enable (true);
611                 _filters_button->Enable (single && !ffmpeg_sel.empty ());
612                 _colour_conversion->Enable (single && !video_sel.empty ());
613                 _range->Enable (single && !video_sel.empty());
614         }
615
616         ContentList vc = _parent->selected_video ();
617         shared_ptr<Content> vcs;
618         if (!vc.empty ()) {
619                 vcs = vc.front ();
620         }
621
622         if (vcs && vcs->video->colour_conversion ()) {
623                 _edit_colour_conversion_button->Enable (!vcs->video->colour_conversion().get().preset());
624         } else {
625                 _edit_colour_conversion_button->Enable (false);
626         }
627 }
628
629 void
630 VideoPanel::fade_in_changed ()
631 {
632         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video ()) {
633                 double const vfr = i->active_video_frame_rate (_parent->film());
634                 i->video->set_fade_in (_fade_in->get(vfr).frames_round(vfr));
635         }
636 }
637
638 void
639 VideoPanel::fade_out_changed ()
640 {
641         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video ()) {
642                 double const vfr = i->active_video_frame_rate (_parent->film());
643                 i->video->set_fade_out (_fade_out->get(vfr).frames_round(vfr));
644         }
645 }
646
647 void
648 VideoPanel::use_clicked ()
649 {
650         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video()) {
651                 i->video->set_use (_use->GetValue());
652         }
653 }
654
655 void
656 VideoPanel::reference_clicked ()
657 {
658         ContentList c = _parent->selected ();
659         if (c.size() != 1) {
660                 return;
661         }
662
663         shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (c.front ());
664         if (!d) {
665                 return;
666         }
667
668         d->set_reference_video (_reference->GetValue ());
669 }