diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-01-12 20:36:46 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-01-13 00:06:28 +0000 |
| commit | 9b1c6dd87c2a1b0b480a23da756d22c3bfedd9f1 (patch) | |
| tree | 37eaa7473aee114872ffb447da23dce28249ad65 /src/lib | |
| parent | 67a404fff364c6e1fa02eab270755895ba0e1fe8 (diff) | |
Note whether effect is forced or not.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/subtitle_content.cc | 33 | ||||
| -rw-r--r-- | src/lib/subtitle_content.h | 5 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.cc | 4 |
3 files changed, 27 insertions, 15 deletions
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index df05b356a..4bb414af7 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -64,7 +64,6 @@ SubtitleContent::SubtitleContent (Content* parent) , _y_offset (0) , _x_scale (1) , _y_scale (1) - , _effect (dcp::NONE) , _line_spacing (1) , _outline_width (2) { @@ -271,16 +270,18 @@ SubtitleContent::as_xml (xmlpp::Node* root) const root->add_child("Green")->add_child_text (raw_convert<string> (_colour->g)); root->add_child("Blue")->add_child_text (raw_convert<string> (_colour->b)); } - switch (_effect) { - case dcp::NONE: - root->add_child("none"); - break; - case dcp::BORDER: - root->add_child("outline"); - break; - case dcp::SHADOW: - root->add_child("shadow"); - break; + if (_effect) { + switch (*_effect) { + case dcp::NONE: + root->add_child("none"); + break; + case dcp::BORDER: + root->add_child("outline"); + break; + case dcp::SHADOW: + root->add_child("shadow"); + break; + } } if (_effect_colour) { root->add_child("EffectRed")->add_child_text (raw_convert<string> (_effect_colour->r)); @@ -371,6 +372,12 @@ SubtitleContent::set_effect (dcp::Effect e) } void +SubtitleContent::unset_effect () +{ + maybe_set (_effect, optional<dcp::Effect>(), SubtitleContentProperty::EFFECT); +} + +void SubtitleContent::set_effect_colour (dcp::Colour colour) { maybe_set (_effect_colour, colour, SubtitleContentProperty::EFFECT_COLOUR); @@ -463,7 +470,9 @@ SubtitleContent::take_settings_from (shared_ptr<const SubtitleContent> c) } else { unset_colour (); } - set_effect (c->_effect); + if (c->_effect) { + set_effect (*c->_effect); + } if (c->_effect_colour) { set_effect_colour (*c->_effect_colour); } else { diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h index 73e53e446..47b7b5cd9 100644 --- a/src/lib/subtitle_content.h +++ b/src/lib/subtitle_content.h @@ -76,6 +76,7 @@ public: void set_colour (dcp::Colour); void unset_colour (); void set_effect (dcp::Effect); + void unset_effect (); void set_effect_colour (dcp::Colour); void unset_effect_colour (); void set_line_spacing (double s); @@ -128,7 +129,7 @@ public: return _colour; } - dcp::Effect effect () const { + boost::optional<dcp::Effect> effect () const { boost::mutex::scoped_lock lm (_mutex); return _effect; } @@ -189,7 +190,7 @@ private: double _y_scale; std::list<boost::shared_ptr<Font> > _fonts; boost::optional<dcp::Colour> _colour; - dcp::Effect _effect; + boost::optional<dcp::Effect> _effect; boost::optional<dcp::Colour> _effect_colour; /** scaling factor for line spacing; 1 is "standard", < 1 is closer together, > 1 is further apart */ double _line_spacing; diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index 90bedf0ce..9351d6865 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -82,7 +82,9 @@ SubtitleDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s) if (content()->effect_colour()) { i.set_effect_colour (*content()->effect_colour()); } - i.set_effect (content()->effect()); + if (content()->effect()) { + i.set_effect (*content()->effect()); + } i.set_fade_up_time (dcp::Time(content()->fade_in().seconds(), 1000)); i.set_fade_down_time (dcp::Time(content()->fade_out().seconds(), 1000)); } |
