973eacf5d901f48db06e334dd985b846e3959686
[dcpomatic.git] / src / wx / timing_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 "timing_panel.h"
22 #include "wx_util.h"
23 #include "film_viewer.h"
24 #include "timecode.h"
25 #include "content_panel.h"
26 #include "move_to_dialog.h"
27 #include "static_text.h"
28 #include "dcpomatic_button.h"
29 #include "lib/content.h"
30 #include "lib/image_content.h"
31 #include "lib/text_content.h"
32 #include "lib/dcp_subtitle_content.h"
33 #include "lib/audio_content.h"
34 #include "lib/string_text_file_content.h"
35 #include "lib/video_content.h"
36 #include "lib/dcp_content.h"
37 #include "lib/ffmpeg_content.h"
38 #include <dcp/locale_convert.h>
39 #if defined(__WXGTK20__) && !defined(__WXGTK3__)
40 #define TIMING_PANEL_ALIGNMENT_HACK 1
41 #include <gtk/gtk.h>
42 #endif
43 #include <boost/foreach.hpp>
44 #include <set>
45 #include <iostream>
46
47 using std::cout;
48 using std::string;
49 using std::set;
50 using boost::shared_ptr;
51 using boost::weak_ptr;
52 using boost::dynamic_pointer_cast;
53 using boost::optional;
54 using dcp::locale_convert;
55 using namespace dcpomatic;
56
57 TimingPanel::TimingPanel (ContentPanel* p, weak_ptr<FilmViewer> viewer)
58         /* horrid hack for apparent lack of context support with wxWidgets i18n code */
59         /// TRANSLATORS: translate the word "Timing" here; do not include the "Timing|" prefix
60         : ContentSubPanel (p, S_("Timing|Timing"))
61         , _viewer (viewer)
62         , _film_content_changed_suspender (boost::bind(&TimingPanel::film_content_changed, this, _1))
63 {
64         wxSize size = TimecodeBase::size (this);
65
66         for (int i = 0; i < 3; ++i) {
67                 _colon[i] = create_label (this, wxT(":"), false);
68         }
69
70         //// TRANSLATORS: this is an abbreviation for "hours"
71         _h_label = new StaticText (this, _("h"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
72 #ifdef TIMING_PANEL_ALIGNMENT_HACK
73         /* Hack to work around failure to centre text on GTK */
74         gtk_label_set_line_wrap (GTK_LABEL(_h_label->GetHandle()), FALSE);
75 #endif
76         //// TRANSLATORS: this is an abbreviation for "minutes"
77         _m_label = new StaticText (this, _("m"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
78 #ifdef TIMING_PANEL_ALIGNMENT_HACK
79         gtk_label_set_line_wrap (GTK_LABEL (_m_label->GetHandle()), FALSE);
80 #endif
81         //// TRANSLATORS: this is an abbreviation for "seconds"
82         _s_label = new StaticText (this, _("s"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
83 #ifdef TIMING_PANEL_ALIGNMENT_HACK
84         gtk_label_set_line_wrap (GTK_LABEL(_s_label->GetHandle()), FALSE);
85 #endif
86         //// TRANSLATORS: this is an abbreviation for "frames"
87         _f_label = new StaticText (this, _("f"), wxDefaultPosition, size, wxALIGN_CENTRE_HORIZONTAL);
88 #ifdef TIMING_PANEL_ALIGNMENT_HACK
89         gtk_label_set_line_wrap (GTK_LABEL(_f_label->GetHandle()), FALSE);
90 #endif
91
92         _position_label = create_label (this, _("Position"), true);
93         _position = new Timecode<DCPTime> (this);
94         _move_to_start_of_reel = new Button (this, _("Move to start of reel"));
95         _full_length_label = create_label (this, _("Full length"), true);
96         _full_length = new Timecode<DCPTime> (this);
97         _trim_start_label = create_label (this, _("Trim from start"), true);
98         _trim_start = new Timecode<ContentTime> (this);
99         _trim_start_to_playhead = new Button (this, _("Trim up to current position"));
100         _trim_end_label = create_label (this, _("Trim from end"), true);
101         _trim_end = new Timecode<ContentTime> (this);
102         _trim_end_to_playhead = new Button (this, _("Trim after current position"));
103         _play_length_label = create_label (this, _("Play length"), true);
104         _play_length = new Timecode<DCPTime> (this);
105
106         _video_frame_rate_label = create_label (this, _("Video frame rate"), true);
107         _video_frame_rate = new wxTextCtrl (this, wxID_ANY);
108         _set_video_frame_rate = new Button (this, _("Set"));
109         _set_video_frame_rate->Enable (false);
110
111         /* We can't use Wrap() here as it doesn't work with markup:
112          * http://trac.wxwidgets.org/ticket/13389
113          */
114
115         wxString in = _("<i>Only change this if the content's frame rate has been read incorrectly.</i>");
116         wxString out;
117         int const width = 20;
118         int current = 0;
119         for (size_t i = 0; i < in.Length(); ++i) {
120                 if (in[i] == ' ' && current >= width) {
121                         out += '\n';
122                         current = 0;
123                 } else {
124                         out += in[i];
125                         ++current;
126                 }
127         }
128
129         _tip = new StaticText (this, wxT (""));
130         _tip->SetLabelMarkup (out);
131 #ifdef DCPOMATIC_OSX
132         /* Hack to stop hidden text on some versions of OS X */
133         _tip->SetMinSize (wxSize (-1, 256));
134 #endif
135
136         _position->Changed.connect    (boost::bind (&TimingPanel::position_changed, this));
137         _move_to_start_of_reel->Bind  (wxEVT_BUTTON, boost::bind (&TimingPanel::move_to_start_of_reel_clicked, this));
138         _full_length->Changed.connect (boost::bind (&TimingPanel::full_length_changed, this));
139         _trim_start->Changed.connect  (boost::bind (&TimingPanel::trim_start_changed, this));
140         _trim_start_to_playhead->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_start_to_playhead_clicked, this));
141         _trim_end->Changed.connect    (boost::bind (&TimingPanel::trim_end_changed, this));
142         _trim_end_to_playhead->Bind   (wxEVT_BUTTON, boost::bind (&TimingPanel::trim_end_to_playhead_clicked, this));
143         _play_length->Changed.connect (boost::bind (&TimingPanel::play_length_changed, this));
144         _video_frame_rate->Bind       (wxEVT_TEXT, boost::bind (&TimingPanel::video_frame_rate_changed, this));
145         _set_video_frame_rate->Bind   (wxEVT_BUTTON, boost::bind (&TimingPanel::set_video_frame_rate, this));
146
147         shared_ptr<FilmViewer> fv = _viewer.lock ();
148         DCPOMATIC_ASSERT (fv);
149         fv->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this));
150
151         setup_sensitivity ();
152         add_to_grid ();
153 }
154
155 void
156 TimingPanel::add_to_grid ()
157 {
158         bool const full = Config::instance()->interface_complexity() == Config::INTERFACE_FULL;
159
160         int r = 0;
161
162         wxSizer* labels = new wxBoxSizer (wxHORIZONTAL);
163         labels->Add (_h_label, 1, wxEXPAND);
164         add_label_to_sizer (labels, _colon[0], false);
165         labels->Add (_m_label, 1, wxEXPAND);
166         add_label_to_sizer (labels, _colon[1], false);
167         labels->Add (_s_label, 1, wxEXPAND);
168         add_label_to_sizer (labels, _colon[2], false);
169         labels->Add (_f_label, 1, wxEXPAND);
170         _grid->Add (labels, wxGBPosition(r, 1));
171         ++r;
172
173         add_label_to_sizer (_grid, _position_label, true, wxGBPosition(r, 0));
174         _grid->Add (_position, wxGBPosition(r, 1));
175         ++r;
176
177         _move_to_start_of_reel->Show (full);
178         _full_length_label->Show (full);
179         _full_length->Show (full);
180         _play_length_label->Show (full);
181         _play_length->Show (full);
182         _video_frame_rate_label->Show (full);
183         _video_frame_rate->Show (full);
184         _set_video_frame_rate->Show (full);
185         _tip->Show (full);
186
187         if (full) {
188                 _grid->Add (_move_to_start_of_reel, wxGBPosition(r, 1));
189                 ++r;
190
191                 add_label_to_sizer (_grid, _full_length_label, true, wxGBPosition(r, 0));
192                 _grid->Add (_full_length, wxGBPosition(r, 1));
193                 ++r;
194         }
195
196         add_label_to_sizer (_grid, _trim_start_label, true, wxGBPosition(r, 0));
197         _grid->Add (_trim_start, wxGBPosition(r, 1));
198         ++r;
199
200         _grid->Add (_trim_start_to_playhead, wxGBPosition(r, 1));
201         ++r;
202
203         add_label_to_sizer (_grid, _trim_end_label, true, wxGBPosition(r, 0));
204         _grid->Add (_trim_end, wxGBPosition(r, 1));
205         ++r;
206
207         _grid->Add (_trim_end_to_playhead, wxGBPosition(r, 1));
208         ++r;
209
210         if (full) {
211                 add_label_to_sizer (_grid, _play_length_label, true, wxGBPosition(r, 0));
212                 _grid->Add (_play_length, wxGBPosition(r, 1));
213                 ++r;
214
215                 {
216                         add_label_to_sizer (_grid, _video_frame_rate_label, true, wxGBPosition(r, 0));
217                         wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
218                         s->Add (_video_frame_rate, 1, wxEXPAND);
219                         s->Add (_set_video_frame_rate, 0, wxLEFT | wxRIGHT, 8);
220                         _grid->Add (s, wxGBPosition(r, 1), wxGBSpan(1, 2));
221                 }
222                 ++r;
223
224                 _grid->Add (_tip, wxGBPosition(r, 1), wxGBSpan(1, 2));
225         }
226
227         /* Completely speculative fix for #891 */
228         _grid->Layout ();
229 }
230
231 void
232 TimingPanel::update_full_length ()
233 {
234         set<DCPTime> check;
235         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
236                 check.insert (i->full_length(_parent->film()));
237         }
238
239         if (check.size() == 1) {
240                 _full_length->set (_parent->selected().front()->full_length(_parent->film()), _parent->film()->video_frame_rate());
241         } else {
242                 _full_length->clear ();
243         }
244 }
245
246 void
247 TimingPanel::update_play_length ()
248 {
249         set<DCPTime> check;
250         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
251                 check.insert (i->length_after_trim(_parent->film()));
252         }
253
254         if (check.size() == 1) {
255                 _play_length->set (_parent->selected().front()->length_after_trim(_parent->film()), _parent->film()->video_frame_rate());
256         } else {
257                 _play_length->clear ();
258         }
259 }
260
261 void
262 TimingPanel::film_content_changed (int property)
263 {
264         if (_film_content_changed_suspender.check(property)) {
265                 return;
266         }
267
268         int const film_video_frame_rate = _parent->film()->video_frame_rate ();
269
270         /* Here we check to see if we have exactly one different value of various
271            properties, and fill the controls with that value if so.
272         */
273
274         if (property == ContentProperty::POSITION) {
275
276                 set<DCPTime> check;
277                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
278                         check.insert (i->position ());
279                 }
280
281                 if (check.size() == 1) {
282                         _position->set (_parent->selected().front()->position(), film_video_frame_rate);
283                 } else {
284                         _position->clear ();
285                 }
286
287         } else if (
288                 property == ContentProperty::LENGTH ||
289                 property == ContentProperty::VIDEO_FRAME_RATE ||
290                 property == VideoContentProperty::FRAME_TYPE
291                 ) {
292
293                 update_full_length ();
294
295         } else if (property == ContentProperty::TRIM_START) {
296
297                 set<ContentTime> check;
298                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
299                         check.insert (i->trim_start ());
300                 }
301
302                 if (check.size() == 1) {
303                         _trim_start->set (_parent->selected().front()->trim_start (), film_video_frame_rate);
304                 } else {
305                         _trim_start->clear ();
306                 }
307
308         } else if (property == ContentProperty::TRIM_END) {
309
310                 set<ContentTime> check;
311                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
312                         check.insert (i->trim_end ());
313                 }
314
315                 if (check.size() == 1) {
316                         _trim_end->set (_parent->selected().front()->trim_end (), film_video_frame_rate);
317                 } else {
318                         _trim_end->clear ();
319                 }
320         }
321
322         if (
323                 property == ContentProperty::LENGTH ||
324                 property == ContentProperty::TRIM_START ||
325                 property == ContentProperty::TRIM_END ||
326                 property == ContentProperty::VIDEO_FRAME_RATE ||
327                 property == VideoContentProperty::FRAME_TYPE
328                 ) {
329
330                 update_play_length ();
331         }
332
333         if (property == ContentProperty::VIDEO_FRAME_RATE) {
334                 set<double> check_vc;
335                 shared_ptr<const Content> content;
336                 int count_ac = 0;
337                 int count_sc = 0;
338                 BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
339                         if (i->video && i->video_frame_rate()) {
340                                 check_vc.insert (i->video_frame_rate().get());
341                                 content = i;
342                         }
343                         if (i->audio && i->video_frame_rate()) {
344                                 ++count_ac;
345                                 content = i;
346                         }
347                         if (!i->text.empty() && i->video_frame_rate()) {
348                                 ++count_sc;
349                                 content = i;
350                         }
351
352                 }
353
354                 bool const single_frame_image_content = content && dynamic_pointer_cast<const ImageContent> (content) && content->number_of_paths() == 1;
355
356                 if ((check_vc.size() == 1 || count_ac == 1 || count_sc == 1) && !single_frame_image_content) {
357                         checked_set (_video_frame_rate, locale_convert<string> (content->video_frame_rate().get(), 5));
358                         _video_frame_rate->Enable (true);
359                 } else {
360                         checked_set (_video_frame_rate, wxT (""));
361                         _video_frame_rate->Enable (false);
362                 }
363         }
364
365         bool have_still = false;
366         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
367                 shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (i);
368                 if (ic && ic->still ()) {
369                         have_still = true;
370                 }
371         }
372
373         _full_length->set_editable (have_still);
374         _play_length->set_editable (!have_still);
375         _set_video_frame_rate->Enable (false);
376         setup_sensitivity ();
377 }
378
379 void
380 TimingPanel::position_changed ()
381 {
382         DCPTime const pos = _position->get (_parent->film()->video_frame_rate ());
383         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
384                 i->set_position (_parent->film(), pos);
385         }
386 }
387
388 void
389 TimingPanel::full_length_changed ()
390 {
391         int const vfr = _parent->film()->video_frame_rate ();
392         Frame const len = _full_length->get (vfr).frames_round (vfr);
393         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
394                 shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (i);
395                 if (ic && ic->still ()) {
396                         ic->video->set_length (len);
397                 }
398         }
399 }
400
401 void
402 TimingPanel::trim_start_changed ()
403 {
404         shared_ptr<FilmViewer> fv = _viewer.lock ();
405         if (!fv) {
406                 return;
407         }
408
409         DCPTime const ph = fv->position ();
410
411         fv->set_coalesce_player_changes (true);
412
413         shared_ptr<Content> ref;
414         optional<FrameRateChange> ref_frc;
415         optional<DCPTime> ref_ph;
416
417         Suspender::Block bl = _film_content_changed_suspender.block ();
418         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
419                 if (i->position() <= ph && ph < i->end(_parent->film())) {
420                         /* The playhead is in i.  Use it as a reference to work out
421                            where to put the playhead post-trim; we're trying to keep the playhead
422                            at the same frame of content that we're looking at pre-trim.
423                         */
424                         ref = i;
425                         ref_frc = _parent->film()->active_frame_rate_change (i->position ());
426                         ref_ph = ph - i->position() + DCPTime (i->trim_start(), ref_frc.get());
427                 }
428
429                 ContentTime const trim = _trim_start->get (i->video_frame_rate().get_value_or(_parent->film()->video_frame_rate()));
430                 i->set_trim_start (trim);
431         }
432
433         if (ref) {
434                 fv->seek (max(DCPTime(), ref_ph.get() + ref->position() - DCPTime(ref->trim_start(), ref_frc.get())), true);
435         }
436
437         fv->set_coalesce_player_changes (false);
438 }
439
440 void
441 TimingPanel::trim_end_changed ()
442 {
443         shared_ptr<FilmViewer> fv = _viewer.lock ();
444         if (!fv) {
445                 return;
446         }
447
448         fv->set_coalesce_player_changes (true);
449
450         Suspender::Block bl = _film_content_changed_suspender.block ();
451         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
452                 ContentTime const trim = _trim_end->get (i->video_frame_rate().get_value_or(_parent->film()->video_frame_rate()));
453                 i->set_trim_end (trim);
454         }
455
456         /* XXX: maybe playhead-off-the-end-of-the-film should be handled elsewhere */
457         if (fv->position() >= _parent->film()->length()) {
458                 fv->seek (_parent->film()->length() - DCPTime::from_frames(1, _parent->film()->video_frame_rate()), true);
459         }
460
461         fv->set_coalesce_player_changes (false);
462 }
463
464 void
465 TimingPanel::play_length_changed ()
466 {
467         DCPTime const play_length = _play_length->get (_parent->film()->video_frame_rate());
468         Suspender::Block bl = _film_content_changed_suspender.block ();
469         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
470                 FrameRateChange const frc = _parent->film()->active_frame_rate_change (i->position ());
471                 i->set_trim_end (
472                         ContentTime (max(DCPTime(), i->full_length(_parent->film()) - play_length), frc) - i->trim_start()
473                         );
474         }
475 }
476
477 void
478 TimingPanel::video_frame_rate_changed ()
479 {
480         bool enable = true;
481         if (_video_frame_rate->GetValue() == wxT("")) {
482                 /* No frame rate has been entered; if the user clicks "set" now it would unset the video
483                    frame rate in the selected content.  This can't be allowed for some content types.
484                 */
485                 BOOST_FOREACH (shared_ptr<Content> i, _parent->selected()) {
486                         if (
487                                 dynamic_pointer_cast<DCPContent>(i) ||
488                                 dynamic_pointer_cast<FFmpegContent>(i)
489                                 ) {
490                                 enable = false;
491                         }
492                 }
493         }
494
495         _set_video_frame_rate->Enable (enable);
496 }
497
498 void
499 TimingPanel::set_video_frame_rate ()
500 {
501         optional<double> fr;
502         if (_video_frame_rate->GetValue() != wxT("")) {
503                 fr = locale_convert<double> (wx_to_std (_video_frame_rate->GetValue ()));
504         }
505         Suspender::Block bl = _film_content_changed_suspender.block ();
506         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
507                 if (fr) {
508                         i->set_video_frame_rate (*fr);
509                 } else {
510                         i->unset_video_frame_rate ();
511                 }
512         }
513
514         _set_video_frame_rate->Enable (false);
515 }
516
517 void
518 TimingPanel::content_selection_changed ()
519 {
520         setup_sensitivity ();
521
522         film_content_changed (ContentProperty::POSITION);
523         film_content_changed (ContentProperty::LENGTH);
524         film_content_changed (ContentProperty::TRIM_START);
525         film_content_changed (ContentProperty::TRIM_END);
526         film_content_changed (ContentProperty::VIDEO_FRAME_RATE);
527 }
528
529 void
530 TimingPanel::film_changed (Film::Property p)
531 {
532         if (p == Film::VIDEO_FRAME_RATE) {
533                 update_full_length ();
534                 update_play_length ();
535         }
536 }
537
538 void
539 TimingPanel::trim_start_to_playhead_clicked ()
540 {
541         shared_ptr<FilmViewer> fv = _viewer.lock ();
542         if (!fv) {
543                 return;
544         }
545
546         shared_ptr<const Film> film = _parent->film ();
547         DCPTime const ph = fv->position().floor (film->video_frame_rate ());
548         optional<DCPTime> new_ph;
549
550         fv->set_coalesce_player_changes (true);
551
552         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
553                 if (i->position() < ph && ph < i->end(film)) {
554                         FrameRateChange const frc = film->active_frame_rate_change (i->position());
555                         i->set_trim_start (i->trim_start() + ContentTime (ph - i->position(), frc));
556                         new_ph = i->position ();
557                 }
558         }
559
560         if (new_ph) {
561                 fv->seek (new_ph.get(), true);
562         }
563
564         fv->set_coalesce_player_changes (false);
565 }
566
567 void
568 TimingPanel::trim_end_to_playhead_clicked ()
569 {
570         shared_ptr<FilmViewer> fv = _viewer.lock ();
571         if (!fv) {
572                 return;
573         }
574
575         shared_ptr<const Film> film = _parent->film ();
576         DCPTime const ph = fv->position().floor (film->video_frame_rate ());
577         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
578                 if (i->position() < ph && ph < i->end(film)) {
579                         FrameRateChange const frc = film->active_frame_rate_change (i->position ());
580                         i->set_trim_end (ContentTime(i->position() + i->full_length(film) - ph - DCPTime::from_frames(1, frc.dcp), frc) - i->trim_start());
581                 }
582         }
583 }
584
585 void
586 TimingPanel::setup_sensitivity ()
587 {
588         bool const e = !_parent->selected().empty ();
589
590         _position->Enable (e);
591         _move_to_start_of_reel->Enable (e);
592         _full_length->Enable (e);
593         _trim_start->Enable (e);
594         _trim_end->Enable (e);
595         _play_length->Enable (e);
596         _video_frame_rate->Enable (e);
597
598         shared_ptr<FilmViewer> fv = _viewer.lock ();
599         DCPOMATIC_ASSERT (fv);
600         DCPTime const ph = fv->position ();
601         bool any_over_ph = false;
602         BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
603                 if (i->position() <= ph && ph < i->end(_parent->film())) {
604                         any_over_ph = true;
605                 }
606         }
607
608         _trim_start_to_playhead->Enable (any_over_ph);
609         _trim_end_to_playhead->Enable (any_over_ph);
610 }
611
612 void
613 TimingPanel::move_to_start_of_reel_clicked ()
614 {
615         /* Find common position of all selected content, if it exists */
616
617         optional<DCPTime> position;
618         BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
619                 if (!position) {
620                         position = i->position();
621                 } else {
622                         if (position.get() != i->position()) {
623                                 position.reset ();
624                                 break;
625                         }
626                 }
627         }
628
629         MoveToDialog* d = new MoveToDialog (this, position, _parent->film());
630
631         if (d->ShowModal() == wxID_OK) {
632                 BOOST_FOREACH (shared_ptr<Content> i, _parent->selected()) {
633                         i->set_position (_parent->film(), d->position());
634                 }
635         }
636         d->Destroy ();
637 }