Fix various problems with the closed caption viewer not being updated properly. v2.15.91
authorCarl Hetherington <cth@carlh.net>
Tue, 28 Jul 2020 20:20:19 +0000 (22:20 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 28 Jul 2020 20:20:19 +0000 (22:20 +0200)
src/wx/closed_captions_dialog.cc
src/wx/closed_captions_dialog.h
src/wx/film_viewer.cc
src/wx/film_viewer.h

index afcf5fa..625652b 100644 (file)
@@ -205,6 +205,12 @@ ClosedCaptionsDialog::update ()
                Refresh ();
                _current_in_lines = true;
        }
+
+       if (!_current && _tracks.empty()) {
+               for (int i = 0; i < CLOSED_CAPTION_LINES; ++i) {
+                       _lines[i] = wxString();
+               }
+       }
 }
 
 void
@@ -215,8 +221,15 @@ ClosedCaptionsDialog::clear ()
        Refresh ();
 }
 
+
+void
+ClosedCaptionsDialog::set_butler (weak_ptr<Butler> butler)
+{
+       _butler = butler;
+}
+
 void
-ClosedCaptionsDialog::set_film_and_butler (shared_ptr<Film> film, weak_ptr<Butler> butler)
+ClosedCaptionsDialog::update_tracks (shared_ptr<const Film> film)
 {
        _tracks.clear ();
 
@@ -239,5 +252,5 @@ ClosedCaptionsDialog::set_film_and_butler (shared_ptr<Film> film, weak_ptr<Butle
                _track->SetSelection (0);
        }
 
-       _butler = butler;
+       track_selected ();
 }
index cfdab5f..4117de2 100644 (file)
@@ -35,7 +35,8 @@ public:
        explicit ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer);
 
        void clear ();
-       void set_film_and_butler (boost::shared_ptr<Film>, boost::weak_ptr<Butler>);
+       void update_tracks (boost::shared_ptr<const Film> film);
+       void set_butler (boost::weak_ptr<Butler>);
 
 private:
        void shown (wxShowEvent);
index 21a35c2..154b3a5 100644 (file)
@@ -47,6 +47,7 @@
 #include "lib/config.h"
 #include "lib/compose.hpp"
 #include "lib/dcpomatic_log.h"
+#include "lib/text_content.h"
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
@@ -179,6 +180,7 @@ FilmViewer::set_film (shared_ptr<Film> film)
        _player->set_play_referenced ();
 
        _film->Change.connect (boost::bind (&FilmViewer::film_change, this, _1, _2));
+       _film->ContentChange.connect (boost::bind(&FilmViewer::content_change, this, _1, _3));
        _film->LengthChange.connect (boost::bind(&FilmViewer::film_length_change, this));
        _player->Change.connect (boost::bind (&FilmViewer::player_change, this, _1, _2, _3));
 
@@ -221,7 +223,7 @@ FilmViewer::recreate_butler ()
                _butler->disable_audio ();
        }
 
-       _closed_captions_dialog->set_film_and_butler (_film, _butler);
+       _closed_captions_dialog->set_butler (_butler);
 
        resume ();
 }
@@ -408,6 +410,8 @@ FilmViewer::film_change (ChangeType type, Film::Property p)
                _video_view->set_video_frame_rate (_film->video_frame_rate());
        } else if (p == Film::THREE_D) {
                _video_view->set_three_d (_film->three_d());
+       } else if (p == Film::CONTENT) {
+               _closed_captions_dialog->update_tracks (_film);
        }
 }
 
@@ -703,3 +707,15 @@ FilmViewer::gets () const
 }
 
 
+void
+FilmViewer::content_change (ChangeType type, int property)
+{
+       if (type != CHANGE_TYPE_DONE) {
+               return;
+       }
+
+       if (property == TextContentProperty::USE || property == TextContentProperty::TYPE || property == TextContentProperty::DCP_TRACK) {
+               _closed_captions_dialog->update_tracks (_film);
+       }
+}
+
index 6e99581..11a4731 100644 (file)
@@ -161,6 +161,7 @@ private:
        void idle_handler ();
        void request_idle_display_next_frame ();
        void film_change (ChangeType, Film::Property);
+       void content_change (ChangeType, int property);
        void recreate_butler ();
        void config_changed (Config::Property);
        void film_length_change ();