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