summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-12-13 21:43:54 +0000
committerCarl Hetherington <cth@carlh.net>2018-12-13 21:43:54 +0000
commit3f30355567cb88ee425745e805905d57c6d1bdcd (patch)
tree66c366c8f5f419c1e7b9f7426fdd584d66eb4b8b /src
parente81d3bb9857d9de7ec9468a3efcb812042f5cef9 (diff)
swaroop: next/previous buttons for playlist.
Diffstat (limited to 'src')
-rw-r--r--src/wx/swaroop_controls.cc61
-rw-r--r--src/wx/swaroop_controls.h5
2 files changed, 51 insertions, 15 deletions
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<FilmViewer> 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<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);
- _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));
@@ -154,6 +160,28 @@ SwaroopControls::stop_clicked ()
}
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)
{
struct timeval time;
@@ -278,20 +306,23 @@ SwaroopControls::set_film (shared_ptr<Film> film)
}
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 ()
{
if (!_selected_playlist) {
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;