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>
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 Content
139 SubtitleAsset (boost::filesystem::path 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 Content>, 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 write_xml () const;
161 Glib::ustring xml_as_string () const;
164 std::string font_id_to_name (std::string id) const;
167 std::list<boost::shared_ptr<parse::Font> > font_nodes;
168 std::list<boost::shared_ptr<parse::Text> > text_nodes;
169 std::list<boost::shared_ptr<parse::Subtitle> > subtitle_nodes;
172 void maybe_add_subtitle (std::string text, ParseState const & parse_state);
174 void examine_font_nodes (
175 boost::shared_ptr<const cxml::Node> xml,
176 std::list<boost::shared_ptr<parse::Font> > const & font_nodes,
177 ParseState& parse_state
180 void examine_text_nodes (
181 boost::shared_ptr<const cxml::Node> xml,
182 std::list<boost::shared_ptr<parse::Text> > const & text_nodes,
183 ParseState& parse_state
186 std::string _movie_title;
187 /* strangely, this is sometimes a string */
188 std::string _reel_number;
189 std::string _language;
190 std::list<boost::shared_ptr<parse::LoadFont> > _load_font_nodes;
192 std::list<boost::shared_ptr<Subtitle> > _subtitles;