summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-01-08 23:54:10 +0000
committerCarl Hetherington <cth@carlh.net>2018-01-08 23:54:10 +0000
commit81c317f71b4150f9ba6299190d5272837c548ef1 (patch)
treed13502dcb65bdc534fa0124aaae3e866a5234de5 /src
parent160a401d16e3962b10f3105e00992936a8188424 (diff)
When doing jump-to-selected jump to the first subtitle in TextSubtitleContent (#1160).
Diffstat (limited to 'src')
-rw-r--r--src/lib/text_subtitle.cc14
-rw-r--r--src/lib/text_subtitle.h1
-rw-r--r--src/wx/content_panel.cc19
3 files changed, 30 insertions, 4 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:
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 <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
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 <wx/wx.h>
#include <wx/notebook.h>
#include <wx/listctrl.h>
@@ -254,8 +256,19 @@ ContentPanel::selection_changed ()
optional<DCPTime> go_to;
BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
- if (!go_to || i->position() < go_to.get()) {
- go_to = i->position ();
+ DCPTime p;
+ p = i->position();
+ if (dynamic_pointer_cast<TextSubtitleContent>(i)) {
+ /* Rather special case; if we select a text subtitle file jump to its
+ first subtitle.
+ */
+ TextSubtitle ts (dynamic_pointer_cast<TextSubtitleContent>(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;
}
}