Disable player controls when there is no content.
authorCarl Hetherington <cth@carlh.net>
Wed, 23 Jul 2014 09:39:20 +0000 (10:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 23 Jul 2014 09:39:20 +0000 (10:39 +0100)
src/wx/film_viewer.cc
src/wx/film_viewer.h

index 96e20a281af3b2c1e690b49135be8fa621be5bfc..f2f6ba23d73e1b6e987787b68d8388be174928a5 100644 (file)
@@ -114,6 +114,8 @@ FilmViewer::FilmViewer (shared_ptr<Film> 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<Film> 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 ();
+       }
+}
index 930937596ab9afa64fb340463c07c6c0298e851e..0235d225fc030eb125b48b96fbb7a2bf6eb60b07 100644 (file)
@@ -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> _film;
        boost::shared_ptr<Player> _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;
 };