summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-01-12 12:48:50 +0000
committerCarl Hetherington <cth@carlh.net>2018-01-13 00:06:28 +0000
commit10818d95000c291af776ed9ba1c847257ded4b1f (patch)
treeaa22b0c81dc0af1d30b8df952e876b7f2353522c /src
parent199ac062ed945192f2909bd4fbaa629d57a256c9 (diff)
Note whether subtitle colour is forced or not.
Diffstat (limited to 'src')
-rw-r--r--src/lib/subtitle_content.cc36
-rw-r--r--src/lib/subtitle_content.h7
-rw-r--r--src/lib/subtitle_decoder.cc6
-rw-r--r--src/wx/subtitle_appearance_dialog.cc33
-rw-r--r--src/wx/subtitle_appearance_dialog.h3
5 files changed, 62 insertions, 23 deletions
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index 55493039c..b169cfb69 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -37,6 +37,7 @@ using std::cout;
using std::list;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
+using boost::optional;
using dcp::raw_convert;
int const SubtitleContentProperty::X_OFFSET = 500;
@@ -64,7 +65,6 @@ SubtitleContent::SubtitleContent (Content* parent)
, _y_offset (0)
, _x_scale (1)
, _y_scale (1)
- , _colour (255, 255, 255)
, _outline (false)
, _shadow (false)
, _effect_colour (0, 0, 0)
@@ -103,11 +103,6 @@ SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int
, _y_offset (0)
, _x_scale (1)
, _y_scale (1)
- , _colour (
- node->optional_number_child<int>("Red").get_value_or(255),
- node->optional_number_child<int>("Green").get_value_or(255),
- node->optional_number_child<int>("Blue").get_value_or(255)
- )
, _outline (node->optional_bool_child("Outline").get_value_or(false))
, _shadow (node->optional_bool_child("Shadow").get_value_or(false))
, _line_spacing (node->optional_number_child<double>("LineSpacing").get_value_or (1))
@@ -134,6 +129,13 @@ SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int
_x_scale = _y_scale = node->number_child<double> ("SubtitleScale");
}
+ optional<int> r = node->optional_number_child<int>("Red");
+ optional<int> g = node->optional_number_child<int>("Green");
+ optional<int> b = node->optional_number_child<int>("Blue");
+ if (r && g && b) {
+ _colour = dcp::Colour (*r, *g, *b);
+ }
+
if (version >= 36) {
_effect_colour = dcp::Colour (
node->optional_number_child<int>("EffectRed").get_value_or(255),
@@ -249,9 +251,11 @@ SubtitleContent::as_xml (xmlpp::Node* root) const
root->add_child("SubtitleXScale")->add_child_text (raw_convert<string> (_x_scale));
root->add_child("SubtitleYScale")->add_child_text (raw_convert<string> (_y_scale));
root->add_child("SubtitleLanguage")->add_child_text (_language);
- root->add_child("Red")->add_child_text (raw_convert<string> (_colour.r));
- root->add_child("Green")->add_child_text (raw_convert<string> (_colour.g));
- root->add_child("Blue")->add_child_text (raw_convert<string> (_colour.b));
+ if (_colour) {
+ root->add_child("Red")->add_child_text (raw_convert<string> (_colour->r));
+ root->add_child("Green")->add_child_text (raw_convert<string> (_colour->g));
+ root->add_child("Blue")->add_child_text (raw_convert<string> (_colour->b));
+ }
root->add_child("Outline")->add_child_text (_outline ? "1" : "0");
root->add_child("Shadow")->add_child_text (_shadow ? "1" : "0");
root->add_child("EffectRed")->add_child_text (raw_convert<string> (_effect_colour.r));
@@ -329,6 +333,12 @@ SubtitleContent::set_colour (dcp::Colour colour)
}
void
+SubtitleContent::unset_colour ()
+{
+ maybe_set (_colour, optional<dcp::Colour>(), SubtitleContentProperty::COLOUR);
+}
+
+void
SubtitleContent::set_outline (bool o)
{
maybe_set (_outline, o, SubtitleContentProperty::OUTLINE);
@@ -422,7 +432,11 @@ SubtitleContent::take_settings_from (shared_ptr<const SubtitleContent> c)
set_x_scale (c->_x_scale);
set_y_scale (c->_y_scale);
maybe_set (_fonts, c->_fonts, SubtitleContentProperty::FONTS);
- set_colour (c->_colour);
+ if (c->_colour) {
+ set_colour (*c->_colour);
+ } else {
+ unset_colour ();
+ }
set_outline (c->_outline);
set_shadow (c->_shadow);
set_effect_colour (c->_effect_colour);
diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h
index 2fc6d0fd6..b07182406 100644
--- a/src/lib/subtitle_content.h
+++ b/src/lib/subtitle_content.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -75,6 +75,7 @@ public:
void set_y_scale (double);
void set_language (std::string language);
void set_colour (dcp::Colour);
+ void unset_colour ();
void set_outline (bool);
void set_shadow (bool);
void set_effect_colour (dcp::Colour);
@@ -123,7 +124,7 @@ public:
return _language;
}
- dcp::Colour colour () const {
+ boost::optional<dcp::Colour> colour () const {
boost::mutex::scoped_lock lm (_mutex);
return _colour;
}
@@ -193,7 +194,7 @@ private:
/** y scale factor to apply to subtitles */
double _y_scale;
std::list<boost::shared_ptr<Font> > _fonts;
- dcp::Colour _colour;
+ boost::optional<dcp::Colour> _colour;
bool _outline;
bool _shadow;
dcp::Colour _effect_colour;
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc
index 3de097215..eecfce19d 100644
--- a/src/lib/subtitle_decoder.cc
+++ b/src/lib/subtitle_decoder.cc
@@ -75,8 +75,10 @@ SubtitleDecoder::emit_text_start (ContentTime from, list<dcp::SubtitleString> s)
boost::algorithm::replace_all (t, ">", "&gt;");
i.set_text (t);
- /* Force our configured appearance */
- i.set_colour (content()->colour());
+ /* Set any forced appearance */
+ if (content()->colour()) {
+ i.set_colour (*content()->colour());
+ }
i.set_effect_colour (content()->effect_colour());
if (content()->outline()) {
i.set_effect (dcp::BORDER);
diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc
index 2f9b4760c..c72ef7736 100644
--- a/src/wx/subtitle_appearance_dialog.cc
+++ b/src/wx/subtitle_appearance_dialog.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -33,6 +33,7 @@ using std::map;
using boost::shared_ptr;
using boost::bind;
using boost::dynamic_pointer_cast;
+using boost::optional;
int const SubtitleAppearanceDialog::NONE = 0;
int const SubtitleAppearanceDialog::OUTLINE = 1;
@@ -57,8 +58,14 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
int r = 0;
add_label_to_sizer (_table, this, _("Colour"), true, wxGBPosition (r, 0));
- _colour = new wxColourPickerCtrl (this, wxID_ANY);
- _table->Add (_colour, wxGBPosition (r, 1));
+ {
+ wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _force_colour = new wxCheckBox (this, wxID_ANY, _("Set to"));
+ s->Add (_force_colour, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 8);
+ _colour = new wxColourPickerCtrl (this, wxID_ANY);
+ s->Add (_colour, 0, wxALIGN_CENTER_VERTICAL);
+ _table->Add (s, wxGBPosition (r, 1));
+ }
++r;
add_label_to_sizer (_table, this, _("Effect"), true, wxGBPosition (r, 0));
@@ -135,7 +142,15 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
_effect->Append (_("Outline"));
_effect->Append (_("Shadow"));;
- _colour->SetColour (wxColour (_content->subtitle->colour().r, _content->subtitle->colour().g, _content->subtitle->colour().b));
+ optional<dcp::Colour> colour = _content->subtitle->colour();
+ if (colour) {
+ _force_colour->SetValue (true);
+ _colour->SetColour (wxColour (colour->r, colour->g, colour->b));
+ } else {
+ _force_colour->SetValue (false);
+ _colour->SetColour (wxColour (255, 255, 255));
+ }
+
if (_content->subtitle->outline()) {
_effect->SetSelection (OUTLINE);
} else if (_content->subtitle->shadow()) {
@@ -150,6 +165,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
_fade_out->set (_content->subtitle->fade_out(), _content->active_video_frame_rate ());
_outline_width->SetValue (_content->subtitle->outline_width ());
+ _force_colour->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));
@@ -159,8 +175,12 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr
void
SubtitleAppearanceDialog::apply ()
{
- wxColour const c = _colour->GetColour ();
- _content->subtitle->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue()));
+ if (_force_colour->GetValue ()) {
+ wxColour const c = _colour->GetColour ();
+ _content->subtitle->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue()));
+ } else {
+ _content->subtitle->unset_colour ();
+ }
_content->subtitle->set_outline (_effect->GetSelection() == OUTLINE);
_content->subtitle->set_shadow (_effect->GetSelection() == SHADOW);
wxColour const ec = _effect_colour->GetColour ();
@@ -192,6 +212,7 @@ SubtitleAppearanceDialog::restore ()
void
SubtitleAppearanceDialog::setup_sensitivity ()
{
+ _colour->Enable (_force_colour->GetValue ());
_effect_colour->Enable (_effect->GetSelection() != NONE);
bool const can_outline_width = _effect->GetSelection() == OUTLINE && _content->subtitle->burn ();
diff --git a/src/wx/subtitle_appearance_dialog.h b/src/wx/subtitle_appearance_dialog.h
index 2e007e57b..8d36d4da8 100644
--- a/src/wx/subtitle_appearance_dialog.h
+++ b/src/wx/subtitle_appearance_dialog.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -42,6 +42,7 @@ private:
void setup_sensitivity ();
void restore ();
+ wxCheckBox* _force_colour;
wxColourPickerCtrl* _colour;
wxChoice* _effect;
wxColourPickerCtrl* _effect_colour;