Arrows to go forward/back one frame.
authorCarl Hetherington <cth@carlh.net>
Fri, 23 Mar 2018 01:21:46 +0000 (01:21 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 23 Mar 2018 01:21:46 +0000 (01:21 +0000)
ChangeLog
src/tools/dcpomatic.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h

index a4855f2975b2f31509c1ba638adfec9cadff76b7..d126e0fb50a53fbad381c77f474bf4130dbf676a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
 2018-03-23  Carl Hetherington  <cth@carlh.net>
 
-       * Add space shortcut to start/stop playback and
-       Ctrl-T to open timeline (#1201).
+       * Add space shortcut to start/stop playback, arrows to go
+       back/forward one frame and Ctrl-T to open timeline (#1201).
 
 2018-03-22  Carl Hetherington  <cth@carlh.net>
 
index 4d888b3fa7806e9cb347ba4f12f51bf87a8522f9..0fffe6cfc4aa195f062483cf4144103e1ae53173 100644 (file)
@@ -220,7 +220,9 @@ enum {
        ID_add_file,
        ID_remove,
        ID_start_stop,
-       ID_timeline
+       ID_timeline,
+       ID_back_frame,
+       ID_forward_frame
 };
 
 class DOMFrame : public wxFrame
@@ -330,22 +332,26 @@ public:
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
-               int accelerators = 5;
+               int accelerators = 7;
 #else
-               int accelerators = 4;
+               int accelerators = 6;
 #endif
                wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators];
                accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
                accel[1].Set (wxACCEL_NORMAL, WXK_DELETE, ID_remove);
                accel[2].Set (wxACCEL_NORMAL, WXK_SPACE, ID_start_stop);
                accel[3].Set (wxACCEL_CTRL, static_cast<int>('T'), ID_timeline);
+               accel[4].Set (wxACCEL_NORMAL, WXK_LEFT, ID_back_frame);
+               accel[5].Set (wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame);
 #ifdef __WXOSX__
-               accel[4].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_EXIT);
+               accel[6].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_EXIT);
 #endif
                Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::remove_clicked, this, _1), ID_remove);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::start_stop_pressed, this), ID_start_stop);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::timeline_pressed, this), ID_timeline);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::back_frame, this), ID_back_frame);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame);
                wxAcceleratorTable accel_table (accelerators, accel);
                SetAcceleratorTable (accel_table);
                delete[] accel;
@@ -1221,6 +1227,16 @@ private:
                _film_editor->content_panel()->timeline_clicked ();
        }
 
+       void back_frame ()
+       {
+               _film_viewer->back_frame ();
+       }
+
+       void forward_frame ()
+       {
+               _film_viewer->forward_frame ();
+       }
+
        FilmEditor* _film_editor;
        FilmViewer* _film_viewer;
        VideoWaveformDialog* _video_waveform_dialog;
index 635a564c6558c241c04b62301203d7e8d5528a52..5cd09048cb987d2d856f0f26acd03751a8e1a1e2 100644 (file)
@@ -580,7 +580,7 @@ FilmViewer::active_jobs_changed (optional<string> j)
 }
 
 DCPTime
-FilmViewer::nudge_amount (wxMouseEvent& ev)
+FilmViewer::nudge_amount (wxKeyboardState& ev)
 {
        DCPTime amount = one_video_frame ();
 
@@ -619,17 +619,35 @@ FilmViewer::rewind_clicked (wxMouseEvent& ev)
 }
 
 void
-FilmViewer::back_clicked (wxMouseEvent& ev)
+FilmViewer::back_frame ()
+{
+       if (!_film) {
+               return;
+       }
+
+       go_to (_video_position - one_video_frame());
+}
+
+void
+FilmViewer::forward_frame ()
+{
+       if (!_film) {
+               return;
+       }
+
+       go_to (_video_position + one_video_frame());
+}
+
+void
+FilmViewer::back_clicked (wxKeyboardState& ev)
 {
        go_to (_video_position - nudge_amount (ev));
-       ev.Skip ();
 }
 
 void
-FilmViewer::forward_clicked (wxMouseEvent& ev)
+FilmViewer::forward_clicked (wxKeyboardState& ev)
 {
        go_to (_video_position + nudge_amount (ev));
-       ev.Skip ();
 }
 
 void
index 190396601821bc5aac7ccdf58b3ab5e9ecb856f2..eed6c283d8ca811ac568e7d35c27f937001fd781 100644 (file)
@@ -72,6 +72,9 @@ public:
                return _playing;
        }
 
+       void back_frame ();
+       void forward_frame ();
+
        int audio_callback (void* out, unsigned int frames);
 
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
@@ -87,8 +90,8 @@ private:
        void check_play_state ();
        void active_jobs_changed (boost::optional<std::string>);
        void rewind_clicked (wxMouseEvent &);
-       void back_clicked (wxMouseEvent &);
-       void forward_clicked (wxMouseEvent &);
+       void back_clicked (wxKeyboardState& s);
+       void forward_clicked (wxKeyboardState &);
        void player_changed (int, bool);
        void update_position_label ();
        void update_position_slider ();
@@ -98,7 +101,7 @@ private:
        void refresh_panel ();
        void setup_sensitivity ();
        void film_changed (Film::Property);
-       DCPTime nudge_amount (wxMouseEvent &);
+       DCPTime nudge_amount (wxKeyboardState &);
        void timecode_clicked ();
        void frame_number_clicked ();
        void go_to (DCPTime t);