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