From d902160e3c89a9f65f58a2463fac0b1de1d940b1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 28 Jul 2020 22:20:19 +0200 Subject: [PATCH] Fix various problems with the closed caption viewer not being updated properly. --- src/wx/closed_captions_dialog.cc | 17 +++++++++++++++-- src/wx/closed_captions_dialog.h | 3 ++- src/wx/film_viewer.cc | 18 +++++++++++++++++- src/wx/film_viewer.h | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/wx/closed_captions_dialog.cc b/src/wx/closed_captions_dialog.cc index afcf5fa87..625652b8c 100644 --- a/src/wx/closed_captions_dialog.cc +++ b/src/wx/closed_captions_dialog.cc @@ -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; +} + void -ClosedCaptionsDialog::set_film_and_butler (shared_ptr film, weak_ptr butler) +ClosedCaptionsDialog::update_tracks (shared_ptr film) { _tracks.clear (); @@ -239,5 +252,5 @@ ClosedCaptionsDialog::set_film_and_butler (shared_ptr film, weak_ptrSetSelection (0); } - _butler = butler; + track_selected (); } diff --git a/src/wx/closed_captions_dialog.h b/src/wx/closed_captions_dialog.h index cfdab5f3c..4117de263 100644 --- a/src/wx/closed_captions_dialog.h +++ b/src/wx/closed_captions_dialog.h @@ -35,7 +35,8 @@ public: explicit ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer); void clear (); - void set_film_and_butler (boost::shared_ptr, boost::weak_ptr); + void update_tracks (boost::shared_ptr film); + void set_butler (boost::weak_ptr); private: void shown (wxShowEvent); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 21a35c227..154b3a5fd 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -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 } @@ -179,6 +180,7 @@ FilmViewer::set_film (shared_ptr 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); + } +} + diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 6e995813c..11a4731fc 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -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 (); -- 2.30.2