Add swaroop-profile start/stop/pause buttons.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2018 21:53:14 +0000 (22:53 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2018 21:53:14 +0000 (22:53 +0100)
src/tools/dcpomatic_player.cc
src/wx/controls.cc
src/wx/controls.h

index 06b83a97f8a1ec49418746fd3c5a889a7a2ab100..a01d5ecaed25bbc93816dc29fe34ce6e58fb6b6b 100644 (file)
@@ -192,6 +192,7 @@ public:
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
                _controls->DCPDirectorySelected.connect (boost::bind(&DOMFrame::load_dcp, this, _1));
+               _controls->DCPEjected.connect (boost::bind(&DOMFrame::eject_dcp, this));
 
                setup_screen ();
        }
@@ -290,6 +291,13 @@ public:
                Config::instance()->set_decode_reduction (reduction);
        }
 
+       void eject_dcp ()
+       {
+               _film.reset (new Film (optional<boost::filesystem::path>()));
+               _viewer->set_film (_film);
+               _info->triggered_update ();
+       }
+
        void load_dcp (boost::filesystem::path dir)
        {
                _film.reset (new Film (optional<boost::filesystem::path>()));
index 915c056b3d5ada3ab0fb17ab3cdb0d90ae77bf0e..2802008fa58f8fb2a5dc53475ddeecdb9d2fdba3 100644 (file)
@@ -50,7 +50,13 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool outlin
        , _forward_button (new wxButton (this, wxID_ANY, wxT(">")))
        , _frame_number (new wxStaticText (this, wxID_ANY, wxT("")))
        , _timecode (new wxStaticText (this, wxID_ANY, wxT("")))
-       , _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       , _play_button (new wxButton(this, wxID_ANY, _("Play")))
+       , _pause_button (new wxButton(this, wxID_ANY, _("Pause")))
+       , _stop_button (new wxButton(this, wxID_ANY, _("Stop")))
+#else
+       , _play_button (new wxToggleButton(this, wxID_ANY, _("Play")))
+#endif
 {
        _v_sizer = new wxBoxSizer (wxVERTICAL);
        SetSizer (_v_sizer);
@@ -92,6 +98,10 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool outlin
        h_sizer->Add (time_sizer, 0, wxEXPAND);
        h_sizer->Add (_forward_button, 0, wxALL, 2);
        h_sizer->Add (_play_button, 0, wxEXPAND);
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       h_sizer->Add (_pause_button, 0, wxEXPAND);
+       h_sizer->Add (_stop_button, 0, wxEXPAND);
+#endif
        h_sizer->Add (_slider, 1, wxEXPAND);
 
        _v_sizer->Add (h_sizer, 0, wxEXPAND | wxALL, 6);
@@ -111,8 +121,14 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool outlin
        _slider->Bind           (wxEVT_SCROLL_THUMBTRACK,   boost::bind (&Controls::slider_moved,    this, false));
        _slider->Bind           (wxEVT_SCROLL_PAGEUP,       boost::bind (&Controls::slider_moved,    this, true));
        _slider->Bind           (wxEVT_SCROLL_PAGEDOWN,     boost::bind (&Controls::slider_moved,    this, true));
-       _slider->Bind           (wxEVT_SCROLL_THUMBRELEASE, boost::bind (&Controls::slider_released, this));
+       _slider->Bind           (wxEVT_SCROLL_CHANGED,      boost::bind (&Controls::slider_released, this));
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _play_button->Bind      (wxEVT_BUTTON,              boost::bind (&Controls::play_clicked,    this));
+       _pause_button->Bind     (wxEVT_BUTTON,              boost::bind (&Controls::pause_clicked,   this));
+       _stop_button->Bind      (wxEVT_BUTTON,              boost::bind (&Controls::stop_clicked,    this));
+#else
        _play_button->Bind      (wxEVT_TOGGLEBUTTON,        boost::bind (&Controls::play_clicked,    this));
+#endif
        _rewind_button->Bind    (wxEVT_LEFT_DOWN,           boost::bind (&Controls::rewind_clicked,  this, _1));
        _back_button->Bind      (wxEVT_LEFT_DOWN,           boost::bind (&Controls::back_clicked,    this, _1));
        _forward_button->Bind   (wxEVT_LEFT_DOWN,           boost::bind (&Controls::forward_clicked, this, _1));
@@ -152,13 +168,25 @@ Controls::config_changed (int property)
 void
 Controls::started ()
 {
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _play_button->Enable (false);
+       _pause_button->Enable (true);
+#else
        _play_button->SetValue (true);
+#endif
+       setup_sensitivity ();
 }
 
 void
 Controls::stopped ()
 {
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _play_button->Enable (true);
+       _pause_button->Enable (false);
+#else
        _play_button->SetValue (false);
+#endif
+       setup_sensitivity ();
 }
 
 void
@@ -231,9 +259,15 @@ Controls::slider_released ()
 void
 Controls::play_clicked ()
 {
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _viewer->start ();
+#else
        check_play_state ();
+#endif
 }
 
+
+#ifndef DCPOMATIC_VARIANT_SWAROOP
 void
 Controls::check_play_state ()
 {
@@ -247,6 +281,7 @@ Controls::check_play_state ()
                _viewer->stop ();
        }
 }
+#endif
 
 void
 Controls::update_position_slider ()
@@ -284,10 +319,8 @@ Controls::update_position_label ()
 void
 Controls::active_jobs_changed (optional<string> j)
 {
-       /* examine content is the only job which stops the viewer working */
-       bool const a = !j || *j != "examine_content";
-       _slider->Enable (a);
-       _play_button->Enable (a);
+       _active_job = j;
+       setup_sensitivity ();
 }
 
 DCPTime
@@ -340,13 +373,20 @@ Controls::forward_clicked (wxKeyboardState& ev)
 void
 Controls::setup_sensitivity ()
 {
-       bool const c = _film && !_film->content().empty ();
+       /* examine content is the only job which stops the viewer working */
+       bool const c = _film && !_film->content().empty() && (!_active_job || *_active_job != "examine_content");
 
        _slider->Enable (c);
        _rewind_button->Enable (c);
        _back_button->Enable (c);
        _forward_button->Enable (c);
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       _play_button->Enable (c && !_viewer->playing());
+       _pause_button->Enable (c && _viewer->playing());
+       _stop_button->Enable (c);
+#else
        _play_button->Enable (c);
+#endif
        if (_outline_content) {
                _outline_content->Enable (c);
        }
@@ -456,3 +496,18 @@ Controls::dcp_directory_selected ()
        DCPOMATIC_ASSERT (s < int(_dcp_directories.size()));
        DCPDirectorySelected (*Config::instance()->player_dcp_directory() / _dcp_directories[s]);
 }
+
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+void
+Controls::pause_clicked ()
+{
+       _viewer->stop ();
+}
+
+void
+Controls::stop_clicked ()
+{
+       _viewer->stop ();
+       DCPEjected ();
+}
+#endif
index 8ee5310c785a81f3bb2555a957f1a19c6e4905bb..652e71f1651aad8623197726d43344bda1d6eec9 100644 (file)
@@ -52,6 +52,7 @@ public:
        void show_dcp_directory (bool s);
 
        boost::signals2::signal<void (boost::filesystem::path)> DCPDirectorySelected;
+       boost::signals2::signal<void ()> DCPEjected;
 
 private:
        void update_position_label ();
@@ -66,7 +67,9 @@ private:
        void jump_to_selected_clicked ();
        void setup_sensitivity ();
        void timecode_clicked ();
+#ifndef DCPOMATIC_PLAYER_SWAROOP
        void check_play_state ();
+#endif
        void active_jobs_changed (boost::optional<std::string>);
        DCPTime nudge_amount (wxKeyboardState& ev);
        void image_changed (boost::weak_ptr<PlayerVideo>);
@@ -81,6 +84,10 @@ private:
        void dcp_directory_changed ();
        void dcp_directory_selected ();
        void config_changed (int property);
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       void pause_clicked ();
+       void stop_clicked ();
+#endif
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<FilmViewer> _viewer;
@@ -100,7 +107,14 @@ private:
        wxButton* _forward_button;
        wxStaticText* _frame_number;
        wxStaticText* _timecode;
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       wxButton* _play_button;
+       wxButton* _pause_button;
+       wxButton* _stop_button;
+#else
        wxToggleButton* _play_button;
+#endif
+       boost::optional<std::string> _active_job;
 
        ClosedCaptionsDialog* _closed_captions_dialog;