Another static fix.
[dcpomatic.git] / src / wx / film_viewer.cc
index 96e20a281af3b2c1e690b49135be8fa621be5bfc..7ecba1903799d28ae658a7eee917bbce6d624983 100644 (file)
@@ -55,7 +55,7 @@ using boost::dynamic_pointer_cast;
 using boost::weak_ptr;
 using dcp::Size;
 
-FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
+FilmViewer::FilmViewer (wxWindow* p)
        : wxPanel (p)
        , _panel (new wxPanel (this))
        , _outline_content (new wxCheckBox (this, wxID_ANY, _("Outline content")))
@@ -109,11 +109,13 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p)
        _back_button->Bind    (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&FilmViewer::back_clicked,    this));
        _forward_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,       boost::bind (&FilmViewer::forward_clicked, this));
 
-       set_film (f);
-
+       set_film (shared_ptr<Film> ());
+       
        JobManager::instance()->ActiveJobsChanged.connect (
                bind (&FilmViewer::active_jobs_changed, this, _1)
                );
+
+       setup_sensitivity ();
 }
 
 void
@@ -142,11 +144,15 @@ 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);
+
+       setup_sensitivity ();
 }
 
 void
@@ -402,3 +408,25 @@ FilmViewer::player_changed (bool frequent)
        calculate_sizes ();
        get (_position, _last_get_accurate);
 }
+
+void
+FilmViewer::setup_sensitivity ()
+{
+       bool const c = _film && !_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 ();
+       }
+}