Supporters update.
[dcpomatic.git] / src / lib / content_text.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
22 #ifndef DCPOMATIC_CONTENT_TEXT_H
23 #define DCPOMATIC_CONTENT_TEXT_H
24
25
26 #include "bitmap_text.h"
27 #include "dcpomatic_time.h"
28 #include "rect.h"
29 #include "string_text.h"
30 #include "types.h"
31 #include <dcp/subtitle_string.h>
32 #include <vector>
33
34
35 class Image;
36
37
38 class ContentText
39 {
40 public:
41         explicit ContentText (dcpomatic::ContentTime f)
42                 : _from (f)
43         {}
44
45         dcpomatic::ContentTime from () const {
46                 return _from;
47         }
48
49 private:
50         dcpomatic::ContentTime _from;
51 };
52
53
54 class ContentBitmapText : public ContentText
55 {
56 public:
57         ContentBitmapText (dcpomatic::ContentTime from)
58                 : ContentText(from)
59         {}
60
61         ContentBitmapText (dcpomatic::ContentTime f, std::shared_ptr<const Image> im, dcpomatic::Rect<double> r)
62                 : ContentText (f)
63                 , subs{ {im, r} }
64         {}
65
66         /* Our texts, with their rectangles unmodified by any offsets or scales that the content specifies */
67         std::vector<BitmapText> subs;
68 };
69
70
71 /** A text caption.  We store the time period separately (as well as in the dcp::SubtitleStrings)
72  *  as the dcp::SubtitleString timings are sometimes quite heavily quantised and this causes problems
73  *  when we want to compare the quantised periods to the unquantised ones.
74  */
75 class ContentStringText : public ContentText
76 {
77 public:
78         ContentStringText (dcpomatic::ContentTime f, std::vector<StringText> s)
79                 : ContentText (f)
80                 , subs (s)
81         {}
82
83         std::vector<StringText> subs;
84 };
85
86
87 #endif