ad83fcb89b3dd1b363cdd3c785a92b890462df96
[dcpomatic.git] / src / lib / content_caption.h
1 /*
2     Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_CONTENT_TEXT_H
22 #define DCPOMATIC_CONTENT_TEXT_H
23
24 #include "dcpomatic_time.h"
25 #include "rect.h"
26 #include "types.h"
27 #include "bitmap_caption.h"
28 #include <dcp/subtitle_string.h>
29 #include <list>
30
31 class Image;
32
33 class ContentCaption
34 {
35 public:
36         explicit ContentCaption (ContentTime f, CaptionType t)
37                 : _from (f)
38                 , _type (t)
39         {}
40
41         ContentTime from () const {
42                 return _from;
43         }
44
45         CaptionType type () const {
46                 return _type;
47         }
48
49 private:
50         ContentTime _from;
51         CaptionType _type;
52 };
53
54 class ContentBitmapCaption : public ContentCaption
55 {
56 public:
57         ContentBitmapCaption (ContentTime f, CaptionType type, boost::shared_ptr<Image> im, dcpomatic::Rect<double> r)
58                 : ContentCaption (f, type)
59                 , sub (im, r)
60         {}
61
62         /* Our text, with its rectangle unmodified by any offsets or scales that the content specifies */
63         BitmapCaption sub;
64 };
65
66 /** A text caption.  We store the time period separately (as well as in the dcp::SubtitleStrings)
67  *  as the dcp::SubtitleString timings are sometimes quite heavily quantised and this causes problems
68  *  when we want to compare the quantised periods to the unquantised ones.
69  */
70 class ContentTextCaption : public ContentCaption
71 {
72 public:
73         ContentTextCaption (ContentTime f, CaptionType type, std::list<dcp::SubtitleString> s)
74                 : ContentCaption (f, type)
75                 , subs (s)
76         {}
77
78         std::list<dcp::SubtitleString> subs;
79 };
80
81 #endif