summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-03-07 20:13:22 +0000
committerCarl Hetherington <cth@carlh.net>2014-03-07 20:13:22 +0000
commitcab9a1d569396065a6e9eb39386736908564d6b4 (patch)
treeef698f132e659ab34a8783771ddc522481cbe48b /src
parent978be856218cc15f059b7e267811e7302c37b24d (diff)
Add primitive subtitle view. Remove unused Film member from Decoder hierarchy.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_decoder.cc8
-rw-r--r--src/lib/audio_decoder.h2
-rw-r--r--src/lib/decoder.cc9
-rw-r--r--src/lib/decoder.h6
-rw-r--r--src/lib/ffmpeg_content.cc6
-rw-r--r--src/lib/ffmpeg_decoder.cc34
-rw-r--r--src/lib/ffmpeg_decoder.h6
-rw-r--r--src/lib/image_decoder.cc5
-rw-r--r--src/lib/image_decoder.h2
-rw-r--r--src/lib/player.cc8
-rw-r--r--src/lib/sndfile_content.cc5
-rw-r--r--src/lib/sndfile_decoder.cc6
-rw-r--r--src/lib/sndfile_decoder.h2
-rw-r--r--src/lib/subrip_decoder.cc6
-rw-r--r--src/lib/subrip_decoder.h5
-rw-r--r--src/lib/subtitle_decoder.cc3
-rw-r--r--src/lib/subtitle_decoder.h2
-rw-r--r--src/lib/video_decoder.cc5
-rw-r--r--src/lib/video_decoder.h2
-rw-r--r--src/wx/subtitle_panel.cc30
-rw-r--r--src/wx/subtitle_panel.h6
-rw-r--r--src/wx/subtitle_view.cc89
-rw-r--r--src/wx/subtitle_view.h33
-rw-r--r--src/wx/wscript1
24 files changed, 202 insertions, 79 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index b0d0cc22f..32453cc13 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -23,7 +23,6 @@
#include "log.h"
#include "resampler.h"
#include "util.h"
-#include "film.h"
#include "i18n.h"
@@ -34,9 +33,8 @@ using std::cout;
using boost::optional;
using boost::shared_ptr;
-AudioDecoder::AudioDecoder (shared_ptr<const Film> film, shared_ptr<const AudioContent> content)
- : Decoder (film)
- , _audio_content (content)
+AudioDecoder::AudioDecoder (shared_ptr<const AudioContent> content)
+ : _audio_content (content)
{
if (content->output_audio_frame_rate() != content->content_audio_frame_rate() && content->audio_channels ()) {
_resampler.reset (new Resampler (content->content_audio_frame_rate(), content->output_audio_frame_rate(), content->audio_channels ()));
@@ -58,8 +56,6 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time)
}
if (!_audio_position) {
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
_audio_position = time;
}
diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h
index 5b68a51a1..35d9f3560 100644
--- a/src/lib/audio_decoder.h
+++ b/src/lib/audio_decoder.h
@@ -38,7 +38,7 @@ class Resampler;
class AudioDecoder : public virtual Decoder
{
public:
- AudioDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const AudioContent>);
+ AudioDecoder (boost::shared_ptr<const AudioContent>);
boost::shared_ptr<const AudioContent> audio_content () const {
return _audio_content;
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index 53a0c31e1..0901f73b0 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -21,7 +21,6 @@
* @brief Parent class for decoders of content.
*/
-#include "film.h"
#include "decoder.h"
#include "decoded.h"
@@ -30,12 +29,10 @@
using std::cout;
using boost::shared_ptr;
-/** @param f Film.
- * @param o Decode options.
+/** @param o Decode options.
*/
-Decoder::Decoder (shared_ptr<const Film> f)
- : _film (f)
- , _done (false)
+Decoder::Decoder ()
+ : _done (false)
{
}
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index aeb39d0b2..0f14dbba7 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -30,7 +30,6 @@
#include "types.h"
#include "dcpomatic_time.h"
-class Film;
class Decoded;
/** @class Decoder.
@@ -39,7 +38,7 @@ class Decoded;
class Decoder : public boost::noncopyable
{
public:
- Decoder (boost::shared_ptr<const Film>);
+ Decoder ();
virtual ~Decoder () {}
/** Seek so that the next peek() will yield the next thing
@@ -67,9 +66,6 @@ protected:
virtual bool pass () = 0;
virtual void flush () {};
- /** The Film that we are decoding in */
- boost::weak_ptr<const Film> _film;
-
std::list<boost::shared_ptr<Decoded> > _pending;
bool _done;
};
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index e9be3cc46..2b535a2ab 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -158,13 +158,13 @@ FFmpegContent::examine (shared_ptr<Job> job)
Content::examine (job);
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
-
shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this ()));
take_from_video_examiner (examiner);
ContentTime video_length = examiner->video_length ();
+
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
film->log()->log (String::compose ("Video length obtained from header as %1 frames", video_length.frames (video_frame_rate ())));
{
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 8b28a5c13..dc2a5590b 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -33,7 +33,6 @@ extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
-#include "film.h"
#include "filter.h"
#include "exceptions.h"
#include "image.h"
@@ -58,16 +57,16 @@ using boost::optional;
using boost::dynamic_pointer_cast;
using dcp::Size;
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio)
- : Decoder (f)
- , VideoDecoder (f, c)
- , AudioDecoder (f, c)
- , SubtitleDecoder (f)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> log, bool video, bool audio, bool subtitles)
+ : VideoDecoder (c)
+ , AudioDecoder (c)
, FFmpeg (c)
+ , _log (log)
, _subtitle_codec_context (0)
, _subtitle_codec (0)
, _decode_video (video)
, _decode_audio (audio)
+ , _decode_subtitles (subtitles)
, _pts_offset (0)
{
setup_subtitle ();
@@ -144,25 +143,20 @@ FFmpegDecoder::pass ()
/* Maybe we should fail here, but for now we'll just finish off instead */
char buf[256];
av_strerror (r, buf, sizeof(buf));
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
- film->log()->log (String::compose (N_("error on av_read_frame (%1) (%2)"), buf, r));
+ _log->log (String::compose (N_("error on av_read_frame (%1) (%2)"), buf, r));
}
flush ();
return true;
}
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
-
int const si = _packet.stream_index;
if (si == _video_stream && _decode_video) {
decode_video_packet ();
} else if (_ffmpeg_content->audio_stream() && _ffmpeg_content->audio_stream()->uses_index (_format_context, si) && _decode_audio) {
decode_audio_packet ();
- } else if (_ffmpeg_content->subtitle_stream() && _ffmpeg_content->subtitle_stream()->uses_index (_format_context, si) && film->with_subtitles ()) {
+ } else if (_ffmpeg_content->subtitle_stream() && _ffmpeg_content->subtitle_stream()->uses_index (_format_context, si) && _decode_subtitles) {
decode_subtitle_packet ();
}
@@ -427,9 +421,7 @@ FFmpegDecoder::decode_audio_packet ()
int const decode_result = avcodec_decode_audio4 (audio_codec_context(), _frame, &frame_finished, &copy_packet);
if (decode_result < 0) {
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
- film->log()->log (String::compose ("avcodec_decode_audio4 failed (%1)", decode_result));
+ _log->log (String::compose ("avcodec_decode_audio4 failed (%1)", decode_result));
return;
}
@@ -469,13 +461,9 @@ FFmpegDecoder::decode_video_packet ()
}
if (i == _filter_graphs.end ()) {
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
-
graph.reset (new FilterGraph (_ffmpeg_content, dcp::Size (_frame->width, _frame->height), (AVPixelFormat) _frame->format));
_filter_graphs.push_back (graph);
-
- film->log()->log (String::compose (N_("New graph for %1x%2, pixel format %3"), _frame->width, _frame->height, _frame->format));
+ _log->log (String::compose (N_("New graph for %1x%2, pixel format %3"), _frame->width, _frame->height, _frame->format));
} else {
graph = *i;
}
@@ -494,9 +482,7 @@ FFmpegDecoder::decode_video_packet ()
if (i->second != AV_NOPTS_VALUE) {
video (image, false, ContentTime::from_seconds (i->second * av_q2d (_format_context->streams[_video_stream]->time_base)) + _pts_offset);
} else {
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
- film->log()->log ("Dropping frame without PTS");
+ _log->log ("Dropping frame without PTS");
}
}
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h
index 8eadb116f..fbf802bb0 100644
--- a/src/lib/ffmpeg_decoder.h
+++ b/src/lib/ffmpeg_decoder.h
@@ -38,7 +38,7 @@ extern "C" {
#include "subtitle_decoder.h"
#include "ffmpeg.h"
-class Film;
+class Log;
class FilterGraph;
class ffmpeg_pts_offset_test;
@@ -48,7 +48,7 @@ class ffmpeg_pts_offset_test;
class FFmpegDecoder : public VideoDecoder, public AudioDecoder, public SubtitleDecoder, public FFmpeg
{
public:
- FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const FFmpegContent>, bool video, bool audio);
+ FFmpegDecoder (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Log>, bool video, bool audio, bool subtitles);
~FFmpegDecoder ();
void seek (ContentTime time, bool);
@@ -76,6 +76,7 @@ private:
int minimal_run (boost::function<bool (boost::optional<ContentTime>, boost::optional<ContentTime>, int)>);
void seek_and_flush (ContentTime);
+ boost::shared_ptr<Log> _log;
AVCodecContext* _subtitle_codec_context; ///< may be 0 if there is no subtitle
AVCodec* _subtitle_codec; ///< may be 0 if there is no subtitle
@@ -84,6 +85,7 @@ private:
bool _decode_video;
bool _decode_audio;
+ bool _decode_subtitles;
ContentTime _pts_offset;
};
diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc
index c9b17add8..58ba732bb 100644
--- a/src/lib/image_decoder.cc
+++ b/src/lib/image_decoder.cc
@@ -32,9 +32,8 @@ using std::cout;
using boost::shared_ptr;
using dcp::Size;
-ImageDecoder::ImageDecoder (shared_ptr<const Film> f, shared_ptr<const ImageContent> c)
- : Decoder (f)
- , VideoDecoder (f, c)
+ImageDecoder::ImageDecoder (shared_ptr<const ImageContent> c)
+ : VideoDecoder (c)
, _image_content (c)
{
diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h
index f4d81dfb5..13ffea13d 100644
--- a/src/lib/image_decoder.h
+++ b/src/lib/image_decoder.h
@@ -28,7 +28,7 @@ class ImageContent;
class ImageDecoder : public VideoDecoder
{
public:
- ImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>);
+ ImageDecoder (boost::shared_ptr<const ImageContent>);
boost::shared_ptr<const ImageContent> content () {
return _image_content;
diff --git a/src/lib/player.cc b/src/lib/player.cc
index e6e1f3753..e89e84aa6 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -486,7 +486,7 @@ Player::setup_pieces ()
/* FFmpeg */
shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
if (fc) {
- decoder.reset (new FFmpegDecoder (_film, fc, _video, _audio));
+ decoder.reset (new FFmpegDecoder (fc, _film->log(), _video, _audio, _film->with_subtitles ()));
frc = FrameRateChange (fc->video_frame_rate(), _film->video_frame_rate());
}
@@ -502,7 +502,7 @@ Player::setup_pieces ()
}
if (!decoder) {
- decoder.reset (new ImageDecoder (_film, ic));
+ decoder.reset (new ImageDecoder (ic));
}
frc = FrameRateChange (ic->video_frame_rate(), _film->video_frame_rate());
@@ -511,14 +511,14 @@ Player::setup_pieces ()
/* SndfileContent */
shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i);
if (sc) {
- decoder.reset (new SndfileDecoder (_film, sc));
+ decoder.reset (new SndfileDecoder (sc));
frc = best_overlap_frc;
}
/* SubRipContent */
shared_ptr<const SubRipContent> rc = dynamic_pointer_cast<const SubRipContent> (*i);
if (rc) {
- decoder.reset (new SubRipDecoder (_film, rc));
+ decoder.reset (new SubRipDecoder (rc));
frc = best_overlap_frc;
}
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index 1aa7bde61..71b549d51 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -102,10 +102,7 @@ SndfileContent::examine (shared_ptr<Job> job)
job->set_progress_unknown ();
Content::examine (job);
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
-
- SndfileDecoder dec (film, shared_from_this());
+ SndfileDecoder dec (shared_from_this());
{
boost::mutex::scoped_lock lm (_mutex);
diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc
index 3a71fab52..67bb25e0d 100644
--- a/src/lib/sndfile_decoder.cc
+++ b/src/lib/sndfile_decoder.cc
@@ -25,7 +25,6 @@
#include <sndfile.h>
#include "sndfile_content.h"
#include "sndfile_decoder.h"
-#include "film.h"
#include "exceptions.h"
#include "audio_buffers.h"
@@ -37,9 +36,8 @@ using std::min;
using std::cout;
using boost::shared_ptr;
-SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<const SndfileContent> c)
- : Decoder (f)
- , AudioDecoder (f, c)
+SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c)
+ : AudioDecoder (c)
, _sndfile_content (c)
, _deinterleave_buffer (0)
{
diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h
index aaa4c0da8..1de123917 100644
--- a/src/lib/sndfile_decoder.h
+++ b/src/lib/sndfile_decoder.h
@@ -26,7 +26,7 @@ class SndfileContent;
class SndfileDecoder : public AudioDecoder
{
public:
- SndfileDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const SndfileContent>);
+ SndfileDecoder (boost::shared_ptr<const SndfileContent>);
~SndfileDecoder ();
void seek (ContentTime, bool);
diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc
index 6ebb88323..47b6ea044 100644
--- a/src/lib/subrip_decoder.cc
+++ b/src/lib/subrip_decoder.cc
@@ -23,10 +23,8 @@
using std::list;
using boost::shared_ptr;
-SubRipDecoder::SubRipDecoder (shared_ptr<const Film> film, shared_ptr<const SubRipContent> content)
- : Decoder (film)
- , SubtitleDecoder (film)
- , SubRip (content)
+SubRipDecoder::SubRipDecoder (shared_ptr<const SubRipContent> content)
+ : SubRip (content)
, _next (0)
{
diff --git a/src/lib/subrip_decoder.h b/src/lib/subrip_decoder.h
index 26d5d5010..6025c90e2 100644
--- a/src/lib/subrip_decoder.h
+++ b/src/lib/subrip_decoder.h
@@ -28,8 +28,9 @@ class SubRipContent;
class SubRipDecoder : public SubtitleDecoder, public SubRip
{
public:
- SubRipDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const SubRipContent>);
-
+ SubRipDecoder (boost::shared_ptr<const SubRipContent>);
+
+protected:
bool pass ();
private:
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc
index cf5550e42..a9674fe92 100644
--- a/src/lib/subtitle_decoder.cc
+++ b/src/lib/subtitle_decoder.cc
@@ -24,8 +24,7 @@ using std::list;
using boost::shared_ptr;
using boost::optional;
-SubtitleDecoder::SubtitleDecoder (shared_ptr<const Film> f)
- : Decoder (f)
+SubtitleDecoder::SubtitleDecoder ()
{
}
diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h
index e2bd9c9d6..78ee6801e 100644
--- a/src/lib/subtitle_decoder.h
+++ b/src/lib/subtitle_decoder.h
@@ -34,7 +34,7 @@ class Image;
class SubtitleDecoder : public virtual Decoder
{
public:
- SubtitleDecoder (boost::shared_ptr<const Film>);
+ SubtitleDecoder ();
protected:
void image_subtitle (boost::shared_ptr<Image>, dcpomatic::Rect<double>, ContentTime, ContentTime);
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index e4d5516a1..15f91b892 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -26,9 +26,8 @@ using std::cout;
using boost::shared_ptr;
using boost::optional;
-VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<const VideoContent> c)
- : Decoder (f)
- , _video_content (c)
+VideoDecoder::VideoDecoder (shared_ptr<const VideoContent> c)
+ : _video_content (c)
{
}
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index d8c362354..c3228e88d 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -33,7 +33,7 @@ class Image;
class VideoDecoder : public virtual Decoder
{
public:
- VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const VideoContent>);
+ VideoDecoder (boost::shared_ptr<const VideoContent>);
boost::shared_ptr<const VideoContent> video_content () const {
return _video_content;
diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc
index 63a18b0ce..b4b5a7b42 100644
--- a/src/wx/subtitle_panel.cc
+++ b/src/wx/subtitle_panel.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,9 +20,11 @@
#include <boost/lexical_cast.hpp>
#include <wx/spinctrl.h>
#include "lib/ffmpeg_content.h"
+#include "lib/subrip_content.h"
#include "subtitle_panel.h"
#include "film_editor.h"
#include "wx_util.h"
+#include "subtitle_view.h"
using std::vector;
using std::string;
@@ -32,6 +34,7 @@ using boost::dynamic_pointer_cast;
SubtitlePanel::SubtitlePanel (FilmEditor* e)
: FilmEditorPanel (e, _("Subtitles"))
+ , _view (0)
{
wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
_sizer->Add (grid, 0, wxALL, 8);
@@ -70,6 +73,9 @@ SubtitlePanel::SubtitlePanel (FilmEditor* e)
add_label_to_sizer (grid, this, _("Subtitle Stream"), true);
_stream = new wxChoice (this, wxID_ANY);
grid->Add (_stream, 1, wxEXPAND);
+
+ _view_button = new wxButton (this, wxID_ANY, _("View..."));
+ grid->Add (_view_button);
_x_offset->SetRange (-100, 100);
_y_offset->SetRange (-100, 100);
@@ -81,6 +87,7 @@ SubtitlePanel::SubtitlePanel (FilmEditor* e)
_y_offset->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::y_offset_changed, this));
_scale->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::scale_changed, this));
_stream->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&SubtitlePanel::stream_changed, this));
+ _view_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::view_clicked, this));
}
void
@@ -164,6 +171,9 @@ SubtitlePanel::setup_sensitivity ()
_y_offset->Enable (j);
_scale->Enable (j);
_stream->Enable (j);
+
+ SubtitleContentList c = _editor->selected_subtitle_content ();
+ _view_button->Enable (c.size() == 1);
}
void
@@ -223,3 +233,21 @@ SubtitlePanel::content_selection_changed ()
film_content_changed (SubtitleContentProperty::SUBTITLE_Y_OFFSET);
film_content_changed (SubtitleContentProperty::SUBTITLE_SCALE);
}
+
+void
+SubtitlePanel::view_clicked ()
+{
+ if (_view) {
+ _view->Destroy ();
+ _view = 0;
+ }
+
+ SubtitleContentList c = _editor->selected_subtitle_content ();
+ assert (c.size() == 1);
+ shared_ptr<SubRipContent> sr = dynamic_pointer_cast<SubRipContent> (c.front ());
+ if (sr) {
+ _view = new SubtitleView (this, sr);
+ }
+
+ _view->Show ();
+}
diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h
index 20d7c40c2..1ee775025 100644
--- a/src/wx/subtitle_panel.h
+++ b/src/wx/subtitle_panel.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
class wxCheckBox;
class wxSpinCtrl;
+class SubtitleView;
class SubtitlePanel : public FilmEditorPanel
{
@@ -37,6 +38,7 @@ private:
void y_offset_changed ();
void scale_changed ();
void stream_changed ();
+ void view_clicked ();
void setup_sensitivity ();
@@ -45,4 +47,6 @@ private:
wxSpinCtrl* _y_offset;
wxSpinCtrl* _scale;
wxChoice* _stream;
+ wxButton* _view_button;
+ SubtitleView* _view;
};
diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc
new file mode 100644
index 000000000..f6fbd9a9a
--- /dev/null
+++ b/src/wx/subtitle_view.cc
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/subrip_decoder.h"
+#include "lib/decoded.h"
+#include "subtitle_view.h"
+
+using std::list;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<SubRipContent> content)
+ : wxDialog (parent, wxID_ANY, _("Subtitles"))
+{
+ _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
+
+ {
+ wxListItem ip;
+ ip.SetId (0);
+ ip.SetText (_("Start"));
+ ip.SetWidth (100);
+ _list->InsertColumn (0, ip);
+ }
+
+ {
+ wxListItem ip;
+ ip.SetId (1);
+ ip.SetText (_("End"));
+ ip.SetWidth (100);
+ _list->InsertColumn (1, ip);
+ }
+
+ {
+ wxListItem ip;
+ ip.SetId (2);
+ ip.SetText (_("Subtitle"));
+ ip.SetWidth (640);
+ _list->InsertColumn (2, ip);
+ }
+
+ wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+ sizer->Add (_list, 1, wxEXPAND);
+
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ if (buttons) {
+ sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ shared_ptr<SubRipDecoder> decoder (new SubRipDecoder (content));
+ int n = 0;
+ while (1) {
+ shared_ptr<Decoded> dec = decoder->peek ();
+ if (!dec) {
+ break;
+ }
+
+ shared_ptr<DecodedTextSubtitle> sub = dynamic_pointer_cast<DecodedTextSubtitle> (dec);
+ assert (sub);
+
+ for (list<dcp::SubtitleString>::const_iterator i = sub->subs.begin(); i != sub->subs.end(); ++i) {
+ wxListItem list_item;
+ list_item.SetId (n);
+ _list->InsertItem (list_item);
+ _list->SetItem (n, 2, i->text ());
+ ++n;
+ }
+
+ decoder->consume ();
+ }
+
+ SetSizerAndFit (sizer);
+}
+
diff --git a/src/wx/subtitle_view.h b/src/wx/subtitle_view.h
new file mode 100644
index 000000000..94a25b70c
--- /dev/null
+++ b/src/wx/subtitle_view.h
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/shared_ptr.hpp>
+#include <wx/wx.h>
+#include <wx/listctrl.h>
+
+class SubRipContent;
+
+class SubtitleView : public wxDialog
+{
+public:
+ SubtitleView (wxWindow *, boost::shared_ptr<SubRipContent>);
+
+private:
+ wxListCtrl* _list;
+};
diff --git a/src/wx/wscript b/src/wx/wscript
index 1ffaa6097..45a5bc96d 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -35,6 +35,7 @@ sources = """
server_dialog.cc
servers_list_dialog.cc
subtitle_panel.cc
+ subtitle_view.cc
timecode.cc
timeline.cc
timeline_dialog.cc