X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fsubtitle_panel.cc;h=5cfd295042e6bfdc407511a6f2171ca2a041b306;hb=8d58a7c5f4320ad5c111e336c45e44d6b51ab509;hp=4b7f1ca534b594c24c9f01fa767ace32b9943258;hpb=05654d0e1799746a9df3ccab040c92e0ed825cac;p=dcpomatic.git diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 4b7f1ca53..5cfd29504 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -22,6 +22,9 @@ #include "lib/ffmpeg_content.h" #include "lib/subrip_content.h" #include "lib/ffmpeg_subtitle_stream.h" +#include "lib/dcp_subtitle_content.h" +#include "lib/subrip_decoder.h" +#include "lib/dcp_subtitle_decoder.h" #include "subtitle_panel.h" #include "film_editor.h" #include "wx_util.h" @@ -156,14 +159,20 @@ SubtitlePanel::setup_sensitivity () { int any_subs = 0; int ffmpeg_subs = 0; + int subrip_or_dcp_subs = 0; SubtitleContentList c = _editor->selected_subtitle_content (); for (SubtitleContentList::const_iterator i = c.begin(); i != c.end(); ++i) { shared_ptr fc = boost::dynamic_pointer_cast (*i); + shared_ptr sc = boost::dynamic_pointer_cast (*i); + shared_ptr dsc = boost::dynamic_pointer_cast (*i); if (fc) { if (!fc->subtitle_streams().empty ()) { ++ffmpeg_subs; ++any_subs; } + } else if (sc || dsc) { + ++subrip_or_dcp_subs; + ++any_subs; } else { ++any_subs; } @@ -176,7 +185,7 @@ SubtitlePanel::setup_sensitivity () _y_offset->Enable (any_subs > 0 && use); _scale->Enable (any_subs > 0 && use); _stream->Enable (ffmpeg_subs == 1); - _view_button->Enable (any_subs == 1); + _view_button->Enable (subrip_or_dcp_subs == 1); } void @@ -248,10 +257,21 @@ SubtitlePanel::view_clicked () SubtitleContentList c = _editor->selected_subtitle_content (); assert (c.size() == 1); + + shared_ptr decoder; + shared_ptr sr = dynamic_pointer_cast (c.front ()); if (sr) { - _view = new SubtitleView (this, _editor->film(), sr); + decoder.reset (new SubRipDecoder (sr)); + } + + shared_ptr dc = dynamic_pointer_cast (c.front ()); + if (dc) { + decoder.reset (new DCPSubtitleDecoder (dc)); + } + + if (decoder) { + _view = new SubtitleView (this, _editor->film(), decoder, c.front()->position ()); + _view->Show (); } - - _view->Show (); }