summaryrefslogtreecommitdiff
path: root/src/lib/subtitle_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-09-12 22:45:24 +0100
committerCarl Hetherington <cth@carlh.net>2014-09-12 22:45:24 +0100
commit4265db19ba68a995fca42bdd5fa815aead9c5c50 (patch)
treebfce12d663f71080430cf4da74229fd5f48f214f /src/lib/subtitle_content.cc
parenta8f51733f93bcf88d867d5a4b359e6e14ddad91a (diff)
Allow separate X and Y scale for subtitles.
Diffstat (limited to 'src/lib/subtitle_content.cc')
-rw-r--r--src/lib/subtitle_content.cc48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 0abb7d491..3702eef41 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -33,13 +33,15 @@ using libdcp::raw_convert;
int const SubtitleContentProperty::SUBTITLE_X_OFFSET = 500;
int const SubtitleContentProperty::SUBTITLE_Y_OFFSET = 501;
-int const SubtitleContentProperty::SUBTITLE_SCALE = 502;
+int const SubtitleContentProperty::SUBTITLE_X_SCALE = 502;
+int const SubtitleContentProperty::SUBTITLE_Y_SCALE = 503;
SubtitleContent::SubtitleContent (shared_ptr<const Film> f, boost::filesystem::path p)
: Content (f, p)
, _subtitle_x_offset (0)
, _subtitle_y_offset (0)
- , _subtitle_scale (1)
+ , _subtitle_x_scale (1)
+ , _subtitle_y_scale (1)
{
}
@@ -48,7 +50,8 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, shared_ptr<const cxm
: Content (f, node)
, _subtitle_x_offset (0)
, _subtitle_y_offset (0)
- , _subtitle_scale (1)
+ , _subtitle_x_scale (1)
+ , _subtitle_y_scale (1)
{
if (version >= 7) {
_subtitle_x_offset = node->number_child<float> ("SubtitleXOffset");
@@ -56,8 +59,13 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, shared_ptr<const cxm
} else {
_subtitle_y_offset = node->number_child<float> ("SubtitleOffset");
}
-
- _subtitle_scale = node->number_child<float> ("SubtitleScale");
+
+ if (version >= 10) {
+ _subtitle_x_scale = node->number_child<float> ("SubtitleXScale");
+ _subtitle_y_scale = node->number_child<float> ("SubtitleYScale");
+ } else {
+ _subtitle_x_scale = _subtitle_y_scale = node->number_child<float> ("SubtitleScale");
+ }
}
SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Content> > c)
@@ -77,14 +85,19 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Co
throw JoinError (_("Content to be joined must have the same subtitle Y offset."));
}
- if (sc->subtitle_scale() != ref->subtitle_scale()) {
- throw JoinError (_("Content to be joined must have the same subtitle scale."));
+ if (sc->subtitle_x_scale() != ref->subtitle_x_scale()) {
+ throw JoinError (_("Content to be joined must have the same subtitle X scale."));
+ }
+
+ if (sc->subtitle_y_scale() != ref->subtitle_y_scale()) {
+ throw JoinError (_("Content to be joined must have the same subtitle Y scale."));
}
}
_subtitle_x_offset = ref->subtitle_x_offset ();
_subtitle_y_offset = ref->subtitle_y_offset ();
- _subtitle_scale = ref->subtitle_scale ();
+ _subtitle_x_scale = ref->subtitle_x_scale ();
+ _subtitle_y_scale = ref->subtitle_y_scale ();
}
void
@@ -92,7 +105,8 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
{
root->add_child("SubtitleXOffset")->add_child_text (raw_convert<string> (_subtitle_x_offset));
root->add_child("SubtitleYOffset")->add_child_text (raw_convert<string> (_subtitle_y_offset));
- root->add_child("SubtitleScale")->add_child_text (raw_convert<string> (_subtitle_scale));
+ root->add_child("SubtitleXScale")->add_child_text (raw_convert<string> (_subtitle_x_scale));
+ root->add_child("SubtitleYScale")->add_child_text (raw_convert<string> (_subtitle_y_scale));
}
void
@@ -116,11 +130,21 @@ SubtitleContent::set_subtitle_y_offset (double o)
}
void
-SubtitleContent::set_subtitle_scale (double s)
+SubtitleContent::set_subtitle_x_scale (double s)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _subtitle_x_scale = s;
+ }
+ signal_changed (SubtitleContentProperty::SUBTITLE_X_SCALE);
+}
+
+void
+SubtitleContent::set_subtitle_y_scale (double s)
{
{
boost::mutex::scoped_lock lm (_mutex);
- _subtitle_scale = s;
+ _subtitle_y_scale = s;
}
- signal_changed (SubtitleContentProperty::SUBTITLE_SCALE);
+ signal_changed (SubtitleContentProperty::SUBTITLE_Y_SCALE);
}