2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
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.
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.
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.
24 #include <libcxml/cxml.h>
25 #include <boost/lexical_cast.hpp>
29 using boost::optional;
30 using boost::shared_ptr;
31 using boost::lexical_cast;
34 Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node, int tcr)
36 in = Time (node->string_attribute ("TimeIn"), tcr);
37 out = Time (node->string_attribute ("TimeOut"), tcr);
39 list<cxml::NodePtr> f = node->node_children ("Font");
40 for (list<cxml::NodePtr>::iterator i = f.begin(); i != f.end(); ++i) {
41 font_nodes.push_back (shared_ptr<Font> (new Font (*i, tcr)));
44 list<cxml::NodePtr> t = node->node_children ("Text");
45 for (list<cxml::NodePtr>::iterator i = t.begin(); i != t.end(); ++i) {
46 text_nodes.push_back (shared_ptr<Text> (new Text (*i, tcr)));
49 fade_up_time = fade_time (node, "FadeUpTime", tcr);
50 fade_down_time = fade_time (node, "FadeDownTime", tcr);
54 Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name, int tcr)
56 string const u = node->optional_string_attribute (name).get_value_or ("");
60 t = Time (0, 0, 0, 20, 250);
61 } else if (u.find (":") != string::npos) {
64 t = Time (0, 0, 0, lexical_cast<int> (u), tcr);
67 if (t > Time (0, 0, 8, 0, 250)) {
68 t = Time (0, 0, 8, 0, 250);