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 df05b35..4bb414a 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));
@@ -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 {
index 73e53e4..47b7b5c 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 90bedf0..9351d68 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 929bc60..34bdeca 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 99eba13..7a23b81 100644 (file)
@@ -44,6 +44,7 @@ private:
 
        wxCheckBox* _force_colour;
        wxColourPickerCtrl* _colour;
+       wxCheckBox* _force_effect;
        wxChoice* _effect;
        wxCheckBox* _force_effect_colour;
        wxColourPickerCtrl* _effect_colour;