swaroop: next/previous buttons for playlist.
authorCarl Hetherington <cth@carlh.net>
Thu, 13 Dec 2018 21:43:54 +0000 (21:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 13 Dec 2018 21:43:54 +0000 (21:43 +0000)
src/wx/swaroop_controls.cc
src/wx/swaroop_controls.h

index 909cb0dc46a8554d0eccff68785934f3bddcbe38..6a7cde4e71febab12cf7183c4eb91c83c42a6e8b 100644 (file)
@@ -41,11 +41,15 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
        , _play_button (new Button(this, _("Play")))
        , _pause_button (new Button(this, _("Pause")))
        , _stop_button (new Button(this, _("Stop")))
        , _play_button (new Button(this, _("Play")))
        , _pause_button (new Button(this, _("Pause")))
        , _stop_button (new Button(this, _("Stop")))
+       , _next_button (new Button(this, "Next"))
+       , _previous_button (new Button(this, "Previous"))
        , _current_disable_timeline (false)
 {
        _button_sizer->Add (_play_button, 0, wxEXPAND);
        _button_sizer->Add (_pause_button, 0, wxEXPAND);
        _button_sizer->Add (_stop_button, 0, wxEXPAND);
        , _current_disable_timeline (false)
 {
        _button_sizer->Add (_play_button, 0, wxEXPAND);
        _button_sizer->Add (_pause_button, 0, wxEXPAND);
        _button_sizer->Add (_stop_button, 0, wxEXPAND);
+       _button_sizer->Add (_next_button, 0, wxEXPAND);
+       _button_sizer->Add (_previous_button, 0, wxEXPAND);
 
        _spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
        _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 740);
 
        _spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
        _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 740);
@@ -93,11 +97,13 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
        _log = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1, 200), wxTE_READONLY | wxTE_MULTILINE);
        _v_sizer->Add (_log, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
 
        _log = new wxTextCtrl (this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1, 200), wxTE_READONLY | wxTE_MULTILINE);
        _v_sizer->Add (_log, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_GAP);
 
-       _play_button->Bind  (wxEVT_BUTTON, boost::bind(&SwaroopControls::play_clicked,  this));
-       _pause_button->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::pause_clicked, this));
-       _stop_button->Bind  (wxEVT_BUTTON, boost::bind(&SwaroopControls::stop_clicked,  this));
-       _spl_view->Bind     (wxEVT_LIST_ITEM_SELECTED,   boost::bind(&SwaroopControls::spl_selection_changed, this));
-       _spl_view->Bind     (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&SwaroopControls::spl_selection_changed, this));
+       _play_button->Bind     (wxEVT_BUTTON, boost::bind(&SwaroopControls::play_clicked,  this));
+       _pause_button->Bind    (wxEVT_BUTTON, boost::bind(&SwaroopControls::pause_clicked, this));
+       _stop_button->Bind     (wxEVT_BUTTON, boost::bind(&SwaroopControls::stop_clicked,  this));
+       _next_button->Bind     (wxEVT_BUTTON, boost::bind(&SwaroopControls::next_clicked,  this));
+       _previous_button->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::previous_clicked,  this));
+       _spl_view->Bind        (wxEVT_LIST_ITEM_SELECTED,   boost::bind(&SwaroopControls::spl_selection_changed, this));
+       _spl_view->Bind        (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&SwaroopControls::spl_selection_changed, this));
        _viewer->Finished.connect (boost::bind(&SwaroopControls::viewer_finished, this));
        _refresh_spl_view->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::update_playlist_directory, this));
        _refresh_content_view->Bind (wxEVT_BUTTON, boost::bind(&ContentView::update, _content_view));
        _viewer->Finished.connect (boost::bind(&SwaroopControls::viewer_finished, this));
        _refresh_spl_view->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::update_playlist_directory, this));
        _refresh_content_view->Bind (wxEVT_BUTTON, boost::bind(&ContentView::update, _content_view));
@@ -153,6 +159,28 @@ SwaroopControls::stop_clicked ()
        _viewer->seek (DCPTime(), true);
 }
 
        _viewer->seek (DCPTime(), true);
 }
 
+void
+SwaroopControls::previous_clicked ()
+{
+       if (!_selected_playlist || (_selected_playlist_position - 1) < 0) {
+               return;
+       }
+
+       _selected_playlist_position--;
+       update_current_content ();
+}
+
+void
+SwaroopControls::next_clicked ()
+{
+       if (!_selected_playlist || (_selected_playlist_position + 1) >= int(_playlists[*_selected_playlist].get().size())) {
+               return;
+       }
+
+       _selected_playlist_position++;
+       update_current_content ();
+}
+
 void
 SwaroopControls::log (wxString s)
 {
 void
 SwaroopControls::log (wxString s)
 {
@@ -277,6 +305,18 @@ SwaroopControls::set_film (shared_ptr<Film> film)
        setup_sensitivity ();
 }
 
        setup_sensitivity ();
 }
 
+void
+SwaroopControls::update_current_content ()
+{
+       DCPOMATIC_ASSERT (_selected_playlist);
+
+       _viewer->stop ();
+       _current_disable_timeline = _playlists[*_selected_playlist].get()[_selected_playlist_position].disable_timeline;
+       setup_sensitivity ();
+       reset_film ();
+       _viewer->start ();
+}
+
 void
 SwaroopControls::viewer_finished ()
 {
 void
 SwaroopControls::viewer_finished ()
 {
@@ -284,14 +324,5 @@ SwaroopControls::viewer_finished ()
                return;
        }
 
                return;
        }
 
-       ++_selected_playlist_position;
-
-       SPL const & playlist = _playlists[*_selected_playlist];
-
-       if (_selected_playlist_position < int(playlist.get().size())) {
-               _current_disable_timeline = playlist.get()[_selected_playlist_position].disable_timeline;
-               setup_sensitivity ();
-               reset_film ();
-               _viewer->start ();
-       }
+       next_clicked ();
 }
 }
index 7012bcb4782ff78d6695b54c2194e590eee87564..91fad1537d16b616877935f7cc1c109a49c04c63 100644 (file)
@@ -38,6 +38,8 @@ private:
        void play_clicked ();
        void pause_clicked ();
        void stop_clicked ();
        void play_clicked ();
        void pause_clicked ();
        void stop_clicked ();
+       void next_clicked ();
+       void previous_clicked ();
        void add_playlist_to_list (SPL spl);
        void update_content_directory ();
        void update_playlist_directory ();
        void add_playlist_to_list (SPL spl);
        void update_content_directory ();
        void update_playlist_directory ();
@@ -48,10 +50,13 @@ private:
        void config_changed (int);
        void viewer_finished ();
        void reset_film ();
        void config_changed (int);
        void viewer_finished ();
        void reset_film ();
+       void update_current_content ();
 
        wxButton* _play_button;
        wxButton* _pause_button;
        wxButton* _stop_button;
 
        wxButton* _play_button;
        wxButton* _pause_button;
        wxButton* _stop_button;
+       wxButton* _next_button;
+       wxButton* _previous_button;
 
        ContentView* _content_view;
        wxButton* _refresh_content_view;
 
        ContentView* _content_view;
        wxButton* _refresh_content_view;