X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftiming_panel.cc;h=a29240f8dbaf3cd2eea395c133dc885ff0cc918b;hb=80400212e939dc2f3b987cb6df57709929aa5178;hp=9f5aa78ead191be6e0434205d20e0834fdb3a99d;hpb=294704d07de1fd6981362d85a26e4a83a6ef08fa;p=dcpomatic.git diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 9f5aa78ea..a29240f8d 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -27,7 +27,7 @@ #include "lib/raw_convert.h" #include "lib/subtitle_content.h" #include "lib/dcp_subtitle_content.h" -#include "lib/subrip_content.h" +#include "lib/text_subtitle_content.h" #include #include #include @@ -324,17 +324,49 @@ TimingPanel::full_length_changed () void TimingPanel::trim_start_changed () { + DCPTime const ph = _viewer->position (); + + _viewer->set_coalesce_player_changes (true); + + shared_ptr ref; + optional ref_frc; + optional ref_ph; BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + if (i->position() <= ph && ph < i->end()) { + /* The playhead is in i. Use it as a reference to work out + where to put the playhead post-trim; we're trying to keep the playhead + at the same frame of content that we're looking at pre-trim. + */ + ref = i; + ref_frc = _parent->film()->active_frame_rate_change (i->position ()); + ref_ph = ph - i->position() + DCPTime (i->trim_start(), ref_frc.get()); + } + i->set_trim_start (_trim_start->get (_parent->film()->video_frame_rate ())); } + + if (ref) { + _viewer->set_position (max (DCPTime(), ref_ph.get() + ref->position() - DCPTime (ref->trim_start(), ref_frc.get()))); + } + + _viewer->set_coalesce_player_changes (false); } void TimingPanel::trim_end_changed () { + _viewer->set_coalesce_player_changes (true); + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { i->set_trim_end (_trim_end->get (_parent->film()->video_frame_rate ())); } + + /* XXX: maybe playhead-off-the-end-of-the-film should be handled elsewhere */ + if (_viewer->position() >= _parent->film()->length()) { + _viewer->set_position (_parent->film()->length() - DCPTime::from_frames (1, _parent->film()->video_frame_rate())); + } + + _viewer->set_coalesce_player_changes (true); } void @@ -361,13 +393,13 @@ TimingPanel::set_video_frame_rate () BOOST_FOREACH (shared_ptr i, _parent->selected ()) { shared_ptr vc = dynamic_pointer_cast (i); shared_ptr dsc = dynamic_pointer_cast (i); - shared_ptr ssc = dynamic_pointer_cast (i); + shared_ptr tsc = dynamic_pointer_cast (i); if (vc) { vc->set_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); } else if (dsc) { dsc->set_subtitle_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); - } else if (ssc) { - ssc->set_subtitle_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); + } else if (tsc) { + tsc->set_subtitle_video_frame_rate (raw_convert (wx_to_std (_video_frame_rate->GetValue ()))); } _set_video_frame_rate->Enable (false); } @@ -401,7 +433,7 @@ TimingPanel::trim_start_to_playhead_clicked () DCPTime const ph = _viewer->position (); optional new_ph; - _viewer->set_ignore_player_changes (true); + _viewer->set_coalesce_player_changes (true); BOOST_FOREACH (shared_ptr i, _parent->selected ()) { if (i->position() < ph && ph < i->end ()) { @@ -411,11 +443,11 @@ TimingPanel::trim_start_to_playhead_clicked () } } - _viewer->set_ignore_player_changes (false); - if (new_ph) { _viewer->set_position (new_ph.get()); } + + _viewer->set_coalesce_player_changes (false); } void