libdcp
text_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_TEXT_STRING_H
41 #define LIBDCP_TEXT_STRING_H
42 
43 
44 #include "dcp_time.h"
45 #include "ruby.h"
46 #include "text.h"
47 #include <boost/optional.hpp>
48 #include <string>
49 
50 
51 namespace dcp {
52 
53 
57 class TextString : public Text
58 {
59 public:
83  TextString(
84  boost::optional<std::string> font,
85  bool italic,
86  bool bold,
87  bool underline,
88  Colour colour,
89  int size,
90  float aspect_adjust,
91  Time in,
92  Time out,
93  float h_position,
94  HAlign h_align,
95  float v_position,
96  VAlign v_align,
97  float z_position,
98  Direction direction,
99  std::string text,
100  Effect effect,
101  Colour effect_colour,
102  Time fade_up_time,
103  Time fade_down_time,
104  float space_before,
105  std::vector<Ruby> rubies
106  );
107 
109  boost::optional<std::string> font () const {
110  return _font;
111  }
112 
113  bool italic () const {
114  return _italic;
115  }
116 
117  bool bold () const {
118  return _bold;
119  }
120 
121  bool underline () const {
122  return _underline;
123  }
124 
125  Colour colour () const {
126  return _colour;
127  }
128 
129  std::string text () const {
130  return _text;
131  }
132 
133  Direction direction () const {
134  return _direction;
135  }
136 
137  Effect effect () const {
138  return _effect;
139  }
140 
141  Colour effect_colour () const {
142  return _effect_colour;
143  }
144 
145  int size () const {
146  return _size;
147  }
148 
149  float size_in_pixels (int screen_height) const;
150 
151  float space_before () const {
152  return _space_before;
153  }
154 
159  float aspect_adjust () const {
160  return _aspect_adjust;
161  }
162 
163  std::vector<Ruby> const& rubies() const {
164  return _rubies;
165  }
166 
167  void set_font (std::string id) {
168  _font = id;
169  }
170 
171  void unset_font () {
172  _font = boost::optional<std::string>();
173  }
174 
175  void set_size (int s) {
176  _size = s;
177  }
178 
179  void set_aspect_adjust (float a) {
180  _aspect_adjust = a;
181  }
182 
183  void set_text (std::string t) {
184  _text = t;
185  }
186 
187  void set_colour (Colour c) {
188  _colour = c;
189  }
190 
191  void set_effect (Effect e) {
192  _effect = e;
193  }
194 
195  void set_effect_colour (Colour c) {
196  _effect_colour = c;
197  }
198 
199  void set_rubies(std::vector<Ruby> rubies) {
200  _rubies = std::move(rubies);
201  }
202 
203  bool equals(std::shared_ptr<const dcp::Text> other_sub, EqualityOptions const& options, NoteHandler node) const override;
204 
205 private:
207  boost::optional<std::string> _font;
209  bool _italic;
211  bool _bold;
219  int _size;
220  float _aspect_adjust;
221  Direction _direction;
222  std::string _text;
223  Effect _effect;
224  Colour _effect_colour;
225  float _space_before;
226  std::vector<Ruby> _rubies;
227 };
228 
229 
230 bool operator==(TextString const & a, TextString const & b);
231 bool operator!=(TextString const & a, TextString const & b);
232 std::ostream& operator<<(std::ostream& s, TextString const & sub);
233 
234 
235 }
236 
237 
238 #endif
239 
An RGB colour.
Definition: types.h:224
A single line of subtitle text with all the associated attributes.
Definition: text_string.h:58
TextString(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, float z_position, Direction direction, std::string text, Effect effect, Colour effect_colour, Time fade_up_time, Time fade_down_time, float space_before, std::vector< Ruby > rubies)
Definition: text_string.cc:57
boost::optional< std::string > _font
Definition: text_string.h:207
float aspect_adjust() const
Definition: text_string.h:159
boost::optional< std::string > font() const
Definition: text_string.h:109
Definition: text.h:56
Time in() const
Definition: text.h:61
Time out() const
Definition: text.h:66
float v_position() const
Definition: text.h:82
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:145
HAlign
Definition: h_align.h:46
VAlign
Definition: v_align.h:46
Text class.