Keep current frame visible when trimming start. Don't trim the current
authorCarl Hetherington <cth@carlh.net>
Mon, 9 Nov 2015 00:22:46 +0000 (00:22 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 9 Nov 2015 00:22:46 +0000 (00:22 +0000)
frame with "trim after current position" (#737).

ChangeLog
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/timing_panel.cc

index 04c78f074728f1921330d4f51d0bb3c41303b25b..38d0ab14a3e1684e45b792cc5a8788ecd14cf99e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-11-09  Carl Hetherington  <cth@carlh.net>
+
+       * Keep same frame visible after trimming content start (#737).
+
+       * Trim frames after the current one with "trim after current", leaving
+       the current frame in (#737).
+
 2015-11-08  Carl Hetherington  <cth@carlh.net>
 
        * Fix bad layout in the audio tab (#738).
index ead1cf9aee227717d26413ada1071c4e4ff16182..e3f76cbc75960ea94ca3f1218c09b29c61b329ed 100644 (file)
@@ -70,6 +70,7 @@ FilmViewer::FilmViewer (wxWindow* p)
        , _frame_number (new wxStaticText (this, wxID_ANY, wxT("")))
        , _timecode (new wxStaticText (this, wxID_ANY, wxT("")))
        , _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
+       , _ignore_player_changes (false)
        , _last_get_accurate (true)
 {
 #ifndef __WXOSX__
@@ -431,7 +432,7 @@ FilmViewer::forward_clicked ()
 void
 FilmViewer::player_changed (bool frequent)
 {
-       if (frequent) {
+       if (frequent || _ignore_player_changes) {
                return;
        }
 
@@ -469,3 +470,18 @@ FilmViewer::refresh ()
 {
        get (_position, _last_get_accurate);
 }
+
+void
+FilmViewer::set_position (DCPTime p)
+{
+       _position = p;
+       get (_position, true);
+       update_position_label ();
+       update_position_slider ();
+}
+
+void
+FilmViewer::set_ignore_player_changes (bool i)
+{
+       _ignore_player_changes = i;
+}
index 4776d24b48cc37976a5036e3e991056117e5b9de..4c7e3ba33c4d8a606c0a4ca92c1230311ce157b9 100644 (file)
@@ -44,6 +44,9 @@ public:
                return _position;
        }
 
+       void set_position (DCPTime p);
+       void set_ignore_player_changes (bool i);
+
        void refresh ();
 
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
@@ -80,6 +83,7 @@ private:
        wxStaticText* _timecode;
        wxToggleButton* _play_button;
        wxTimer _timer;
+       bool _ignore_player_changes;
 
        boost::shared_ptr<const Image> _frame;
        DCPTime _position;
index f05268f92434d79626268eebfe936716a9bf35a9..bb0547b9c62368553d8c58bd2c08b3f66476fad6 100644 (file)
@@ -37,6 +37,7 @@ using std::string;
 using std::set;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
+using boost::optional;
 
 TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer)
        /* horrid hack for apparent lack of context support with wxWidgets i18n code */
@@ -401,12 +402,23 @@ void
 TimingPanel::trim_start_to_playhead_clicked ()
 {
        DCPTime const ph = _viewer->position ();
+       optional<DCPTime> new_ph;
+
+       _viewer->set_ignore_player_changes (true);
+
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
                if (i->position() < ph && ph < i->end ()) {
                        FrameRateChange const frc = _parent->film()->active_frame_rate_change (i->position ());
                        i->set_trim_start (i->trim_start() + ContentTime (ph - i->position (), frc));
+                       new_ph = i->position ();
                }
        }
+
+       _viewer->set_ignore_player_changes (false);
+
+       if (new_ph) {
+               _viewer->set_position (new_ph.get());
+       }
 }
 
 void
@@ -416,7 +428,7 @@ TimingPanel::trim_end_to_playhead_clicked ()
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
                if (i->position() < ph && ph < i->end ()) {
                        FrameRateChange const frc = _parent->film()->active_frame_rate_change (i->position ());
-                       i->set_trim_end (ContentTime (i->position() + i->full_length() - ph, frc) - i->trim_start());
+                       i->set_trim_end (ContentTime (i->position() + i->full_length() - ph - DCPTime::from_frames (1, frc.dcp), frc) - i->trim_start());
                }
 
        }