Add space shortcut to start/stop playback (#1201).
authorCarl Hetherington <cth@carlh.net>
Fri, 23 Mar 2018 00:28:40 +0000 (00:28 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 23 Mar 2018 00:28:40 +0000 (00:28 +0000)
ChangeLog
src/tools/dcpomatic.cc
src/tools/dcpomatic_player.cc
src/wx/film_viewer.h

index 73f38490180511197524c8aee8949472fc4bef2f..9c59092e90cbdcf585b9ff9d8b636077520402cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-03-23  Carl Hetherington  <cth@carlh.net>
+
+       * Add space shortcut to start/stop playback (#1201).
+
 2018-03-22  Carl Hetherington  <cth@carlh.net>
 
        * Allow CPL selection in player (#1239).
 2018-03-22  Carl Hetherington  <cth@carlh.net>
 
        * Allow CPL selection in player (#1239).
index 2285cccffe8f5b079833eb42f6d00602d9ef2857..982e38e67cdc3213046f8a958db40007ca688fcd 100644 (file)
@@ -218,7 +218,8 @@ enum {
        ID_help_report_a_problem,
        /* IDs for shortcuts (with no associated menu item) */
        ID_add_file,
        ID_help_report_a_problem,
        /* IDs for shortcuts (with no associated menu item) */
        ID_add_file,
-       ID_remove
+       ID_remove,
+       ID_start_stop
 };
 
 class DOMFrame : public wxFrame
 };
 
 class DOMFrame : public wxFrame
@@ -328,18 +329,20 @@ public:
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
-               int accelerators = 3;
+               int accelerators = 4;
 #else
 #else
-               int accelerators = 2;
+               int accelerators = 3;
 #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);
 #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);
 #ifdef __WXOSX__
 #ifdef __WXOSX__
-               accel[2].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_EXIT);
+               accel[3].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);
 #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);
                wxAcceleratorTable accel_table (accelerators, accel);
                SetAcceleratorTable (accel_table);
                delete[] accel;
                wxAcceleratorTable accel_table (accelerators, accel);
                SetAcceleratorTable (accel_table);
                delete[] accel;
@@ -1201,6 +1204,15 @@ private:
                _update_news_requested = false;
        }
 
                _update_news_requested = false;
        }
 
+       void start_stop_pressed ()
+       {
+               if (_film_viewer->playing()) {
+                       _film_viewer->stop();
+               } else {
+                       _film_viewer->start();
+               }
+       }
+
        FilmEditor* _film_editor;
        FilmViewer* _film_viewer;
        VideoWaveformDialog* _video_waveform_dialog;
        FilmEditor* _film_editor;
        FilmViewer* _film_viewer;
        VideoWaveformDialog* _video_waveform_dialog;
index a765bd1d1416fda01783c9152a820e2517686455..39826df1b5b1a202c52610cde9c23ebc5821ad25 100644 (file)
@@ -83,6 +83,8 @@ enum {
        ID_help_report_a_problem,
        ID_tools_verify,
        ID_tools_check_for_updates,
        ID_help_report_a_problem,
        ID_tools_verify,
        ID_tools_check_for_updates,
+       /* IDs for shortcuts (with no associated menu item) */
+       ID_start_stop
 };
 
 class DOMFrame : public wxFrame
 };
 
 class DOMFrame : public wxFrame
@@ -147,12 +149,21 @@ public:
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
-               wxAcceleratorEntry* accel = new wxAcceleratorEntry[1];
-               accel[0].Set(wxACCEL_CTRL, static_cast<int>('W'), ID_file_close);
-               wxAcceleratorTable accel_table (1, accel);
+               int accelerators = 2;
+#else
+               int accelerators = 1;
+#endif
+
+               wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators];
+               accel[0].Set(wxACCEL_NORMAL, WXK_SPACE, ID_start_stop);
+#ifdef __WXOSX__
+               accel[1].Set(wxACCEL_CTRL, static_cast<int>('W'), ID_file_close);
+#endif
+               wxAcceleratorTable accel_table (accelerators, accel);
                SetAcceleratorTable (accel_table);
                delete[] accel;
                SetAcceleratorTable (accel_table);
                delete[] accel;
-#endif
+
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::start_stop_pressed, this), ID_start_stop);
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
        }
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
        }
@@ -553,6 +564,15 @@ private:
                _view_cpl->Enable (static_cast<bool>(_film));
        }
 
                _view_cpl->Enable (static_cast<bool>(_film));
        }
 
+       void start_stop_pressed ()
+       {
+               if (_viewer->playing()) {
+                       _viewer->stop();
+               } else {
+                       _viewer->start();
+               }
+       }
+
        bool _update_news_requested;
        PlayerInformation* _info;
        wxPreferencesEditor* _config_dialog;
        bool _update_news_requested;
        PlayerInformation* _info;
        wxPreferencesEditor* _config_dialog;
index a41cb310e374ec6b7d5c1cbb7480926af72a4e5a..190396601821bc5aac7ccdf58b3ab5e9ecb856f2 100644 (file)
@@ -66,6 +66,12 @@ public:
                return _dropped;
        }
 
                return _dropped;
        }
 
+       void start ();
+       bool stop ();
+       bool playing () const {
+               return _playing;
+       }
+
        int audio_callback (void* out, unsigned int frames);
 
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
        int audio_callback (void* out, unsigned int frames);
 
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
@@ -100,8 +106,6 @@ private:
        void recreate_butler ();
        void config_changed (Config::Property);
        DCPTime time () const;
        void recreate_butler ();
        void config_changed (Config::Property);
        DCPTime time () const;
-       void start ();
-       bool stop ();
        Frame average_latency () const;
        DCPTime one_video_frame () const;
 
        Frame average_latency () const;
        DCPTime one_video_frame () const;