X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftext_view.cc;fp=src%2Fwx%2Ftext_view.cc;h=abe73a5a9fea212eeb10ce08947cee0e4fb2bd78;hb=41885408b723c29ab3ae48cae5999a9934240bf2;hp=3b674b5c17eb04562932ca23e54d2668cc144b89;hpb=c99c72164a6b598f13b4af5ec08f42205565cb34;p=dcpomatic.git diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc index 3b674b5c1..abe73a5a9 100644 --- a/src/wx/text_view.cc +++ b/src/wx/text_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2018 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,28 +18,31 @@ */ -#include "text_view.h" + #include "film_viewer.h" +#include "text_view.h" #include "wx_util.h" -#include "lib/string_text_file_decoder.h" -#include "lib/content_text.h" -#include "lib/video_decoder.h" #include "lib/audio_decoder.h" -#include "lib/film.h" #include "lib/config.h" +#include "lib/film.h" +#include "lib/piece_text.h" #include "lib/string_text_file_content.h" +#include "lib/string_text_file_decoder.h" #include "lib/text_decoder.h" +#include "lib/video_decoder.h" + +using std::dynamic_pointer_cast; using std::list; using std::shared_ptr; using std::weak_ptr; using boost::bind; -using std::dynamic_pointer_cast; using namespace dcpomatic; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif + TextView::TextView ( wxWindow* parent, shared_ptr film, shared_ptr content, shared_ptr text, shared_ptr decoder, weak_ptr viewer ) @@ -73,7 +76,7 @@ TextView::TextView ( _list->InsertColumn (2, ip); } - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); _list->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&TextView::subtitle_selected, this, _1)); @@ -96,30 +99,32 @@ TextView::TextView ( /* Find the decoder that is being used for our TextContent and attach to it */ for (auto i: decoder->text) { if (i->content() == text) { - i->PlainStart.connect (bind (&TextView::data_start, this, _1)); - i->Stop.connect (bind (&TextView::data_stop, this, _1)); + i->StringStart.connect (bind(&TextView::data_start, this, _1, _2)); + i->Stop.connect (bind(&TextView::data_stop, this, _1)); } } while (!decoder->pass ()) {} SetSizerAndFit (sizer); } + void -TextView::data_start (ContentStringText cts) +TextView::data_start (ContentTime time, list subs) { - for (auto const& i: cts.subs) { + for (auto const& i: subs) { wxListItem list_item; list_item.SetId (_subs); _list->InsertItem (list_item); - _list->SetItem (_subs, 0, std_to_wx (cts.from().timecode (_frc->source))); - _list->SetItem (_subs, 2, std_to_wx (i.text ())); - _start_times.push_back (cts.from ()); + _list->SetItem (_subs, 0, std_to_wx(time.timecode(_frc->source))); + _list->SetItem (_subs, 2, std_to_wx(i.text ())); + _start_times.push_back (time); ++_subs; } - _last_count = cts.subs.size (); + _last_count = subs.size (); } + void TextView::data_stop (ContentTime time) { @@ -128,21 +133,22 @@ TextView::data_stop (ContentTime time) } for (int i = _subs - *_last_count; i < _subs; ++i) { - _list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source))); + _list->SetItem (i, 1, std_to_wx(time.timecode(_frc->source))); } } + void TextView::subtitle_selected (wxListEvent& ev) { - if (!Config::instance()->jump_to_selected ()) { + if (!Config::instance()->jump_to_selected()) { return; } DCPOMATIC_ASSERT (ev.GetIndex() < int(_start_times.size())); - shared_ptr lc = _content.lock (); + auto lc = _content.lock (); DCPOMATIC_ASSERT (lc); - shared_ptr fv = _film_viewer.lock (); + auto fv = _film_viewer.lock (); DCPOMATIC_ASSERT (fv); /* Add on a frame here to work around any rounding errors and make sure land in the subtitle */ fv->seek (lc, _start_times[ev.GetIndex()] + ContentTime::from_frames(1, _frc->source), true);