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 #ifndef LIBDCP_SUBTITLE_ASSET_H
21 #define LIBDCP_SUBTITLE_ASSET_H
23 #include <libcxml/cxml.h>
24 #include "content_asset.h"
57 std::string font () const {
61 bool italic () const {
65 Color color () const {
77 std::string text () const {
81 float v_position () const {
85 VAlign v_align () const {
89 Effect effect () const {
93 Color effect_color () const {
97 Time fade_up_time () const {
101 Time fade_down_time () const {
102 return _fade_down_time;
109 int size_in_pixels (int screen_height) const;
115 /** Size in points as if the screen height is 11 inches, so a 72pt font
116 * would be 1/11th of the screen height.
121 /** Vertical position as a proportion of the screen height from the top
130 Time _fade_down_time;
133 bool operator== (Subtitle const & a, Subtitle const & b);
134 std::ostream& operator<< (std::ostream& s, Subtitle const & sub);
136 class SubtitleAsset : public ContentAsset
139 SubtitleAsset (std::string directory, std::string xml_file);
140 SubtitleAsset (std::string directory, std::string movie_title, std::string language);
142 void write_to_cpl (xmlpp::Element *) const;
143 virtual bool equals (boost::shared_ptr<const ContentAsset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
145 note (ERROR, "subtitle assets not compared yet");
149 std::string language () const {
153 std::list<boost::shared_ptr<Subtitle> > subtitles_at (Time t) const;
154 std::list<boost::shared_ptr<Subtitle> > const & subtitles () const {
158 void add (boost::shared_ptr<Subtitle>);
160 void read_xml (std::string);
161 void write_xml () const;
162 Glib::ustring xml_as_string () const;
165 std::string font_id_to_name (std::string id) const;
168 std::list<boost::shared_ptr<parse::Font> > font_nodes;
169 std::list<boost::shared_ptr<parse::Text> > text_nodes;
170 std::list<boost::shared_ptr<parse::Subtitle> > subtitle_nodes;
173 void maybe_add_subtitle (std::string text, ParseState const & parse_state);
175 void examine_font_nodes (
176 boost::shared_ptr<const cxml::Node> xml,
177 std::list<boost::shared_ptr<parse::Font> > const & font_nodes,
178 ParseState& parse_state
181 void examine_text_nodes (
182 boost::shared_ptr<const cxml::Node> xml,
183 std::list<boost::shared_ptr<parse::Text> > const & text_nodes,
184 ParseState& parse_state
187 std::string _movie_title;
188 /* strangely, this is sometimes a string */
189 std::string _reel_number;
190 std::string _language;
191 std::list<boost::shared_ptr<parse::LoadFont> > _load_font_nodes;
193 std::list<boost::shared_ptr<Subtitle> > _subtitles;