diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-01-08 23:54:10 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-01-08 23:54:10 +0000 |
| commit | 81c317f71b4150f9ba6299190d5272837c548ef1 (patch) | |
| tree | d13502dcb65bdc534fa0124aaae3e866a5234de5 /src/lib | |
| parent | 160a401d16e3962b10f3105e00992936a8188424 (diff) | |
When doing jump-to-selected jump to the first subtitle in TextSubtitleContent (#1160).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/text_subtitle.cc | 14 | ||||
| -rw-r--r-- | src/lib/text_subtitle.h | 1 |
2 files changed, 14 insertions, 1 deletions
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 <cth@carlh.net> + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> 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<const TextSubtitleContent> content) @@ -85,6 +86,17 @@ TextSubtitle::TextSubtitle (shared_ptr<const TextSubtitleContent> content) delete reader; } +/** @return time of first subtitle, if there is one */ +optional<ContentTime> +TextSubtitle::first () const +{ + if (_subtitles.empty()) { + return optional<ContentTime>(); + } + + 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<const TextSubtitleContent>); + boost::optional<ContentTime> first () const; ContentTime length () const; protected: |
