summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-08-25 10:50:19 +0100
committerCarl Hetherington <cth@carlh.net>2016-08-25 10:50:19 +0100
commit4a5fcd19ca16447ba8b204986a378072a9c730b2 (patch)
treeaf96095183aff5d1331b370283f6623570d5ff65 /src/wx
parente2d0781d45fccd67649a8943f1fb45442f5d2cbc (diff)
Make burnt-in subtitle outline width configurable (#940).
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/text_subtitle_appearance_dialog.cc44
-rw-r--r--src/wx/text_subtitle_appearance_dialog.h10
2 files changed, 47 insertions, 7 deletions
diff --git a/src/wx/text_subtitle_appearance_dialog.cc b/src/wx/text_subtitle_appearance_dialog.cc
index d00dd2cf1..292a8ed2a 100644
--- a/src/wx/text_subtitle_appearance_dialog.cc
+++ b/src/wx/text_subtitle_appearance_dialog.cc
@@ -23,8 +23,14 @@
#include "lib/subtitle_content.h"
#include <wx/wx.h>
#include <wx/clrpicker.h>
+#include <wx/spinctrl.h>
using boost::shared_ptr;
+using boost::bind;
+
+int const TextSubtitleAppearanceDialog::NONE = 0;
+int const TextSubtitleAppearanceDialog::OUTLINE = 1;
+int const TextSubtitleAppearanceDialog::SHADOW = 2;
TextSubtitleAppearanceDialog::TextSubtitleAppearanceDialog (wxWindow* parent, shared_ptr<Content> content)
: TableDialog (parent, _("Subtitle appearance"), 2, 1, true)
@@ -38,8 +44,10 @@ TextSubtitleAppearanceDialog::TextSubtitleAppearanceDialog (wxWindow* parent, sh
add (_effect = new wxChoice (this, wxID_ANY));
add (_("Outline / shadow colour"), true);
- _effect_colour = new wxColourPickerCtrl (this, wxID_ANY);
- add (_effect_colour);
+ add (_effect_colour = new wxColourPickerCtrl (this, wxID_ANY));
+
+ add (_("Outline width"), true);
+ add (_outline_width = new wxSpinCtrl (this, wxID_ANY));
add (_("Fade in time"), true);
_fade_in = new Timecode<ContentTime> (this);
@@ -51,23 +59,30 @@ TextSubtitleAppearanceDialog::TextSubtitleAppearanceDialog (wxWindow* parent, sh
layout ();
+ /* Keep these Appends() up to date with NONE/OUTLINE/SHADOW variables */
_effect->Append (_("None"));
_effect->Append (_("Outline"));
_effect->Append (_("Shadow"));;
_colour->SetColour (wxColour (_content->subtitle->colour().r, _content->subtitle->colour().g, _content->subtitle->colour().b));
if (_content->subtitle->outline()) {
- _effect->SetSelection (1);
+ _effect->SetSelection (OUTLINE);
} else if (_content->subtitle->shadow()) {
- _effect->SetSelection (2);
+ _effect->SetSelection (SHADOW);
} else {
- _effect->SetSelection (0);
+ _effect->SetSelection (NONE);
}
_effect_colour->SetColour (
wxColour (_content->subtitle->effect_colour().r, _content->subtitle->effect_colour().g, _content->subtitle->effect_colour().b)
);
_fade_in->set (_content->subtitle->fade_in(), _content->active_video_frame_rate ());
_fade_out->set (_content->subtitle->fade_out(), _content->active_video_frame_rate ());
+ _outline_width->SetValue (_content->subtitle->outline_width ());
+
+ _effect->Bind (wxEVT_COMMAND_CHOICE_SELECTED, bind (&TextSubtitleAppearanceDialog::setup_sensitivity, this));
+ _content_connection = _content->Changed.connect (bind (&TextSubtitleAppearanceDialog::setup_sensitivity, this));
+
+ setup_sensitivity ();
}
void
@@ -75,10 +90,25 @@ TextSubtitleAppearanceDialog::apply ()
{
wxColour const c = _colour->GetColour ();
_content->subtitle->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue()));
- _content->subtitle->set_outline (_effect->GetSelection() == 1);
- _content->subtitle->set_shadow (_effect->GetSelection() == 2);
+ _content->subtitle->set_outline (_effect->GetSelection() == OUTLINE);
+ _content->subtitle->set_shadow (_effect->GetSelection() == SHADOW);
wxColour const ec = _effect_colour->GetColour ();
_content->subtitle->set_effect_colour (dcp::Colour (ec.Red(), ec.Green(), ec.Blue()));
_content->subtitle->set_fade_in (_fade_in->get (_content->active_video_frame_rate ()));
_content->subtitle->set_fade_out (_fade_out->get (_content->active_video_frame_rate ()));
+ _content->subtitle->set_outline_width (_outline_width->GetValue ());
+}
+
+void
+TextSubtitleAppearanceDialog::setup_sensitivity ()
+{
+ _effect_colour->Enable (_effect->GetSelection() != NONE);
+
+ bool const can_outline_width = _effect->GetSelection() == OUTLINE && _content->subtitle->burn ();
+ _outline_width->Enable (can_outline_width);
+ if (can_outline_width) {
+ _outline_width->SetToolTip (_("Outline width cannot be set unless you are burning in subtitles"));
+ } else {
+ _outline_width->UnsetToolTip ();
+ }
}
diff --git a/src/wx/text_subtitle_appearance_dialog.h b/src/wx/text_subtitle_appearance_dialog.h
index 381b36ec7..c191cc3c0 100644
--- a/src/wx/text_subtitle_appearance_dialog.h
+++ b/src/wx/text_subtitle_appearance_dialog.h
@@ -21,6 +21,7 @@
#include "table_dialog.h"
#include "timecode.h"
#include <boost/shared_ptr.hpp>
+#include <boost/signals2.hpp>
class wxRadioButton;
class wxColourPickerCtrl;
@@ -34,11 +35,20 @@ public:
void apply ();
private:
+ void setup_sensitivity ();
+
wxColourPickerCtrl* _colour;
wxChoice* _effect;
wxColourPickerCtrl* _effect_colour;
Timecode<ContentTime>* _fade_in;
Timecode<ContentTime>* _fade_out;
+ wxSpinCtrl* _outline_width;
boost::shared_ptr<Content> _content;
+
+ boost::signals2::scoped_connection _content_connection;
+
+ static int const NONE;
+ static int const OUTLINE;
+ static int const SHADOW;
};