From: Carl Hetherington Date: Mon, 8 Jan 2018 23:54:10 +0000 (+0000) Subject: When doing jump-to-selected jump to the first subtitle in TextSubtitleContent (#1160). X-Git-Tag: v2.11.39~3 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=81c317f71b4150f9ba6299190d5272837c548ef1 When doing jump-to-selected jump to the first subtitle in TextSubtitleContent (#1160). --- diff --git a/ChangeLog b/ChangeLog index 3c7e25e91..486d70c57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-01-08 Carl Hetherington + + * When doing jump-to-selected, jump to the first subtitle + in any text subtitle content (#1160). + 2018-01-07 Carl Hetherington * Updated nl_NL translation from Rob van Nieuwkerk. diff --git a/src/lib/text_subtitle.cc b/src/lib/text_subtitle.cc index 0f5e055cf..2de815459 100644 --- a/src/lib/text_subtitle.cc +++ b/src/lib/text_subtitle.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2016 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -36,6 +36,7 @@ using std::cout; using std::string; using boost::shared_ptr; using boost::scoped_array; +using boost::optional; using dcp::Data; TextSubtitle::TextSubtitle (shared_ptr content) @@ -85,6 +86,17 @@ TextSubtitle::TextSubtitle (shared_ptr content) delete reader; } +/** @return time of first subtitle, if there is one */ +optional +TextSubtitle::first () const +{ + if (_subtitles.empty()) { + return optional(); + } + + return ContentTime::from_seconds(_subtitles[0].from.all_as_seconds()); +} + ContentTime TextSubtitle::length () const { diff --git a/src/lib/text_subtitle.h b/src/lib/text_subtitle.h index c02f7a14b..94adb5cc5 100644 --- a/src/lib/text_subtitle.h +++ b/src/lib/text_subtitle.h @@ -37,6 +37,7 @@ class TextSubtitle public: TextSubtitle (boost::shared_ptr); + boost::optional first () const; ContentTime length () const; protected: diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 8620fa3e0..fa3754dd6 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -39,6 +39,8 @@ #include "lib/config.h" #include "lib/log.h" #include "lib/compose.hpp" +#include "lib/text_subtitle_content.h" +#include "lib/text_subtitle.h" #include #include #include @@ -254,8 +256,19 @@ ContentPanel::selection_changed () optional go_to; BOOST_FOREACH (shared_ptr i, selected ()) { - if (!go_to || i->position() < go_to.get()) { - go_to = i->position (); + DCPTime p; + p = i->position(); + if (dynamic_pointer_cast(i)) { + /* Rather special case; if we select a text subtitle file jump to its + first subtitle. + */ + TextSubtitle ts (dynamic_pointer_cast(i)); + if (ts.first()) { + p += DCPTime(ts.first().get(), _film->active_frame_rate_change(i->position())); + } + } + if (!go_to || p < go_to.get()) { + go_to = p; } }