From: Carl Hetherington Date: Wed, 23 Jul 2014 09:39:20 +0000 (+0100) Subject: Disable player controls when there is no content. X-Git-Tag: v2.0.48~676 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=2cb5f05397b115bda11d8f86a62a3f30d8e2ea71 Disable player controls when there is no content. --- diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 96e20a281..f2f6ba23d 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -114,6 +114,8 @@ FilmViewer::FilmViewer (shared_ptr f, wxWindow* p) JobManager::instance()->ActiveJobsChanged.connect ( bind (&FilmViewer::active_jobs_changed, this, _1) ); + + setup_sensitivity (); } void @@ -142,8 +144,10 @@ FilmViewer::set_film (shared_ptr f) return; } + _film_connection = _film->Changed.connect (boost::bind (&FilmViewer::film_changed, this, _1)); + _player->set_approximate_size (); - _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1)); + _player_connection = _player->Changed.connect (boost::bind (&FilmViewer::player_changed, this, _1)); calculate_sizes (); get (_position, _last_get_accurate); @@ -402,3 +406,24 @@ FilmViewer::player_changed (bool frequent) calculate_sizes (); get (_position, _last_get_accurate); } + +void +FilmViewer::setup_sensitivity () +{ + bool const c = !_film->content().empty (); + _slider->Enable (c); + _back_button->Enable (c); + _forward_button->Enable (c); + _play_button->Enable (c); + _outline_content->Enable (c); + _frame_number->Enable (c); + _timecode->Enable (c); +} + +void +FilmViewer::film_changed (Film::Property p) +{ + if (p == Film::CONTENT) { + setup_sensitivity (); + } +} diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 930937596..0235d225f 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -55,6 +55,8 @@ private: void set_position_text (); void get (DCPTime, bool); void refresh_panel (); + void setup_sensitivity (); + void film_changed (Film::Property); boost::shared_ptr _film; boost::shared_ptr _player; @@ -84,4 +86,7 @@ private: * can get the same one that we got last time. */ bool _last_get_accurate; + + boost::signals2::scoped_connection _film_connection; + boost::signals2::scoped_connection _player_connection; };