/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-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
*/
-#include <list>
#include <boost/shared_ptr.hpp>
-#include "util.h"
+#include <boost/weak_ptr.hpp>
+#include <boost/optional.hpp>
+#include <libdcp/util.h>
+#include "rect.h"
+#include "types.h"
-struct AVSubtitle;
-class SubtitleImage;
-class SimpleImage;
-class FilmState;
+class Film;
+class Piece;
+class Image;
class Subtitle
{
public:
- Subtitle (AVSubtitle const &);
- bool displayed_at (double t);
+ Subtitle (boost::shared_ptr<const Film>, libdcp::Size, boost::weak_ptr<Piece>, boost::shared_ptr<Image>, dcpomatic::Rect<double>, Time, Time);
- std::list<boost::shared_ptr<SubtitleImage> > images () const {
- return _images;
+ void update (boost::shared_ptr<const Film>, libdcp::Size);
+ void set_stop (Time t) {
+ _stop = t;
+ check_out_to ();
}
-private:
- /** display from time in seconds from the start of the film */
- double _from;
- /** display to time in seconds from the start of the film */
- double _to;
- std::list<boost::shared_ptr<SubtitleImage> > _images;
-};
-
-extern Rectangle transformed_subtitle_area (
- float target_x_scale, float target_y_scale,
- Rectangle sub_area,
- boost::shared_ptr<FilmState> fs
- );
-
-class SubtitleImage
-{
-public:
- SubtitleImage (AVSubtitleRect const *);
+ bool covers (Time t) const;
+ bool ends_before (Time t) const {
+ return _out_to < t;
+ }
- void set_position (Position p) {
- _position = p;
+ boost::shared_ptr<Image> out_image () const {
+ return _out_image;
}
- Position position () const {
- return _position;
+ Position<int> out_position () const {
+ return _out_position;
}
- boost::shared_ptr<SimpleImage> image () const {
- return _image;
- }
-
private:
- Position _position;
- boost::shared_ptr<SimpleImage> _image;
+ void check_out_to ();
+
+ boost::weak_ptr<Piece> _piece;
+ boost::shared_ptr<Image> _in_image;
+ dcpomatic::Rect<double> _in_rect;
+ Time _in_from;
+ Time _in_to;
+
+ boost::shared_ptr<Image> _out_image;
+ Position<int> _out_position;
+ Time _out_from;
+ Time _out_to;
+
+ /** Time at which this subtitle should stop (overriding _out_to) */
+ boost::optional<Time> _stop;
};