Fix colour conversion choice on GTK3.
[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 <boost/unordered_set.hpp>
42 #include <boost/functional/hash.hpp>
43 #include <set>
44 #include <iostream>
45
46 using std::vector;
47 using std::string;
48 using std::pair;
49 using std::cout;
50 using std::list;
51 using std::set;
52 using boost::shared_ptr;
53 using boost::dynamic_pointer_cast;
54 using boost::bind;
55 using boost::optional;
56 #if BOOST_VERSION >= 106100
57 using namespace boost::placeholders;
58 #endif
59
60 static VideoContentScale
61 index_to_scale (int n)
62 {
63         vector<VideoContentScale> scales = VideoContentScale::all ();
64         DCPOMATIC_ASSERT (n >= 0);
65         DCPOMATIC_ASSERT (n < int (scales.size ()));
66         return scales[n];
67 }
68
69 static int
70 scale_to_index (VideoContentScale scale)
71 {
72         vector<VideoContentScale> scales = VideoContentScale::all ();
73         for (size_t i = 0; i < scales.size(); ++i) {
74                 if (scales[i] == scale) {
75                         return i;
76                 }
77         }
78
79         DCPOMATIC_ASSERT (false);
80 }
81
82 VideoPanel::VideoPanel (ContentPanel* p)
83         : ContentSubPanel (p, _("Video"))
84 {
85         _reference = new CheckBox (this, _("Use this DCP's video as OV and make VF"));
86         _reference_note = new StaticText (this, wxT(""));
87         _reference_note->Wrap (200);
88         wxFont font = _reference_note->GetFont();
89         font.SetStyle(wxFONTSTYLE_ITALIC);
90         font.SetPointSize(font.GetPointSize() - 1);
91         _reference_note->SetFont(font);
92
93         _type_label = create_label (this, _("Type"), true);
94         _frame_type = new ContentChoice<VideoContent, VideoFrameType> (
95                 this,
96                 new wxChoice (this, wxID_ANY),
97                 VideoContentProperty::FRAME_TYPE,
98                 &Content::video,
99                 boost::mem_fn (&VideoContent::frame_type),
100                 boost::mem_fn (&VideoContent::set_frame_type),
101                 &caster<int, VideoFrameType>,
102                 &caster<VideoFrameType, int>
103                 );
104
105         _crop_label = create_label (this, _("Crop"), true);
106
107 #ifdef __WXGTK3__
108         int const crop_width = 128;
109 #else
110         int const crop_width = 56;
111 #endif
112
113         _left_crop_label = create_label (this, _("Left"), true);
114         _left_crop = new ContentSpinCtrl<VideoContent> (
115                 this,
116                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (crop_width, -1)),
117                 VideoContentProperty::CROP,
118                 &Content::video,
119                 boost::mem_fn (&VideoContent::left_crop),
120                 boost::mem_fn (&VideoContent::set_left_crop)
121                 );
122
123         _right_crop_label = create_label (this, _("Right"), true);
124         _right_crop = new ContentSpinCtrl<VideoContent> (
125                 this,
126                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (crop_width, -1)),
127                 VideoContentProperty::CROP,
128                 &Content::video,
129                 boost::mem_fn (&VideoContent::right_crop),
130                 boost::mem_fn (&VideoContent::set_right_crop)
131                 );
132
133         _top_crop_label = create_label (this, _("Top"), true);
134         _top_crop = new ContentSpinCtrl<VideoContent> (
135                 this,
136                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (crop_width, -1)),
137                 VideoContentProperty::CROP,
138                 &Content::video,
139                 boost::mem_fn (&VideoContent::top_crop),
140                 boost::mem_fn (&VideoContent::set_top_crop)
141                 );
142
143         _bottom_crop_label = create_label (this, _("Bottom"), true);
144         _bottom_crop = new ContentSpinCtrl<VideoContent> (
145                 this,
146                 new wxSpinCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (crop_width, -1)),
147                 VideoContentProperty::CROP,
148                 &Content::video,
149                 boost::mem_fn (&VideoContent::bottom_crop),
150                 boost::mem_fn (&VideoContent::set_bottom_crop)
151                 );
152
153         _fade_in_label = create_label (this, _("Fade in"), true);
154         _fade_in = new Timecode<ContentTime> (this);
155
156         _fade_out_label = create_label (this, _("Fade out"), true);
157         _fade_out = new Timecode<ContentTime> (this);
158
159         _scale_to_label = create_label (this, _("Scale to"), true);
160         _scale = new ContentChoice<VideoContent, VideoContentScale> (
161                 this,
162                 new wxChoice (this, wxID_ANY),
163                 VideoContentProperty::SCALE,
164                 &Content::video,
165                 boost::mem_fn (&VideoContent::scale),
166                 boost::mem_fn (&VideoContent::set_scale),
167                 &index_to_scale,
168                 &scale_to_index
169                 );
170
171         wxClientDC dc (this);
172         wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
173 #ifdef __WXGTK3__
174         size.SetWidth (size.GetWidth() + 64);
175 #endif
176         size.SetHeight (-1);
177
178         _filters_label = create_label (this, _("Filters"), true);
179         _filters = new StaticText (this, _("None"), wxDefaultPosition, size);
180         _filters_button = new Button (this, _("Edit..."));
181
182         _colour_conversion_label = create_label (this, _("Colour conversion"), true);
183         _colour_conversion = new wxChoice (this, wxID_ANY, wxDefaultPosition, size);
184         _colour_conversion->Append (_("None"));
185         BOOST_FOREACH (PresetColourConversion const & i, PresetColourConversion::all()) {
186                 _colour_conversion->Append (std_to_wx (i.name));
187         }
188
189         /// TRANSLATORS: translate the word "Custom" here; do not include the "Colour|" prefix
190         _colour_conversion->Append (S_("Colour|Custom"));
191         _edit_colour_conversion_button = new Button (this, _("Edit..."));
192
193         _description = new StaticText (this, wxT ("\n \n \n \n \n"), wxDefaultPosition, wxDefaultSize);
194         _description->SetFont(font);
195
196         _left_crop->wrapped()->SetRange (0, 4096);
197         _top_crop->wrapped()->SetRange (0, 4096);
198         _right_crop->wrapped()->SetRange (0, 4096);
199         _bottom_crop->wrapped()->SetRange (0, 4096);
200
201         _scale->wrapped()->Clear ();
202         BOOST_FOREACH (VideoContentScale const & i, VideoContentScale::all ()) {
203                 _scale->wrapped()->Append (std_to_wx (i.name ()));
204         }
205
206         _frame_type->wrapped()->Append (_("2D"));
207         _frame_type->wrapped()->Append (_("3D"));
208         _frame_type->wrapped()->Append (_("3D left/right"));
209         _frame_type->wrapped()->Append (_("3D top/bottom"));
210         _frame_type->wrapped()->Append (_("3D alternate"));
211         _frame_type->wrapped()->Append (_("3D left only"));
212         _frame_type->wrapped()->Append (_("3D right only"));
213
214         content_selection_changed ();
215
216         _fade_in->Changed.connect (boost::bind (&VideoPanel::fade_in_changed, this));
217         _fade_out->Changed.connect (boost::bind (&VideoPanel::fade_out_changed, this));
218
219         _reference->Bind                     (wxEVT_CHECKBOX, boost::bind (&VideoPanel::reference_clicked, this));
220         _filters_button->Bind                (wxEVT_BUTTON,   boost::bind (&VideoPanel::edit_filters_clicked, this));
221         _colour_conversion->Bind             (wxEVT_CHOICE,   boost::bind (&VideoPanel::colour_conversion_changed, this));
222         _edit_colour_conversion_button->Bind (wxEVT_BUTTON,   boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
223
224         add_to_grid ();
225 }
226
227 void
228 VideoPanel::add_to_grid ()
229 {
230         bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
231
232         int r = 0;
233
234         _reference->Show (full);
235         _reference_note->Show (full);
236
237         if (full) {
238                 wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
239                 reference_sizer->Add (_reference, 0);
240                 reference_sizer->Add (_reference_note, 0);
241                 _grid->Add (reference_sizer, wxGBPosition(r, 0), wxGBSpan(1, 3));
242                 ++r;
243         }
244
245         add_label_to_sizer (_grid, _type_label, true, wxGBPosition(r, 0));
246         _frame_type->add (_grid, wxGBPosition(r, 1), wxGBSpan(1, 2));
247         ++r;
248
249         int cr = 0;
250         wxGridBagSizer* crop = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
251         add_label_to_sizer (crop, _left_crop_label, true, wxGBPosition (cr, 0));
252         _left_crop->add (crop, wxGBPosition (cr, 1));
253 #ifdef __WXGTK3__
254         ++cr;
255         add_label_to_sizer (crop, _right_crop_label, true, wxGBPosition (cr, 0));
256         _right_crop->add (crop, wxGBPosition (cr, 1));
257 #else
258         add_label_to_sizer (crop, _right_crop_label, true, wxGBPosition (cr, 2));
259         _right_crop->add (crop, wxGBPosition (cr, 3));
260 #endif
261         ++cr;
262         add_label_to_sizer (crop, _top_crop_label, true, wxGBPosition (cr, 0));
263         _top_crop->add (crop, wxGBPosition (cr, 1));
264 #ifdef __WXGTK3__
265         ++cr;
266         add_label_to_sizer (crop, _bottom_crop_label, true, wxGBPosition (cr, 0));
267         _bottom_crop->add (crop, wxGBPosition (cr, 1));
268 #else
269         add_label_to_sizer (crop, _bottom_crop_label, true, wxGBPosition (cr, 2));
270         _bottom_crop->add (crop, wxGBPosition (cr, 3));
271 #endif
272         add_label_to_sizer (_grid, _crop_label, true, wxGBPosition(r, 0));
273         _grid->Add (crop, wxGBPosition(r, 1));
274         ++r;
275
276         _scale_to_label->Show (full);
277         _scale->show (full);
278         _filters_label->Show (full);
279         _filters->Show (full);
280         _filters_button->Show (full);
281         _colour_conversion_label->Show (full);
282         _colour_conversion->Show (full);
283         _edit_colour_conversion_button->Show (full);
284
285         add_label_to_sizer (_grid, _fade_in_label, true, wxGBPosition (r, 0));
286         _grid->Add (_fade_in, wxGBPosition (r, 1), wxGBSpan (1, 3));
287         ++r;
288
289         add_label_to_sizer (_grid, _fade_out_label, true, wxGBPosition (r, 0));
290         _grid->Add (_fade_out, wxGBPosition (r, 1), wxGBSpan (1, 3));
291         ++r;
292
293         if (full) {
294                 add_label_to_sizer (_grid, _scale_to_label, true, wxGBPosition (r, 0));
295                 _scale->add (_grid, wxGBPosition (r, 1), wxGBSpan (1, 2));
296                 ++r;
297
298                 add_label_to_sizer (_grid, _filters_label, true, wxGBPosition (r, 0));
299                 {
300                         wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
301                         s->Add (_filters, 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
302                         s->Add (_filters_button, 0, wxALIGN_CENTER_VERTICAL);
303                         _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
304                 }
305                 ++r;
306
307                 add_label_to_sizer (_grid, _colour_conversion_label, true, wxGBPosition(r, 0));
308                 {
309                         wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
310                         s->Add (_colour_conversion, 1, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxRIGHT, 6);
311                         s->Add (_edit_colour_conversion_button, 0, wxALIGN_CENTER_VERTICAL);
312                         _grid->Add (s, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
313                 }
314                 ++r;
315         }
316
317         _grid->Add (_description, wxGBPosition (r, 0), wxGBSpan (1, 4), wxEXPAND | wxALIGN_CENTER_VERTICAL, 6);
318         ++r;
319 }
320
321
322 void
323 VideoPanel::film_changed (Film::Property property)
324 {
325         switch (property) {
326         case Film::VIDEO_FRAME_RATE:
327         case Film::CONTAINER:
328         case Film::RESOLUTION:
329                 setup_description ();
330                 setup_sensitivity ();
331                 break;
332         case Film::REEL_TYPE:
333         case Film::INTEROP:
334                 setup_sensitivity ();
335                 break;
336         default:
337                 break;
338         }
339 }
340
341 std::size_t
342 hash_value (boost::optional<ColourConversion> const & c)
343 {
344         boost::hash<string> hasher;
345         if (!c) {
346                 return hasher ("none");
347         }
348         return hasher (c->identifier());
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                 boost::unordered_set<optional<ColourConversion> > check;
370                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
371                         check.insert (i->video->colour_conversion());
372                 }
373
374                 /* Remove any "Many" entry that we might have added previously.  There should
375                  * be entries for each preset plus one for "None" and one for "Custom".
376                  */
377                 vector<PresetColourConversion> cc = PresetColourConversion::all ();
378                 if (_colour_conversion->GetCount() > cc.size() + 2) {
379                         _colour_conversion->Delete (_colour_conversion->GetCount() - 1);
380                 }
381
382                 if (check.size() == 1) {
383                         if (vcs && vcs->video->colour_conversion ()) {
384                                 optional<size_t> preset = vcs->video->colour_conversion().get().preset ();
385                                 if (preset) {
386                                         checked_set (_colour_conversion, preset.get() + 1);
387                                 } else {
388                                         checked_set (_colour_conversion, cc.size() + 1);
389                                 }
390                         } else {
391                                 checked_set (_colour_conversion, 0);
392                         }
393                 } else if (check.size() > 1) {
394                         /* Add a "many" entry and select it as an indication that multiple different
395                          * colour conversions are present in the selection.
396                          */
397                         _colour_conversion->Append (_("Many"));
398                         checked_set (_colour_conversion, _colour_conversion->GetCount() - 1);
399                 }
400
401                 setup_sensitivity ();
402
403         } else if (property == FFmpegContentProperty::FILTERS) {
404                 if (fcs) {
405                         string p = Filter::ffmpeg_string (fcs->filters ());
406                         if (p.empty ()) {
407                                 checked_set (_filters, _("None"));
408                         } else {
409                                 if (p.length() > 25) {
410                                         p = p.substr (0, 25) + "...";
411                                 }
412                                 checked_set (_filters, p);
413                         }
414                 }
415         } else if (property == VideoContentProperty::FADE_IN) {
416                 set<Frame> check;
417                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
418                         check.insert (i->video->fade_in ());
419                 }
420
421                 if (check.size() == 1) {
422                         _fade_in->set (
423                                 ContentTime::from_frames (vc.front()->video->fade_in(), vc.front()->active_video_frame_rate(_parent->film())),
424                                 vc.front()->active_video_frame_rate(_parent->film())
425                                 );
426                 } else {
427                         _fade_in->clear ();
428                 }
429         } else if (property == VideoContentProperty::FADE_OUT) {
430                 set<Frame> check;
431                 BOOST_FOREACH (shared_ptr<const Content> i, vc) {
432                         check.insert (i->video->fade_out ());
433                 }
434
435                 if (check.size() == 1) {
436                         _fade_out->set (
437                                 ContentTime::from_frames (vc.front()->video->fade_out(), vc.front()->active_video_frame_rate(_parent->film())),
438                                 vc.front()->active_video_frame_rate(_parent->film())
439                                 );
440                 } else {
441                         _fade_out->clear ();
442                 }
443         } else if (property == DCPContentProperty::REFERENCE_VIDEO) {
444                 if (vc.size() == 1) {
445                         shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (vc.front ());
446                         checked_set (_reference, dcp ? dcp->reference_video () : false);
447                 } else {
448                         checked_set (_reference, false);
449                 }
450
451                 setup_sensitivity ();
452         }
453 }
454
455 /** Called when the `Edit filters' button has been clicked */
456 void
457 VideoPanel::edit_filters_clicked ()
458 {
459         FFmpegContentList c = _parent->selected_ffmpeg ();
460         if (c.size() != 1) {
461                 return;
462         }
463
464         FilterDialog* d = new FilterDialog (this, c.front()->filters());
465         d->ActiveChanged.connect (bind (&FFmpegContent::set_filters, c.front(), _1));
466         d->ShowModal ();
467         d->Destroy ();
468 }
469
470 void
471 VideoPanel::setup_description ()
472 {
473         ContentList vc = _parent->selected_video ();
474         if (vc.empty ()) {
475                 checked_set (_description, wxT (""));
476                 return;
477         } else if (vc.size() > 1) {
478                 checked_set (_description, _("Multiple content selected"));
479                 return;
480         }
481
482         string d = vc.front()->video->processing_description (_parent->film());
483         size_t lines = count (d.begin(), d.end(), '\n');
484
485         for (int i = lines; i < 6; ++i) {
486                 d += "\n ";
487         }
488
489         checked_set (_description, d);
490         _sizer->Layout ();
491 }
492
493 void
494 VideoPanel::colour_conversion_changed ()
495 {
496         ContentList vc = _parent->selected_video ();
497
498         int const s = _colour_conversion->GetSelection ();
499         vector<PresetColourConversion> all = PresetColourConversion::all ();
500
501         if (s == int(all.size() + 1)) {
502                 edit_colour_conversion_clicked ();
503         } else {
504                 BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video()) {
505                         if (s == 0) {
506                                 i->video->unset_colour_conversion ();
507                         } else if (s != int(all.size() + 2)) {
508                                 i->video->set_colour_conversion (all[s - 1].conversion);
509                         }
510                 }
511         }
512 }
513
514 void
515 VideoPanel::edit_colour_conversion_clicked ()
516 {
517         ContentList vc = _parent->selected_video ();
518
519         ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->video->yuv ());
520         d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front().conversion));
521         if (d->ShowModal() == wxID_OK) {
522                 BOOST_FOREACH (shared_ptr<Content> i, vc) {
523                         i->video->set_colour_conversion (d->get ());
524                 }
525         } else {
526                 /* Reset the colour conversion choice */
527                 film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
528         }
529         d->Destroy ();
530 }
531
532 void
533 VideoPanel::content_selection_changed ()
534 {
535         ContentList video_sel = _parent->selected_video ();
536
537         _frame_type->set_content (video_sel);
538         _left_crop->set_content (video_sel);
539         _right_crop->set_content (video_sel);
540         _top_crop->set_content (video_sel);
541         _bottom_crop->set_content (video_sel);
542         _scale->set_content (video_sel);
543
544         film_content_changed (ContentProperty::VIDEO_FRAME_RATE);
545         film_content_changed (VideoContentProperty::CROP);
546         film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
547         film_content_changed (VideoContentProperty::FADE_IN);
548         film_content_changed (VideoContentProperty::FADE_OUT);
549         film_content_changed (FFmpegContentProperty::FILTERS);
550         film_content_changed (DCPContentProperty::REFERENCE_VIDEO);
551
552         setup_sensitivity ();
553 }
554
555 void
556 VideoPanel::setup_sensitivity ()
557 {
558         ContentList sel = _parent->selected ();
559
560         shared_ptr<DCPContent> dcp;
561         if (sel.size() == 1) {
562                 dcp = dynamic_pointer_cast<DCPContent> (sel.front ());
563         }
564
565         string why_not;
566         bool const can_reference = dcp && dcp->can_reference_video (_parent->film(), why_not);
567         setup_refer_button (_reference, _reference_note, dcp, can_reference, why_not);
568
569         if (_reference->GetValue ()) {
570                 _frame_type->wrapped()->Enable (false);
571                 _left_crop->wrapped()->Enable (false);
572                 _right_crop->wrapped()->Enable (false);
573                 _top_crop->wrapped()->Enable (false);
574                 _bottom_crop->wrapped()->Enable (false);
575                 _fade_in->Enable (false);
576                 _fade_out->Enable (false);
577                 _scale->wrapped()->Enable (false);
578                 _description->Enable (false);
579                 _filters->Enable (false);
580                 _filters_button->Enable (false);
581                 _colour_conversion->Enable (false);
582         } else {
583                 ContentList video_sel = _parent->selected_video ();
584                 FFmpegContentList ffmpeg_sel = _parent->selected_ffmpeg ();
585                 bool const single = video_sel.size() == 1;
586
587                 _frame_type->wrapped()->Enable (true);
588                 _left_crop->wrapped()->Enable (true);
589                 _right_crop->wrapped()->Enable (true);
590                 _top_crop->wrapped()->Enable (true);
591                 _bottom_crop->wrapped()->Enable (true);
592                 _fade_in->Enable (!video_sel.empty ());
593                 _fade_out->Enable (!video_sel.empty ());
594                 _scale->wrapped()->Enable (true);
595                 _description->Enable (true);
596                 _filters->Enable (true);
597                 _filters_button->Enable (single && !ffmpeg_sel.empty ());
598                 _colour_conversion->Enable (!video_sel.empty());
599         }
600
601         ContentList vc = _parent->selected_video ();
602         shared_ptr<Content> vcs;
603         if (!vc.empty ()) {
604                 vcs = vc.front ();
605         }
606
607         if (vcs && vcs->video->colour_conversion ()) {
608                 _edit_colour_conversion_button->Enable (!vcs->video->colour_conversion().get().preset());
609         } else {
610                 _edit_colour_conversion_button->Enable (false);
611         }
612 }
613
614 void
615 VideoPanel::fade_in_changed ()
616 {
617         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video ()) {
618                 double const vfr = i->active_video_frame_rate (_parent->film());
619                 i->video->set_fade_in (_fade_in->get(vfr).frames_round(vfr));
620         }
621 }
622
623 void
624 VideoPanel::fade_out_changed ()
625 {
626         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_video ()) {
627                 double const vfr = i->active_video_frame_rate (_parent->film());
628                 i->video->set_fade_out (_fade_out->get(vfr).frames_round(vfr));
629         }
630 }
631
632 void
633 VideoPanel::reference_clicked ()
634 {
635         ContentList c = _parent->selected ();
636         if (c.size() != 1) {
637                 return;
638         }
639
640         shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (c.front ());
641         if (!d) {
642                 return;
643         }
644
645         d->set_reference_video (_reference->GetValue ());
646 }