Note whether effect is forced or not.
authorCarl Hetherington <cth@carlh.net>
Fri, 12 Jan 2018 20:36:46 +0000 (20:36 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 13 Jan 2018 00:06:28 +0000 (00:06 +0000)
src/lib/subtitle_content.cc
src/lib/subtitle_content.h
src/lib/subtitle_decoder.cc
src/wx/subtitle_appearance_dialog.cc
src/wx/subtitle_appearance_dialog.h

index df05b356afda68b43a53b5f2be04df0fe935039b..4bb414af744a332ffdf4d40994d9bc757252536a 100644 (file)
@@ -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));
@@ -370,6 +371,12 @@ SubtitleContent::set_effect (dcp::Effect e)
        maybe_set (_effect, e, SubtitleContentProperty::EFFECT);
 }
 
+void
+SubtitleContent::unset_effect ()
+{
+       maybe_set (_effect, optional<dcp::Effect>(), SubtitleContentProperty::EFFECT);
+}
+
 void
 SubtitleContent::set_effect_colour (dcp::Colour 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 {
index 73e53e446ba59c8ef5cebc20bb8d26e645e8a6de..47b7b5cd99358cc1f17987956465b91eb7124230 100644 (file)
@@ -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;
index 90bedf0ce8996925bc1c52d90704b43a4565b98e..9351d6865be55d50a02f0dc533aca5f241393cd6 100644 (file)
@@ -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));
        }
index 929bc6006b6c7e8dc2bec3d4ee3ece33f508d38b..34bdeca466a689948b87066fb58f1205fad268bb 100644 (file)
@@ -69,8 +69,14 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
        ++r;
 
        add_label_to_sizer (_table, this, _("Effect"), true, wxGBPosition (r, 0));
-       _effect = new wxChoice (this, wxID_ANY);
-       _table->Add (_effect, wxGBPosition (r, 1));
+       {
+               wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _force_effect = new wxCheckBox (this, wxID_ANY, _("Set to"));
+               s->Add (_force_effect, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 8);
+               _effect = new wxChoice (this, wxID_ANY);
+               s->Add (_effect, 0, wxALIGN_CENTER_VERTICAL);
+               _table->Add (s, wxGBPosition (r, 1));
+       }
        ++r;
 
        add_label_to_sizer (_table, this, _("Effect colour"), true, wxGBPosition (r, 0));
@@ -157,16 +163,23 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
                _colour->SetColour (wxColour (255, 255, 255));
        }
 
-       switch (_content->subtitle->effect()) {
-       case dcp::NONE:
+       optional<dcp::Effect> effect = _content->subtitle->effect();
+       if (effect) {
+               _force_effect->SetValue (true);
+               switch (*effect) {
+               case dcp::NONE:
+                       _effect->SetSelection (NONE);
+                       break;
+               case dcp::BORDER:
+                       _effect->SetSelection (OUTLINE);
+                       break;
+               case dcp::SHADOW:
+                       _effect->SetSelection (SHADOW);
+                       break;
+               }
+       } else {
+               _force_effect->SetValue (false);
                _effect->SetSelection (NONE);
-               break;
-       case dcp::BORDER:
-               _effect->SetSelection (OUTLINE);
-               break;
-       case dcp::SHADOW:
-               _effect->SetSelection (SHADOW);
-               break;
        }
 
        optional<dcp::Colour> effect_colour = _content->subtitle->effect_colour();
@@ -184,6 +197,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
 
        _force_colour->Bind (wxEVT_CHECKBOX, bind (&SubtitleAppearanceDialog::setup_sensitivity, this));
        _force_effect_colour->Bind (wxEVT_CHECKBOX, bind (&SubtitleAppearanceDialog::setup_sensitivity, this));
+       _force_effect->Bind (wxEVT_CHECKBOX, bind (&SubtitleAppearanceDialog::setup_sensitivity, this));
        _effect->Bind (wxEVT_CHOICE, bind (&SubtitleAppearanceDialog::setup_sensitivity, this));
        _content_connection = _content->Changed.connect (bind (&SubtitleAppearanceDialog::setup_sensitivity, this));
 
@@ -245,6 +259,7 @@ SubtitleAppearanceDialog::setup_sensitivity ()
 {
        _colour->Enable (_force_colour->GetValue ());
        _effect_colour->Enable (_force_effect_colour->GetValue ());
+       _effect->Enable (_force_effect->GetValue ());
 
        bool const can_outline_width = _effect->GetSelection() == OUTLINE && _content->subtitle->burn ();
        _outline_width->Enable (can_outline_width);
index 99eba133ab15b55b96bf78b65012d3fb7ae54a8e..7a23b819912a7e72efa2ce5cf8b2cd46922cbc0b 100644 (file)
@@ -44,6 +44,7 @@ private:
 
        wxCheckBox* _force_colour;
        wxColourPickerCtrl* _colour;
+       wxCheckBox* _force_effect;
        wxChoice* _effect;
        wxCheckBox* _force_effect_colour;
        wxColourPickerCtrl* _effect_colour;