Merge branch 'master' into 1.0
[libdcp.git] / src / subtitle_string.h
1 /*
2     Copyright (C) 2012-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 #ifndef LIBDCP_SUBTITLE_STRING_H
21 #define LIBDCP_SUBTITLE_STRING_H
22
23 #include "types.h"
24 #include "dcp_time.h"
25 #include <string>
26
27 namespace dcp {
28
29 class SubtitleString
30 {
31 public:
32         SubtitleString (
33                 std::string font,
34                 bool italic,
35                 Color color,
36                 int size,
37                 Time in,
38                 Time out,
39                 float v_position,
40                 VAlign v_align,
41                 std::string text,
42                 Effect effect,
43                 Color effect_color,
44                 Time fade_up_time,
45                 Time fade_down_time
46                 );
47
48         std::string font () const {
49                 return _font;
50         }
51
52         bool italic () const {
53                 return _italic;
54         }
55
56         Color color () const {
57                 return _color;
58         }
59
60         Time in () const {
61                 return _in;
62         }
63
64         Time out () const {
65                 return _out;
66         }
67
68         std::string text () const {
69                 return _text;
70         }
71
72         float v_position () const {
73                 return _v_position;
74         }
75
76         VAlign v_align () const {
77                 return _v_align;
78         }
79
80         Effect effect () const {
81                 return _effect;
82         }
83
84         Color effect_color () const {
85                 return _effect_color;
86         }
87
88         Time fade_up_time () const {
89                 return _fade_up_time;
90         }
91
92         Time fade_down_time () const {
93                 return _fade_down_time;
94         }
95
96         int size () const {
97                 return _size;
98         }
99         
100         int size_in_pixels (int screen_height) const;
101
102 private:
103         std::string _font;
104         bool _italic;
105         Color _color;
106         /** Size in points as if the screen height is 11 inches, so a 72pt font
107          *  would be 1/11th of the screen height.
108          */ 
109         int _size;
110         Time _in;
111         Time _out;
112         /** Vertical position as a proportion of the screen height from the top
113          *  (between 0 and 1)
114          */
115         float _v_position;
116         VAlign _v_align;
117         std::string _text;
118         Effect _effect;
119         Color _effect_color;
120         Time _fade_up_time;
121         Time _fade_down_time;
122 };
123
124 bool operator== (SubtitleString const & a, SubtitleString const & b);
125 std::ostream& operator<< (std::ostream& s, SubtitleString const & sub);
126
127 }
128
129 #endif