From 83cc718cc4f38bc2a9cc8cd62ed570415c5ba289 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 23 Mar 2018 01:21:46 +0000 Subject: [PATCH] Arrows to go forward/back one frame. --- ChangeLog | 4 ++-- src/tools/dcpomatic.cc | 24 ++++++++++++++++++++---- src/wx/film_viewer.cc | 28 +++++++++++++++++++++++----- src/wx/film_viewer.h | 9 ++++++--- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4855f297..d126e0fb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ 2018-03-23 Carl Hetherington - * 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 diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 4d888b3fa..0fffe6cfc 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -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('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('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('W'), wxID_EXIT); + accel[6].Set (wxACCEL_CTRL, static_cast('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; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 635a564c6..5cd09048c 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -580,7 +580,7 @@ FilmViewer::active_jobs_changed (optional 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 diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 190396601..eed6c283d 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -72,6 +72,9 @@ public: return _playing; } + void back_frame (); + void forward_frame (); + int audio_callback (void* out, unsigned int frames); boost::signals2::signal)> ImageChanged; @@ -87,8 +90,8 @@ private: void check_play_state (); void active_jobs_changed (boost::optional); 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); -- 2.30.2