Merge.
[dcpomatic.git] / src / lib / subtitle.h
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <boost/shared_ptr.hpp>
21 #include <boost/weak_ptr.hpp>
22 #include <boost/optional.hpp>
23 #include <libdcp/util.h>
24 #include "rect.h"
25 #include "types.h"
26
27 class Film;
28 class Piece;
29 class Image;
30
31 class Subtitle
32 {
33 public:
34
35         Subtitle (boost::shared_ptr<const Film>, libdcp::Size, boost::weak_ptr<Piece>, boost::shared_ptr<Image>, dcpomatic::Rect<double>, Time, Time);
36
37         void update (boost::shared_ptr<const Film>, libdcp::Size);
38         void set_stop (Time t) {
39                 _stop = t;
40                 check_out_to ();
41         }
42
43         bool covers (Time t) const;
44         bool ends_before (Time t) const {
45                 return _out_to < t;
46         }
47
48         boost::shared_ptr<Image> out_image () const {
49                 return _out_image;
50         }
51
52         Position<int> out_position () const {
53                 return _out_position;
54         }
55         
56 private:
57         void check_out_to ();
58         
59         boost::weak_ptr<Piece> _piece;
60         boost::shared_ptr<Image> _in_image;
61         dcpomatic::Rect<double> _in_rect;
62         Time _in_from;
63         Time _in_to;
64
65         boost::shared_ptr<Image> _out_image;
66         Position<int> _out_position;
67         Time _out_from;
68         Time _out_to;
69
70         /** Time at which this subtitle should stop (overriding _out_to) */
71         boost::optional<Time> _stop;
72 };