+ film_content_changed (ContentProperty::VIDEO_FRAME_RATE);
+}
+
+void
+TimingPanel::film_changed (Film::Property p)
+{
+ if (p == Film::VIDEO_FRAME_RATE) {
+ update_full_length ();
+ update_play_length ();
+ }
+}
+
+void
+TimingPanel::trim_start_to_playhead_clicked ()
+{
+ shared_ptr<const Film> film = _parent->film ();
+ DCPTime const ph = _viewer->position().floor (film->video_frame_rate ());
+ optional<DCPTime> new_ph;
+
+ _viewer->set_coalesce_player_changes (true);
+
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ if (i->position() < ph && ph < i->end ()) {
+ FrameRateChange const frc = film->active_frame_rate_change (i->position ());
+ i->set_trim_start (i->trim_start() + ContentTime (ph - i->position (), frc));
+ new_ph = i->position ();
+ }
+ }
+
+ if (new_ph) {
+ _viewer->set_position (new_ph.get());
+ }
+
+ _viewer->set_coalesce_player_changes (false);
+}
+
+void
+TimingPanel::trim_end_to_playhead_clicked ()
+{
+ shared_ptr<const Film> film = _parent->film ();
+ DCPTime const ph = _viewer->position().floor (film->video_frame_rate ());
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ if (i->position() < ph && ph < i->end ()) {
+ FrameRateChange const frc = film->active_frame_rate_change (i->position ());
+ i->set_trim_end (ContentTime (i->position() + i->full_length() - ph - DCPTime::from_frames (1, frc.dcp), frc) - i->trim_start());
+ }
+ }
+}
+
+void
+TimingPanel::setup_sensitivity ()
+{
+ bool const e = !_parent->selected().empty ();
+
+ _position->Enable (e);
+ _move_to_start_of_reel->Enable (e);
+ _full_length->Enable (e);
+ _trim_start->Enable (e);
+ _trim_end->Enable (e);
+ _play_length->Enable (e);
+ _video_frame_rate->Enable (e);
+
+ DCPTime const ph = _viewer->position ();
+ bool any_over_ph = false;
+ BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
+ if (i->position() <= ph && ph < i->end()) {
+ any_over_ph = true;
+ }
+ }
+
+ _trim_start_to_playhead->Enable (any_over_ph);
+ _trim_end_to_playhead->Enable (any_over_ph);
+}
+
+void
+TimingPanel::move_to_start_of_reel_clicked ()
+{
+ /* Find common position of all selected content, if it exists */
+
+ optional<DCPTime> position;
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ if (!position) {
+ position = i->position();
+ } else {
+ if (position.get() != i->position()) {
+ position.reset ();
+ break;
+ }
+ }
+ }
+
+ MoveToDialog* d = new MoveToDialog (this, position, _parent->film());
+
+ if (d->ShowModal() == wxID_OK) {
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ i->set_position (d->position ());
+ }
+ }
+ d->Destroy ();