_have_valid_pieces = false;
Changed (PlayerProperty::DCP_DECODE_REDUCTION, false);
}
+
+DCPTime
+Player::content_time_to_dcp (shared_ptr<Content> content, ContentTime t)
+{
+ if (_have_valid_pieces) {
+ setup_pieces ();
+ }
+
+ BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
+ if (i->content == content) {
+ return content_time_to_dcp (i, t);
+ }
+ }
+
+ DCPOMATIC_ASSERT (false);
+ return DCPTime ();
+}
/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include "lib/audio_decoder.h"
#include "lib/film.h"
#include "lib/text_subtitle_content.h"
+#include "lib/config.h"
#include "subtitle_view.h"
+#include "film_viewer.h"
#include "wx_util.h"
using std::list;
using boost::bind;
using boost::dynamic_pointer_cast;
-SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Decoder> decoder, DCPTime position)
+SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<Decoder> decoder, FilmViewer* viewer)
: wxDialog (parent, wxID_ANY, _("Subtitles"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ , _content (content)
+ , _film_viewer (viewer)
{
_list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
+ _list->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind (&SubtitleView::subtitle_selected, this, _1));
+
wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
if (buttons) {
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
_subs = 0;
- _frc = film->active_frame_rate_change (position);
+ _frc = film->active_frame_rate_change (content->position());
decoder->subtitle->TextStart.connect (bind (&SubtitleView::data_start, this, _1));
decoder->subtitle->Stop.connect (bind (&SubtitleView::data_stop, this, _1));
while (!decoder->pass ()) {}
_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 ());
++_subs;
}
_list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source)));
}
}
+
+void
+SubtitleView::subtitle_selected (wxListEvent& ev)
+{
+ if (!Config::instance()->jump_to_selected ()) {
+ return;
+ }
+
+ DCPOMATIC_ASSERT (ev.GetIndex() < int(_start_times.size()));
+ shared_ptr<Content> locked = _content.lock ();
+ DCPOMATIC_ASSERT (locked);
+ _film_viewer->set_position (locked, _start_times[ev.GetIndex()]);
+}
#include <wx/listctrl.h>
class Decoder;
+class FilmViewer;
class SubtitleView : public wxDialog
{
public:
- SubtitleView (wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Decoder>, DCPTime position);
+ SubtitleView (wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Content> content, boost::shared_ptr<Decoder>, FilmViewer* viewer);
private:
void data_start (ContentTextSubtitle cts);
void data_stop (ContentTime time);
+ void subtitle_selected (wxListEvent &);
wxListCtrl* _list;
int _subs;
boost::optional<FrameRateChange> _frc;
boost::optional<int> _last_count;
+ std::vector<ContentTime> _start_times;
+ boost::weak_ptr<Content> _content;
+ FilmViewer* _film_viewer;
};