(*j)->in,
(*j)->out,
(*k)->v_position,
- (*k)->text
+ (*k)->text,
+ effective.effect,
+ effective.effect_color.get()
)
)
);
FontNode::FontNode (xmlpp::Node const * node)
: XMLNode (node)
{
- id = string_attribute ("Id");
+ id = optional_string_attribute ("Id");
size = optional_int64_attribute ("Size");
italic = optional_bool_attribute ("Italic");
color = optional_color_attribute ("Color");
+ effect = optional_string_attribute ("Effect");
+ effect_color = optional_color_attribute ("EffectColor");
subtitle_nodes = sub_nodes<SubtitleNode> ("Subtitle");
font_nodes = sub_nodes<FontNode> ("Font");
}
if ((*i)->color) {
color = (*i)->color.get ();
}
+ if (!(*i)->effect.empty ()) {
+ effect = (*i)->effect;
+ }
+ if ((*i)->effect_color) {
+ effect_color = (*i)->effect_color.get ();
+ }
}
}
}
Subtitle::Subtitle (
- std::string font,
+ string font,
bool italic,
Color color,
int size,
Time in,
Time out,
float v_position,
- std::string text
+ string text,
+ string effect,
+ Color effect_color
)
: _font (font)
, _italic (italic)
, _out (out)
, _v_position (v_position)
, _text (text)
+ , _effect (effect)
+ , _effect_color (effect_color)
{
}
string
XMLNode::string_attribute (string name)
+{
+ xmlpp::Element const * e = dynamic_cast<const xmlpp::Element *> (_node);
+ if (!e) {
+ throw XMLError ("missing attribute");
+ }
+
+ xmlpp::Attribute* a = e->get_attribute (name);
+ if (!a) {
+ throw XMLError ("missing attribute");
+ }
+
+ return a->get_value ();
+}
+
+string
+XMLNode::optional_string_attribute (string name)
{
xmlpp::Element const * e = dynamic_cast<const xmlpp::Element *> (_node);
if (!e) {
int64_t
XMLNode::optional_int64_attribute (string name)
{
- string const s = string_attribute (name);
+ string const s = optional_string_attribute (name);
if (s.empty ()) {
return 0;
}
optional<bool>
XMLNode::optional_bool_attribute (string name)
{
- string const s = string_attribute (name);
+ string const s = optional_string_attribute (name);
if (s.empty ()) {
return optional<bool> ();
}
optional<Color>
XMLNode::optional_color_attribute (string name)
{
- string const s = string_attribute (name);
+ string const s = optional_string_attribute (name);
if (s.empty ()) {
return optional<Color> ();
}
BOOST_CHECK_EQUAL (s.front()->italic(), false);
BOOST_CHECK_EQUAL (s.front()->color(), libdcp::Color(255, 255, 255));
BOOST_CHECK_EQUAL (s.front()->size_in_pixels(1080), 53);
+ BOOST_CHECK_EQUAL (s.front()->effect(), "border");
+ BOOST_CHECK_EQUAL (s.front()->effect_color(), libdcp::Color(0, 0, 0));
s = subs.subtitles_at (libdcp::Time (0, 0, 7, 190));
BOOST_CHECK_EQUAL (s.size(), 2);
BOOST_CHECK_EQUAL (s.front()->font(), "Arial");
BOOST_CHECK_EQUAL (s.front()->italic(), true);
BOOST_CHECK_EQUAL (s.front()->size_in_pixels(1080), 53);
+ BOOST_CHECK_EQUAL (s.front()->effect(), "border");
+ BOOST_CHECK_EQUAL (s.front()->effect_color(), libdcp::Color(0, 0, 0));
BOOST_CHECK_EQUAL (s.back()->text(), "My large wonderbra");
BOOST_CHECK_EQUAL (s.back()->v_position(), 15);
BOOST_CHECK_EQUAL (s.back()->in(), libdcp::Time (0, 0, 7, 177));
BOOST_CHECK_EQUAL (s.back()->italic(), true);
BOOST_CHECK_EQUAL (s.back()->color(), libdcp::Color(255, 255, 255));
BOOST_CHECK_EQUAL (s.back()->size_in_pixels(1080), 53);
+ BOOST_CHECK_EQUAL (s.back()->effect(), "border");
+ BOOST_CHECK_EQUAL (s.back()->effect_color(), libdcp::Color(0, 0, 0));
s = subs.subtitles_at (libdcp::Time (0, 0, 11, 95));
BOOST_CHECK_EQUAL (s.size(), 1);
BOOST_CHECK_EQUAL (s.front()->italic(), false);
BOOST_CHECK_EQUAL (s.front()->color(), libdcp::Color(255, 255, 255));
BOOST_CHECK_EQUAL (s.front()->size_in_pixels(1080), 53);
+ BOOST_CHECK_EQUAL (s.front()->effect(), "border");
+ BOOST_CHECK_EQUAL (s.front()->effect_color(), libdcp::Color(0, 0, 0));
s = subs.subtitles_at (libdcp::Time (0, 0, 14, 42));
BOOST_CHECK_EQUAL (s.size(), 1);
BOOST_CHECK_EQUAL (s.front()->italic(), false);
BOOST_CHECK_EQUAL (s.front()->color(), libdcp::Color(255, 255, 255));
BOOST_CHECK_EQUAL (s.front()->size_in_pixels(1080), 53);
+ BOOST_CHECK_EQUAL (s.front()->effect(), "border");
+ BOOST_CHECK_EQUAL (s.front()->effect_color(), libdcp::Color(0, 0, 0));
}
BOOST_AUTO_TEST_CASE (dcp_time)