summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-05-28 18:45:33 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-01 01:05:06 +0100
commit4593ab6ba39ff188bcf57ef5e69d0c69f454e0b6 (patch)
tree38c053fe07ee578ac5db1478967e27e7024d28b3 /src
parentb8693a3bf32380733604aa6e80c9774de575ebe7 (diff)
Add line-spacing property to SubtitleContent.
Diffstat (limited to 'src')
-rw-r--r--src/lib/subtitle_content.cc18
-rw-r--r--src/lib/subtitle_content.h10
2 files changed, 27 insertions, 1 deletions
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 5b3b453b6..fcc825026 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -50,6 +50,7 @@ int const SubtitleContentProperty::FONTS = 507;
int const SubtitleContentProperty::COLOUR = 508;
int const SubtitleContentProperty::OUTLINE = 509;
int const SubtitleContentProperty::OUTLINE_COLOUR = 510;
+int const SubtitleContentProperty::LINE_SPACING = 511;
SubtitleContent::SubtitleContent (Content* parent)
: ContentPart (parent)
@@ -62,6 +63,7 @@ SubtitleContent::SubtitleContent (Content* parent)
, _colour (255, 255, 255)
, _outline (false)
, _outline_colour (0, 0, 0)
+ , _line_spacing (1)
{
}
@@ -106,6 +108,7 @@ SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int
node->optional_number_child<int>("OutlineGreen").get_value_or(255),
node->optional_number_child<int>("OutlineBlue").get_value_or(255)
)
+ , _line_spacing (node->optional_number_child<double>("LineSpacing").get_value_or (1))
{
if (version >= 32) {
_use = node->bool_child ("UseSubtitles");
@@ -169,6 +172,10 @@ SubtitleContent::SubtitleContent (Content* parent, vector<shared_ptr<Content> >
throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
}
+ if (c[i]->subtitle->line_spacing() != ref->line_spacing()) {
+ throw JoinError (_("Content to be joined must have the same subtitle line spacing."));
+ }
+
list<shared_ptr<Font> > fonts = c[i]->subtitle->fonts ();
if (fonts.size() != ref_fonts.size()) {
throw JoinError (_("Content to be joined must use the same fonts."));
@@ -194,6 +201,7 @@ SubtitleContent::SubtitleContent (Content* parent, vector<shared_ptr<Content> >
_y_scale = ref->y_scale ();
_language = ref->language ();
_fonts = ref_fonts;
+ _line_spacing = ref->line_spacing ();
connect_to_fonts ();
}
@@ -218,6 +226,7 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
root->add_child("OutlineRed")->add_child_text (raw_convert<string> (_outline_colour.r));
root->add_child("OutlineGreen")->add_child_text (raw_convert<string> (_outline_colour.g));
root->add_child("OutlineBlue")->add_child_text (raw_convert<string> (_outline_colour.b));
+ root->add_child("LineSpacing")->add_child_text (raw_convert<string> (_line_spacing));
for (list<shared_ptr<Font> >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
(*i)->as_xml (root->add_child("Font"));
@@ -231,7 +240,8 @@ SubtitleContent::identifier () const
s << raw_convert<string> (x_scale())
<< "_" << raw_convert<string> (y_scale())
<< "_" << raw_convert<string> (x_offset())
- << "_" << raw_convert<string> (y_offset());
+ << "_" << raw_convert<string> (y_offset())
+ << "_" << raw_convert<string> (line_spacing());
/* XXX: I suppose really _fonts shouldn't be in here, since not all
types of subtitle content involve fonts.
@@ -335,3 +345,9 @@ SubtitleContent::set_language (string language)
{
maybe_set (_language, language, SubtitleContentProperty::LANGUAGE);
}
+
+void
+SubtitleContent::set_line_spacing (double s)
+{
+ maybe_set (_line_spacing, s, SubtitleContentProperty::LINE_SPACING);
+}
diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h
index 2aa33f172..6665f563a 100644
--- a/src/lib/subtitle_content.h
+++ b/src/lib/subtitle_content.h
@@ -42,6 +42,7 @@ public:
static int const COLOUR;
static int const OUTLINE;
static int const OUTLINE_COLOUR;
+ static int const LINE_SPACING;
};
/** @class SubtitleContent
@@ -130,6 +131,13 @@ public:
return _outline_colour;
}
+ void set_line_spacing (double s);
+
+ double line_spacing () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _line_spacing;
+ }
+
static boost::shared_ptr<SubtitleContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
protected:
@@ -162,6 +170,8 @@ private:
bool _outline;
dcp::Colour _outline_colour;
std::list<boost::signals2::connection> _font_connections;
+ /** scaling factor for line spacing; 1 is "standard", < 1 is closer together, > 1 is further apart */
+ double _line_spacing;
};
#endif