summaryrefslogtreecommitdiff
path: root/src/lib/text_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-20 14:21:13 +0100
committerCarl Hetherington <cth@carlh.net>2025-09-03 11:59:16 +0200
commitf0189cc11f08d67dfeb45b41a5b970a5856cb42d (patch)
treeef17e46cb51c8013d1faed5855b90c1eb4f24914 /src/lib/text_content.cc
parent4effe4c3dc2d4b6a700e5c20e9e0104f023bd9f9 (diff)
Use helpers for serialising times to/from XML.
Diffstat (limited to 'src/lib/text_content.cc')
-rw-r--r--src/lib/text_content.cc20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc
index a83facd68..17d8b832f 100644
--- a/src/lib/text_content.cc
+++ b/src/lib/text_content.cc
@@ -173,24 +173,16 @@ TextContent::TextContent(Content* parent, cxml::ConstNodePtr node, int version,
);
}
- optional<Frame> fi;
if (version >= 37) {
- fi = node->optional_number_child<Frame>("FadeIn");
+ _fade_in = ContentTime::from_node(node->optional_node_child("FadeIn"));
} else {
- fi = node->optional_number_child<Frame>("SubtitleFadeIn");
- }
- if (fi) {
- _fade_in = ContentTime(*fi);
+ _fade_in = ContentTime::from_node(node->optional_node_child("SubtitleFadeIn"));
}
- optional<Frame> fo;
if (version >= 37) {
- fo = node->optional_number_child<Frame>("FadeOut");
+ _fade_out = ContentTime::from_node(node->optional_node_child("FadeOut"));
} else {
- fo = node->optional_number_child<Frame>("SubtitleFadeOut");
- }
- if (fo) {
- _fade_out = ContentTime(*fo);
+ _fade_out = ContentTime::from_node(node->optional_node_child("SubtitleFadeOut"));
}
for (auto i: node->node_children("Font")) {
@@ -373,10 +365,10 @@ TextContent::as_xml(xmlpp::Element* root) const
}
cxml::add_text_child(text, "LineSpacing", fmt::to_string(_line_spacing));
if (_fade_in) {
- cxml::add_text_child(text, "FadeIn", fmt::to_string(_fade_in->get()));
+ _fade_in->add_as_node(text, "FadeIn");
}
if (_fade_out) {
- cxml::add_text_child(text, "FadeOut", fmt::to_string(_fade_out->get()));
+ _fade_out->add_as_node(text, "FadeOut");
}
cxml::add_text_child(text, "OutlineWidth", fmt::to_string(_outline_width));