From: Carl Hetherington Date: Thu, 13 Dec 2018 21:43:54 +0000 (+0000) Subject: swaroop: next/previous buttons for playlist. X-Git-Tag: v2.13.84~2 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=3f30355567cb88ee425745e805905d57c6d1bdcd swaroop: next/previous buttons for playlist. --- diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc index 909cb0dc4..6a7cde4e7 100644 --- a/src/wx/swaroop_controls.cc +++ b/src/wx/swaroop_controls.cc @@ -41,11 +41,15 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr viewe , _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); + _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); @@ -93,11 +97,13 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr 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); - _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)); @@ -153,6 +159,28 @@ SwaroopControls::stop_clicked () _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) { @@ -277,6 +305,18 @@ SwaroopControls::set_film (shared_ptr film) 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 () { @@ -284,14 +324,5 @@ SwaroopControls::viewer_finished () 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 (); } diff --git a/src/wx/swaroop_controls.h b/src/wx/swaroop_controls.h index 7012bcb47..91fad1537 100644 --- a/src/wx/swaroop_controls.h +++ b/src/wx/swaroop_controls.h @@ -38,6 +38,8 @@ private: 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 (); @@ -48,10 +50,13 @@ private: void config_changed (int); void viewer_finished (); void reset_film (); + void update_current_content (); wxButton* _play_button; wxButton* _pause_button; wxButton* _stop_button; + wxButton* _next_button; + wxButton* _previous_button; ContentView* _content_view; wxButton* _refresh_content_view;