libdcp
subtitle_string.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3 
4  This file is part of libdcp.
5 
6  libdcp 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  libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
18 
19  In addition, as a special exception, the copyright holders give
20  permission to link the code of portions of this program with the
21  OpenSSL library under certain conditions as described in each
22  individual source file, and distribute linked combinations
23  including the two.
24 
25  You must obey the GNU General Public License in all respects
26  for all of the code used other than OpenSSL. If you modify
27  file(s) with this exception, you may extend this exception to your
28  version of the file(s), but you are not obligated to do so. If you
29  do not wish to do so, delete this exception statement from your
30  version. If you delete this exception statement from all source
31  files in the program, then also delete it here.
32 */
33 
34 
40 #ifndef LIBDCP_SUBTITLE_STRING_H
41 #define LIBDCP_SUBTITLE_STRING_H
42 
43 
44 #include "types.h"
45 #include "subtitle.h"
46 #include "dcp_time.h"
47 #include <boost/optional.hpp>
48 #include <string>
49 
50 
51 namespace dcp {
52 
53 
57 class SubtitleString : public Subtitle
58 {
59 public:
82  boost::optional<std::string> font,
83  bool italic,
84  bool bold,
85  bool underline,
86  Colour colour,
87  int size,
88  float aspect_adjust,
89  Time in,
90  Time out,
91  float h_position,
92  HAlign h_align,
93  float v_position,
94  VAlign v_align,
95  Direction direction,
96  std::string text,
97  Effect effect,
98  Colour effect_colour,
99  Time fade_up_time,
100  Time fade_down_time,
101  float space_before
102  );
103 
105  boost::optional<std::string> font () const {
106  return _font;
107  }
108 
109  bool italic () const {
110  return _italic;
111  }
112 
113  bool bold () const {
114  return _bold;
115  }
116 
117  bool underline () const {
118  return _underline;
119  }
120 
121  Colour colour () const {
122  return _colour;
123  }
124 
125  std::string text () const {
126  return _text;
127  }
128 
129  Direction direction () const {
130  return _direction;
131  }
132 
133  Effect effect () const {
134  return _effect;
135  }
136 
137  Colour effect_colour () const {
138  return _effect_colour;
139  }
140 
141  int size () const {
142  return _size;
143  }
144 
145  int size_in_pixels (int screen_height) const;
146 
147  float space_before () const {
148  return _space_before;
149  }
150 
155  float aspect_adjust () const {
156  return _aspect_adjust;
157  }
158 
159  void set_font (std::string id) {
160  _font = id;
161  }
162 
163  void unset_font () {
164  _font = boost::optional<std::string>();
165  }
166 
167  void set_size (int s) {
168  _size = s;
169  }
170 
171  void set_aspect_adjust (float a) {
172  _aspect_adjust = a;
173  }
174 
175  void set_text (std::string t) {
176  _text = t;
177  }
178 
179  void set_colour (Colour c) {
180  _colour = c;
181  }
182 
183  void set_effect (Effect e) {
184  _effect = e;
185  }
186 
187  void set_effect_colour (Colour c) {
188  _effect_colour = c;
189  }
190 
191 private:
193  boost::optional<std::string> _font;
195  bool _italic;
197  bool _bold;
205  int _size;
206  float _aspect_adjust;
207  Direction _direction;
208  std::string _text;
209  Effect _effect;
210  Colour _effect_colour;
211  float _space_before;
212 };
213 
214 bool operator== (SubtitleString const & a, SubtitleString const & b);
215 bool operator!= (SubtitleString const & a, SubtitleString const & b);
216 std::ostream& operator<< (std::ostream& s, SubtitleString const & sub);
217 
218 
219 }
220 
221 
222 #endif
An RGB colour.
Definition: types.h:301
A single line of subtitle text with all the associated attributes.
SubtitleString(boost::optional< std::string > font, bool italic, bool bold, bool underline, Colour colour, int size, float aspect_adjust, Time in, Time out, float h_position, HAlign h_align, float v_position, VAlign v_align, Direction direction, std::string text, Effect effect, Colour effect_colour, Time fade_up_time, Time fade_down_time, float space_before)
float aspect_adjust() const
boost::optional< std::string > _font
boost::optional< std::string > font() const
float v_position() const
Definition: subtitle.h:77
Time in() const
Definition: subtitle.h:56
Time out() const
Definition: subtitle.h:61
A representation of time within a DCP.
Definition: dcp_time.h:73
Time class.
Namespace for everything in libdcp.
Definition: array_data.h:50
Direction
Definition: types.h:191
HAlign
Definition: types.h:166
VAlign
Definition: types.h:178
Subtitle class.
Miscellaneous types.