- for (list<shared_ptr<dcp::SubtitleNode> >::iterator j = (*i)->subtitle_nodes.begin(); j != (*i)->subtitle_nodes.end(); ++j) {
- parse_state.subtitle_nodes.push_back (*j);
- examine_text_nodes (xml, (*j)->text_nodes, parse_state);
- examine_font_nodes (xml, (*j)->font_nodes, parse_state);
- parse_state.subtitle_nodes.pop_back ();
- }
-
- examine_font_nodes (xml, (*i)->font_nodes, parse_state);
- examine_text_nodes (xml, (*i)->text_nodes, parse_state);
-
- parse_state.font_nodes.pop_back ();
+ optional<float> vp = optional_number_attribute<float> (node, "VPosition");
+ if (!vp) {
+ vp = optional_number_attribute<float> (node, "Vposition");
+ }
+ if (vp) {
+ ps.v_position = vp.get () / 100;
+ }
+
+ optional<string> va = optional_string_attribute (node, "VAlign");
+ if (!va) {
+ va = optional_string_attribute (node, "Valign");
+ }
+ if (va) {
+ ps.v_align = string_to_valign (va.get ());
+ }
+
+}
+
+SubtitleAsset::ParseState
+SubtitleAsset::text_node_state (xmlpp::Element const * node) const
+{
+ ParseState ps;
+
+ position_align (ps, node);
+
+ optional<string> d = optional_string_attribute (node, "Direction");
+ if (d) {
+ ps.direction = string_to_direction (d.get ());
+ }
+
+ ps.type = ParseState::TEXT;
+
+ return ps;
+}
+
+SubtitleAsset::ParseState
+SubtitleAsset::image_node_state (xmlpp::Element const * node) const
+{
+ ParseState ps;
+
+ position_align (ps, node);
+
+ ps.type = ParseState::IMAGE;
+
+ return ps;
+}
+
+SubtitleAsset::ParseState
+SubtitleAsset::subtitle_node_state (xmlpp::Element const * node, optional<int> tcr) const
+{
+ ParseState ps;
+ ps.in = Time (string_attribute(node, "TimeIn"), tcr);
+ ps.out = Time (string_attribute(node, "TimeOut"), tcr);
+ ps.fade_up_time = fade_time (node, "FadeUpTime", tcr);
+ ps.fade_down_time = fade_time (node, "FadeDownTime", tcr);
+ return ps;
+}
+
+Time
+SubtitleAsset::fade_time (xmlpp::Element const * node, string name, optional<int> tcr) const
+{
+ string const u = optional_string_attribute(node, name).get_value_or ("");
+ Time t;
+
+ if (u.empty ()) {
+ t = Time (0, 0, 0, 20, 250);
+ } else if (u.find (":") != string::npos) {
+ t = Time (u, tcr);
+ } else {
+ t = Time (0, 0, 0, lexical_cast<int> (u), tcr.get_value_or(250));