summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-01-12 20:36:46 +0000
committerCarl Hetherington <cth@carlh.net>2018-01-13 00:06:28 +0000
commit9b1c6dd87c2a1b0b480a23da756d22c3bfedd9f1 (patch)
tree37eaa7473aee114872ffb447da23dce28249ad65 /src
parent67a404fff364c6e1fa02eab270755895ba0e1fe8 (diff)
Note whether effect is forced or not.
Diffstat (limited to 'src')
-rw-r--r--src/lib/subtitle_content.cc33
-rw-r--r--src/lib/subtitle_content.h5
-rw-r--r--src/lib/subtitle_decoder.cc4
-rw-r--r--src/wx/subtitle_appearance_dialog.cc37
-rw-r--r--src/wx/subtitle_appearance_dialog.h1
5 files changed, 54 insertions, 26 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));
}
diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc
index 929bc6006..34bdeca46 100644
--- a/src/wx/subtitle_appearance_dialog.cc
+++ b/src/wx/subtitle_appearance_dialog.cc
@@ -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);
diff --git a/src/wx/subtitle_appearance_dialog.h b/src/wx/subtitle_appearance_dialog.h
index 99eba133a..7a23b8199 100644
--- a/src/wx/subtitle_appearance_dialog.h
+++ b/src/wx/subtitle_appearance_dialog.h
@@ -44,6 +44,7 @@ private:
wxCheckBox* _force_colour;
wxColourPickerCtrl* _colour;
+ wxCheckBox* _force_effect;
wxChoice* _effect;
wxCheckBox* _force_effect_colour;
wxColourPickerCtrl* _effect_colour;