diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-11-08 15:00:58 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-11-08 15:00:58 +0000 |
| commit | 3b932abd0c7634483911e1d5361e12b2d094ae6f (patch) | |
| tree | d187652362c0d056222a03538a4812282cda7896 /src/wx | |
| parent | 7ddba2932f3e577ecde3324a2094037252bdde18 (diff) | |
Add appearance dialog for SubRip subtitles.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/subtitle_appearance_dialog.cc | 58 | ||||
| -rw-r--r-- | src/wx/subtitle_appearance_dialog.h | 40 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.cc | 57 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.h | 3 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
5 files changed, 143 insertions, 16 deletions
diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc new file mode 100644 index 000000000..0db55edfe --- /dev/null +++ b/src/wx/subtitle_appearance_dialog.cc @@ -0,0 +1,58 @@ +/* + Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "subtitle_appearance_dialog.h" +#include "lib/subrip_content.h" +#include <wx/wx.h> +#include <wx/clrpicker.h> + +using boost::shared_ptr; + +SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr<SubRipContent> content) + : TableDialog (parent, _("Subtitle appearance"), 2, 1, true) + , _content (content) +{ + add (_("Colour"), true); + _colour = new wxColourPickerCtrl (this, wxID_ANY); + add (_colour); + + _outline = new wxCheckBox (this, wxID_ANY, _("Outline")); + add (_outline); + add_spacer (); + + add (_("Outline colour"), true); + _outline_colour = new wxColourPickerCtrl (this, wxID_ANY); + add (_outline_colour); + + layout (); + + _colour->SetColour (wxColour (_content->colour().r, _content->colour().g, _content->colour().b)); + _outline->SetValue (_content->outline ()); + _outline_colour->SetColour (wxColour (_content->outline_colour().r, _content->outline_colour().g, _content->outline_colour().b)); +} + +void +SubtitleAppearanceDialog::apply () +{ + wxColour const c = _colour->GetColour (); + _content->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue())); + _content->set_outline (_outline->GetValue ()); + wxColour const oc = _outline_colour->GetColour (); + _content->set_outline_colour (dcp::Colour (oc.Red(), oc.Green(), oc.Blue())); +} diff --git a/src/wx/subtitle_appearance_dialog.h b/src/wx/subtitle_appearance_dialog.h new file mode 100644 index 000000000..f4fe307d2 --- /dev/null +++ b/src/wx/subtitle_appearance_dialog.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "table_dialog.h" +#include <boost/shared_ptr.hpp> + +class wxCheckBox; +class wxColourPickerCtrl; +class SubRipContent; + +class SubtitleAppearanceDialog : public TableDialog +{ +public: + SubtitleAppearanceDialog (wxWindow* parent, boost::shared_ptr<SubRipContent> content); + + void apply (); + +private: + wxColourPickerCtrl* _colour; + wxCheckBox* _outline; + wxColourPickerCtrl* _outline_colour; + + boost::shared_ptr<SubRipContent> _content; +}; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index e9de4fccd..74a110349 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -23,6 +23,7 @@ #include "subtitle_view.h" #include "content_panel.h" #include "fonts_dialog.h" +#include "subtitle_appearance_dialog.h" #include "lib/ffmpeg_content.h" #include "lib/subrip_content.h" #include "lib/ffmpeg_subtitle_stream.h" @@ -119,6 +120,8 @@ SubtitlePanel::SubtitlePanel (ContentPanel* p) s->Add (_subtitle_view_button, 1, wxALL, DCPOMATIC_SIZER_GAP); _fonts_dialog_button = new wxButton (this, wxID_ANY, _("Fonts...")); s->Add (_fonts_dialog_button, 1, wxALL, DCPOMATIC_SIZER_GAP); + _appearance_dialog_button = new wxButton (this, wxID_ANY, _("Appearance...")); + s->Add (_appearance_dialog_button, 1, wxALL, DCPOMATIC_SIZER_GAP); grid->Add (s, wxGBPosition (r, 0), wxGBSpan (1, 2)); ++r; @@ -129,17 +132,18 @@ SubtitlePanel::SubtitlePanel (ContentPanel* p) _x_scale->SetRange (10, 1000); _y_scale->SetRange (10, 1000); - _reference->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::reference_clicked, this)); - _use->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::use_toggled, this)); - _burn->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::burn_toggled, this)); - _x_offset->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::x_offset_changed, this)); - _y_offset->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::y_offset_changed, this)); - _x_scale->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::x_scale_changed, this)); - _y_scale->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::y_scale_changed, this)); - _language->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&SubtitlePanel::language_changed, this)); - _stream->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&SubtitlePanel::stream_changed, this)); - _subtitle_view_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::subtitle_view_clicked, this)); - _fonts_dialog_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::fonts_dialog_clicked, this)); + _reference->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::reference_clicked, this)); + _use->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::use_toggled, this)); + _burn->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::burn_toggled, this)); + _x_offset->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::x_offset_changed, this)); + _y_offset->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::y_offset_changed, this)); + _x_scale->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::x_scale_changed, this)); + _y_scale->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&SubtitlePanel::y_scale_changed, this)); + _language->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&SubtitlePanel::language_changed, this)); + _stream->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&SubtitlePanel::stream_changed, this)); + _subtitle_view_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::subtitle_view_clicked, this)); + _fonts_dialog_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::fonts_dialog_clicked, this)); + _appearance_dialog_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::appearance_dialog_clicked, this)); } void @@ -229,7 +233,8 @@ SubtitlePanel::setup_sensitivity () { int any_subs = 0; int ffmpeg_subs = 0; - int subrip_or_dcp_subs = 0; + int subrip_subs = 0; + int dcp_subs = 0; int image_subs = 0; SubtitleContentList sel = _parent->selected_subtitle (); BOOST_FOREACH (shared_ptr<SubtitleContent> i, sel) { @@ -241,8 +246,11 @@ SubtitlePanel::setup_sensitivity () ++ffmpeg_subs; ++any_subs; } - } else if (sc || dsc) { - ++subrip_or_dcp_subs; + } else if (sc) { + ++subrip_subs; + ++any_subs; + } else if (dsc) { + ++dcp_subs; ++any_subs; } else { ++any_subs; @@ -284,8 +292,9 @@ SubtitlePanel::setup_sensitivity () _y_scale->Enable (!reference && any_subs > 0 && use); _language->Enable (!reference && any_subs > 0 && use); _stream->Enable (!reference && ffmpeg_subs == 1); - _subtitle_view_button->Enable (!reference && subrip_or_dcp_subs == 1); - _fonts_dialog_button->Enable (!reference && subrip_or_dcp_subs == 1); + _subtitle_view_button->Enable (!reference && (subrip_subs == 1 || dcp_subs == 1)); + _fonts_dialog_button->Enable (!reference && (subrip_subs == 1 || dcp_subs == 1)); + _appearance_dialog_button->Enable (!reference && subrip_subs == 1); } void @@ -425,3 +434,19 @@ SubtitlePanel::reference_clicked () d->set_reference_subtitle (_reference->GetValue ()); } + +void +SubtitlePanel::appearance_dialog_clicked () +{ + SubtitleContentList c = _parent->selected_subtitle (); + DCPOMATIC_ASSERT (c.size() == 1); + + shared_ptr<SubRipContent> sr = dynamic_pointer_cast<SubRipContent> (c.front ()); + DCPOMATIC_ASSERT (sr); + + SubtitleAppearanceDialog* d = new SubtitleAppearanceDialog (this, sr); + if (d->ShowModal () == wxID_OK) { + d->apply (); + } + d->Destroy (); +} diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h index 7eb9cd27e..e3fd7cd75 100644 --- a/src/wx/subtitle_panel.h +++ b/src/wx/subtitle_panel.h @@ -23,6 +23,7 @@ class wxCheckBox; class wxSpinCtrl; class SubtitleView; class FontsDialog; +class SubtitleAppearanceDialog; class SubtitlePanel : public ContentSubPanel { @@ -45,6 +46,7 @@ private: void subtitle_view_clicked (); void fonts_dialog_clicked (); void reference_clicked (); + void appearance_dialog_clicked (); void setup_sensitivity (); @@ -61,4 +63,5 @@ private: SubtitleView* _subtitle_view; wxButton* _fonts_dialog_button; FontsDialog* _fonts_dialog; + wxButton* _appearance_dialog_button; }; diff --git a/src/wx/wscript b/src/wx/wscript index d2bf33cd3..3b61eb5c6 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -70,6 +70,7 @@ sources = """ screens_panel.cc server_dialog.cc servers_list_dialog.cc + subtitle_appearance_dialog.cc subtitle_panel.cc subtitle_view.cc system_font_dialog.cc |
