2 Copyright (C) 2012 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.
20 #include <libcxml/cxml.h>
54 std::string font () const {
58 bool italic () const {
62 Color color () const {
74 std::string text () const {
78 float v_position () const {
82 VAlign v_align () const {
86 Effect effect () const {
90 Color effect_color () const {
94 Time fade_up_time () const {
98 Time fade_down_time () const {
99 return _fade_down_time;
106 int size_in_pixels (int screen_height) const;
121 Time _fade_down_time;
124 bool operator== (Subtitle const & a, Subtitle const & b);
125 std::ostream& operator<< (std::ostream& s, Subtitle const & sub);
127 class SubtitleAsset : public Asset
130 SubtitleAsset (std::string directory, std::string xml_file);
131 SubtitleAsset (std::string directory, std::string movie_title, std::string language);
133 void write_to_cpl (xmlpp::Node *, bool) const;
134 virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
136 note (ERROR, "subtitle assets not compared yet");
140 std::string language () const {
144 std::list<boost::shared_ptr<Subtitle> > subtitles_at (Time t) const;
145 std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
149 void add (boost::shared_ptr<Subtitle>);
151 void read_xml (std::string);
152 void write_xml () const;
153 void write_xml (std::ostream &) const;
156 std::string font_id_to_name (std::string id) const;
159 std::list<boost::shared_ptr<parse::Font> > font_nodes;
160 std::list<boost::shared_ptr<parse::Text> > text_nodes;
161 std::list<boost::shared_ptr<parse::Subtitle> > subtitle_nodes;
164 void maybe_add_subtitle (std::string text, ParseState const & parse_state);
166 void examine_font_nodes (
167 boost::shared_ptr<const cxml::Node> xml,
168 std::list<boost::shared_ptr<parse::Font> > const & font_nodes,
169 ParseState& parse_state
172 void examine_text_nodes (
173 boost::shared_ptr<const cxml::Node> xml,
174 std::list<boost::shared_ptr<parse::Text> > const & text_nodes,
175 ParseState& parse_state
178 std::string _movie_title;
179 /* strangely, this is sometimes a string */
180 std::string _reel_number;
181 std::string _language;
182 std::list<boost::shared_ptr<parse::LoadFont> > _load_font_nodes;
184 std::list<boost::shared_ptr<Subtitle> > _subtitles;