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.
23 #include "parse/subtitle.h"
47 std::string font () const {
51 bool italic () const {
55 Color color () const {
67 std::string text () const {
71 float v_position () const {
75 VAlign v_align () const {
79 Effect effect () const {
83 Color effect_color () const {
87 Time fade_up_time () const {
91 Time fade_down_time () const {
92 return _fade_down_time;
99 int size_in_pixels (int screen_height) const;
114 Time _fade_down_time;
117 bool operator== (Subtitle const & a, Subtitle const & b);
118 std::ostream& operator<< (std::ostream& s, Subtitle const & sub);
120 class SubtitleAsset : public Asset
123 SubtitleAsset (std::string directory, std::string xml_file);
124 SubtitleAsset (std::string directory, std::string movie_title, std::string language);
126 void write_to_cpl (xmlpp::Node *) const;
127 virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
129 note (ERROR, "subtitle assets not compared yet");
133 std::string language () const {
137 std::list<boost::shared_ptr<Subtitle> > subtitles_at (Time t) const;
138 std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
142 void add (boost::shared_ptr<Subtitle>);
144 void read_xml (std::string);
145 void write_xml () const;
146 void write_xml (std::ostream &) const;
149 std::string font_id_to_name (std::string id) const;
152 std::list<boost::shared_ptr<parse::Font> > font_nodes;
153 std::list<boost::shared_ptr<parse::Text> > text_nodes;
154 std::list<boost::shared_ptr<parse::Subtitle> > subtitle_nodes;
157 void maybe_add_subtitle (std::string text, ParseState const & parse_state);
159 void examine_font_nodes (
160 boost::shared_ptr<const cxml::Node> xml,
161 std::list<boost::shared_ptr<parse::Font> > const & font_nodes,
162 ParseState& parse_state
165 void examine_text_nodes (
166 boost::shared_ptr<const cxml::Node> xml,
167 std::list<boost::shared_ptr<parse::Text> > const & text_nodes,
168 ParseState& parse_state
171 std::string _movie_title;
172 /* strangely, this is sometimes a string */
173 std::string _reel_number;
174 std::string _language;
175 std::list<boost::shared_ptr<parse::LoadFont> > _load_font_nodes;
177 std::list<boost::shared_ptr<Subtitle> > _subtitles;