Fix hidden advanced preferences button in some locales (e.g. de_DE).
[dcpomatic.git] / src / lib / subtitle.h
index 18d2590ebf62c6617f377e43bff36ee2e6133baa..c74f5c1b9f0c7c6c775dc368aea684eea1048f82 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    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 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;
-};
+       bool covers (Time t) const;
+       bool ends_before (Time t) const {
+               return _out_to < t;
+       }
 
-class SubtitleImage
-{
-public:
-       SubtitleImage (AVSubtitleRect const *);
+       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;
 };