diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-08-22 15:00:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-08-22 15:00:33 +0100 |
| commit | 8b8bce8d2a83739f96e02a48b77d352414361c43 (patch) | |
| tree | 08abcadb9fa0ba92a6e75d6f6a21383341ba656f /src | |
| parent | a3bbf59dd06dda14f070e99aaee32bb29a13f51a (diff) | |
Allow <Font> nodes inside <Subtitle> nodes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/subtitle_asset.cc | 85 | ||||
| -rw-r--r-- | src/subtitle_asset.h | 17 |
2 files changed, 69 insertions, 33 deletions
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index a80fdec2..ee74e5eb 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -43,46 +43,65 @@ SubtitleAsset::SubtitleAsset (string directory, string xml) */ list<shared_ptr<FontNode> > current_font_nodes; - for (list<shared_ptr<FontNode> >::iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) { - examine_font_node (*i, current_font_nodes); - } + list<shared_ptr<SubtitleNode> > current_subtitle_nodes; + current_subtitle_nodes.push_back (shared_ptr<SubtitleNode> ()); + examine_font_nodes (font_nodes, current_font_nodes, current_subtitle_nodes); } void -SubtitleAsset::examine_font_node (shared_ptr<FontNode> font_node, list<shared_ptr<FontNode> >& current_font_nodes) +SubtitleAsset::examine_font_nodes ( + list<shared_ptr<FontNode> > const & font_nodes, + list<shared_ptr<FontNode> >& current_font_nodes, + list<shared_ptr<SubtitleNode> >& current_subtitle_nodes + ) { - current_font_nodes.push_back (font_node); - - for (list<shared_ptr<SubtitleNode> >::iterator j = font_node->subtitle_nodes.begin(); j != font_node->subtitle_nodes.end(); ++j) { - for (list<shared_ptr<TextNode> >::iterator k = (*j)->text_nodes.begin(); k != (*j)->text_nodes.end(); ++k) { - FontNode effective (current_font_nodes); - _subtitles.push_back ( - shared_ptr<Subtitle> ( - new Subtitle ( - font_id_to_name (effective.id), - effective.italic.get(), - effective.color.get(), - effective.size, - (*j)->in, - (*j)->out, - (*k)->v_position, - (*k)->v_align, - (*k)->text, - effective.effect.get(), - effective.effect_color.get(), - (*k)->fade_up_time, - (*k)->fade_down_time - ) - ) - ); + for (list<shared_ptr<FontNode> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) { + + current_font_nodes.push_back (*i); + + for (list<shared_ptr<SubtitleNode> >::iterator j = (*i)->subtitle_nodes.begin(); j != (*i)->subtitle_nodes.end(); ++j) { + current_subtitle_nodes.push_back (*j); + examine_text_nodes (*j, (*j)->text_nodes, current_font_nodes); + examine_font_nodes ((*j)->font_nodes, current_font_nodes, current_subtitle_nodes); + current_subtitle_nodes.pop_back (); } + + examine_font_nodes ((*i)->font_nodes, current_font_nodes, current_subtitle_nodes); + examine_text_nodes (current_subtitle_nodes.back (), (*i)->text_nodes, current_font_nodes); + + current_font_nodes.pop_back (); } +} - for (list<shared_ptr<FontNode> >::iterator j = font_node->font_nodes.begin(); j != font_node->font_nodes.end(); ++j) { - examine_font_node (*j, current_font_nodes); +void +SubtitleAsset::examine_text_nodes ( + shared_ptr<SubtitleNode> subtitle_node, + list<shared_ptr<TextNode> > const & text_nodes, + list<shared_ptr<FontNode> >& current_font_nodes + ) +{ + for (list<shared_ptr<TextNode> >::const_iterator i = text_nodes.begin(); i != text_nodes.end(); ++i) { + FontNode effective (current_font_nodes); + _subtitles.push_back ( + shared_ptr<Subtitle> ( + new Subtitle ( + font_id_to_name (effective.id), + effective.italic.get(), + effective.color.get(), + effective.size, + subtitle_node->in, + subtitle_node->out, + (*i)->v_position, + (*i)->v_align, + (*i)->text, + effective.effect.get(), + effective.effect_color.get(), + (*i)->fade_up_time, + (*i)->fade_down_time + ) + ) + ); } - - current_font_nodes.pop_back (); } FontNode::FontNode (xmlpp::Node const * node) @@ -105,6 +124,7 @@ FontNode::FontNode (xmlpp::Node const * node) effect_color = optional_color_attribute ("EffectColor"); subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle"); font_nodes = sub_nodes<FontNode> ("Font"); + text_nodes = sub_nodes<TextNode> ("Text"); } FontNode::FontNode (list<shared_ptr<FontNode> > const & font_nodes) @@ -148,6 +168,7 @@ SubtitleNode::SubtitleNode (xmlpp::Node const * node) { in = time_attribute ("TimeIn"); out = time_attribute ("TimeOut"); + font_nodes = sub_nodes<FontNode> ("Font"); text_nodes = sub_nodes<TextNode> ("Text"); } diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h index 607b054d..662f85f1 100644 --- a/src/subtitle_asset.h +++ b/src/subtitle_asset.h @@ -24,6 +24,8 @@ namespace libdcp { +class FontNode; + class TextNode : public XMLNode { public: @@ -49,6 +51,7 @@ public: Time in; Time out; + std::list<boost::shared_ptr<FontNode> > font_nodes; std::list<boost::shared_ptr<TextNode> > text_nodes; }; @@ -68,6 +71,7 @@ public: std::list<boost::shared_ptr<SubtitleNode> > subtitle_nodes; std::list<boost::shared_ptr<FontNode> > font_nodes; + std::list<boost::shared_ptr<TextNode> > text_nodes; }; class LoadFontNode : public XMLNode @@ -184,7 +188,18 @@ public: private: std::string font_id_to_name (std::string id) const; - void examine_font_node (boost::shared_ptr<FontNode> font_node, std::list<boost::shared_ptr<FontNode> >& current_font_nodes); + + void examine_font_nodes ( + std::list<boost::shared_ptr<FontNode> > const & font_nodes, + std::list<boost::shared_ptr<FontNode> >& current_font_nodes, + std::list<boost::shared_ptr<SubtitleNode> >& current_subtitle_nodes + ); + + void examine_text_nodes ( + boost::shared_ptr<SubtitleNode> subtitle_node, + std::list<boost::shared_ptr<TextNode> > const & text_nodes, + std::list<boost::shared_ptr<FontNode> >& current_font_nodes + ); std::string _subtitle_id; std::string _movie_title; |
