Support buttons.
[dcpomatic.git] / src / wx / swaroop_controls.cc
index dc65f1b85f7635f14672106d94ec70cce87ccd11..2546412efe2fe36a7151cb8bc5da3cd162ad33bc 100644 (file)
@@ -22,6 +22,7 @@
 #include "film_viewer.h"
 #include "wx_util.h"
 #include "content_view.h"
+#include "dcpomatic_button.h"
 #include "lib/player_video.h"
 #include "lib/dcp_content.h"
 #include <wx/listctrl.h>
@@ -35,9 +36,10 @@ using boost::optional;
 
 SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewer)
        : Controls (parent, viewer, false)
-       , _play_button (new wxButton(this, wxID_ANY, _("Play")))
-       , _pause_button (new wxButton(this, wxID_ANY, _("Pause")))
-       , _stop_button (new wxButton(this, wxID_ANY, _("Stop")))
+       , _play_button (new Button(this, _("Play")))
+       , _pause_button (new Button(this, _("Pause")))
+       , _stop_button (new Button(this, _("Stop")))
+       , _current_disable_timeline (false)
 {
        _button_sizer->Add (_play_button, 0, wxEXPAND);
        _button_sizer->Add (_pause_button, 0, wxEXPAND);
@@ -107,7 +109,7 @@ SwaroopControls::setup_sensitivity ()
        _play_button->Enable (c && !_viewer->playing());
        _pause_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT) && _viewer->playing());
        _stop_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT));
-       _slider->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT));
+       _slider->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT) && !_current_disable_timeline);
 }
 
 void
@@ -149,6 +151,21 @@ SwaroopControls::image_changed (boost::weak_ptr<PlayerVideo> weak_pv)
                return;
        }
 
+       if (c == _current_content.lock()) {
+               return;
+       }
+
+       _current_content = c;
+
+       if (_selected_playlist) {
+               BOOST_FOREACH (SPLEntry i, _playlists[*_selected_playlist].get()) {
+                       if (i.content == c) {
+                               _current_disable_timeline = i.disable_timeline;
+                               setup_sensitivity ();
+                       }
+               }
+       }
+
        shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (c);
        if (!dc) {
                return;
@@ -202,12 +219,16 @@ SwaroopControls::update_playlist_directory ()
 void
 SwaroopControls::spl_selection_changed ()
 {
+       _current_spl_view->DeleteAllItems ();
+
        long int selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (selected == -1) {
-               _current_spl_view->DeleteAllItems ();
+               _selected_playlist = boost::none;
                return;
        }
 
+       _selected_playlist = selected;
+
        shared_ptr<Film> film (new Film(optional<boost::filesystem::path>()));
 
        int N = 0;