diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-12-15 16:56:18 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-12-15 16:56:18 +0000 |
| commit | a5902c6008fd20392c7248c30bc469310122c527 (patch) | |
| tree | 8b2712fd09a64c4ca3ea01f2d6304f39837abddd /src | |
| parent | 99dc00531b985aa1efa23bec5a00b1a5ad26e86c (diff) | |
Start of Fonts dialog for setting up subtitle fonts.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcp_subtitle_content.cc | 11 | ||||
| -rw-r--r-- | src/lib/font.h | 34 | ||||
| -rw-r--r-- | src/lib/subrip_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/subtitle_content.cc | 1 | ||||
| -rw-r--r-- | src/lib/subtitle_content.h | 10 | ||||
| -rw-r--r-- | src/wx/fonts_dialog.cc | 83 | ||||
| -rw-r--r-- | src/wx/fonts_dialog.h | 34 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.cc | 61 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.h | 10 | ||||
| -rw-r--r-- | src/wx/subtitle_view.cc | 2 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
11 files changed, 227 insertions, 22 deletions
diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 85c28d038..351d8c26e 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -17,8 +17,10 @@ */ +#include "font.h" #include "dcp_subtitle_content.h" #include <dcp/interop_subtitle_content.h> +#include <dcp/interop_load_font.h> #include <dcp/raw_convert.h> #include "i18n.h" @@ -47,9 +49,18 @@ void DCPSubtitleContent::examine (shared_ptr<Job> job, bool calculate_digest) { Content::examine (job, calculate_digest); + dcp::InteropSubtitleContent sc (path (0)); + + boost::mutex::scoped_lock lm (_mutex); + _subtitle_language = sc.language (); _length = DCPTime::from_seconds (sc.latest_subtitle_out().to_seconds ()); + + list<shared_ptr<dcp::InteropLoadFont> > fonts = sc.load_font_nodes (); + for (list<shared_ptr<dcp::InteropLoadFont> >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { + _fonts.push_back (shared_ptr<Font> (new Font ((*i)->id))); + } } DCPTime diff --git a/src/lib/font.h b/src/lib/font.h new file mode 100644 index 000000000..59d983277 --- /dev/null +++ b/src/lib/font.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2014 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 <boost/optional.hpp> +#include <boost/filesystem.hpp> +#include <string> + +class Font +{ +public: + Font () {} + Font (std::string id_) + : id (id_) {} + + /** Font ID, or empty for the default font */ + boost::optional<std::string> id; + boost::optional<boost::filesystem::path> file; +}; diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index 7a336f88a..969829b31 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -21,6 +21,7 @@ #include "util.h" #include "subrip.h" #include "film.h" +#include "font.h" #include <dcp/raw_convert.h> #include "i18n.h" @@ -59,6 +60,7 @@ SubRipContent::examine (boost::shared_ptr<Job> job, bool calculate_digest) boost::mutex::scoped_lock lm (_mutex); _length = len; + _fonts.push_back (shared_ptr<Font> (new Font ())); } string diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index df90a4a1a..f6bceb753 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -39,6 +39,7 @@ int const SubtitleContentProperty::SUBTITLE_X_SCALE = 502; int const SubtitleContentProperty::SUBTITLE_Y_SCALE = 503; int const SubtitleContentProperty::USE_SUBTITLES = 504; int const SubtitleContentProperty::SUBTITLE_LANGUAGE = 505; +int const SubtitleContentProperty::FONTS = 506; SubtitleContent::SubtitleContent (shared_ptr<const Film> f) : Content (f) diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h index 4cbef657a..e8915fc96 100644 --- a/src/lib/subtitle_content.h +++ b/src/lib/subtitle_content.h @@ -22,6 +22,8 @@ #include "content.h" +class Font; + class SubtitleContentProperty { public: @@ -31,6 +33,7 @@ public: static int const SUBTITLE_Y_SCALE; static int const USE_SUBTITLES; static int const SUBTITLE_LANGUAGE; + static int const FONTS; }; /** @class SubtitleContent @@ -84,13 +87,20 @@ public: return _subtitle_y_scale; } + std::list<boost::shared_ptr<Font> > fonts () const { + boost::mutex::scoped_lock lm (_mutex); + return _fonts; + } + std::string subtitle_language () const { + boost::mutex::scoped_lock lm (_mutex); return _subtitle_language; } protected: /** subtitle language (e.g. "German") or empty if it is not known */ std::string _subtitle_language; + std::list<boost::shared_ptr<Font> > _fonts; private: friend struct ffmpeg_pts_offset_test; diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc new file mode 100644 index 000000000..37df8f368 --- /dev/null +++ b/src/wx/fonts_dialog.cc @@ -0,0 +1,83 @@ +/* + Copyright (C) 2014 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 "lib/font.h" +#include "lib/subtitle_content.h" +#include "fonts_dialog.h" +#include "wx_util.h" +#include <wx/wx.h> + +using std::list; +using boost::shared_ptr; + +FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<SubtitleContent> content) + : wxDialog (parent, wxID_ANY, _("Fonts")) +{ + _fonts = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (400, 200), wxLC_REPORT | wxLC_SINGLE_SEL); + + { + wxListItem ip; + ip.SetId (0); + ip.SetText (_("ID")); + ip.SetWidth (100); + _fonts->InsertColumn (0, ip); + } + + { + wxListItem ip; + ip.SetId (1); + ip.SetText (_("Font file")); + ip.SetWidth (300); + _fonts->InsertColumn (1, ip); + } + + wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL); + sizer->Add (_fonts, 1, wxEXPAND); + + { + wxSizer* s = new wxBoxSizer (wxVERTICAL); + _edit = new wxButton (this, wxID_ANY, _("Edit...")); + s->Add (_edit, 0, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); + sizer->Add (s, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP); + } + + wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); + + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); + if (buttons) { + overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + + SetSizerAndFit (overall_sizer); + + list<shared_ptr<Font> > fonts = content->fonts (); + size_t n = 0; + for (list<shared_ptr<Font> >::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { + wxListItem item; + item.SetId (n); + _fonts->InsertItem (item); + _fonts->SetItem (n, 0, (*i)->id.get_value_or (wx_to_std (_("[Default]")))); + if ((*i)->file) { + _fonts->SetItem (n, 1, (*i)->file.get().leaf().string ()); + } + ++n; + } +} + diff --git a/src/wx/fonts_dialog.h b/src/wx/fonts_dialog.h new file mode 100644 index 000000000..32fc65f45 --- /dev/null +++ b/src/wx/fonts_dialog.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2014 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 <wx/listctrl.h> +#include <wx/wx.h> +#include <boost/shared_ptr.hpp> + +class SubtitleContent; + +class FontsDialog : public wxDialog +{ +public: + FontsDialog (wxWindow* parent, boost::shared_ptr<SubtitleContent>); + +private: + wxListCtrl* _fonts; + wxButton* _edit; +}; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 3198723a5..07b987a67 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -30,6 +30,7 @@ #include "wx_util.h" #include "subtitle_view.h" #include "content_panel.h" +#include "fonts_dialog.h" using std::vector; using std::string; @@ -39,7 +40,8 @@ using boost::dynamic_pointer_cast; SubtitlePanel::SubtitlePanel (ContentPanel* p) : ContentSubPanel (p, _("Subtitles")) - , _view (0) + , _subtitle_view (0) + , _fonts_dialog (0) { wxFlexGridSizer* grid = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); _sizer->Add (grid, 0, wxALL, 8); @@ -92,22 +94,28 @@ SubtitlePanel::SubtitlePanel (ContentPanel* p) _stream = new wxChoice (this, wxID_ANY); grid->Add (_stream, 1, wxEXPAND); - _view_button = new wxButton (this, wxID_ANY, _("View...")); - grid->Add (_view_button); + _subtitle_view_button = new wxButton (this, wxID_ANY, _("View...")); + grid->Add (_subtitle_view_button); + grid->AddSpacer (0); + + _fonts_dialog_button = new wxButton (this, wxID_ANY, _("Fonts...")); + grid->Add (_fonts_dialog_button); + grid->AddSpacer (0); _x_offset->SetRange (-100, 100); _y_offset->SetRange (-100, 100); _x_scale->SetRange (10, 1000); _y_scale->SetRange (10, 1000); - _use->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::use_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)); - _view_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&SubtitlePanel::view_clicked, this)); + _use->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&SubtitlePanel::use_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)); } void @@ -207,7 +215,8 @@ SubtitlePanel::setup_sensitivity () _y_scale->Enable (any_subs > 0 && use); _language->Enable (any_subs > 0 && use); _stream->Enable (ffmpeg_subs == 1); - _view_button->Enable (subrip_or_dcp_subs == 1); + _subtitle_view_button->Enable (subrip_or_dcp_subs == 1); + _fonts_dialog_button->Enable (subrip_or_dcp_subs == 1); } void @@ -287,14 +296,15 @@ SubtitlePanel::content_selection_changed () film_content_changed (SubtitleContentProperty::SUBTITLE_X_SCALE); film_content_changed (SubtitleContentProperty::SUBTITLE_Y_SCALE); film_content_changed (SubtitleContentProperty::SUBTITLE_LANGUAGE); + film_content_changed (SubtitleContentProperty::FONTS); } void -SubtitlePanel::view_clicked () +SubtitlePanel::subtitle_view_clicked () { - if (_view) { - _view->Destroy (); - _view = 0; + if (_subtitle_view) { + _subtitle_view->Destroy (); + _subtitle_view = 0; } SubtitleContentList c = _parent->selected_subtitle (); @@ -313,7 +323,22 @@ SubtitlePanel::view_clicked () } if (decoder) { - _view = new SubtitleView (this, _parent->film(), decoder, c.front()->position ()); - _view->Show (); + _subtitle_view = new SubtitleView (this, _parent->film(), decoder, c.front()->position ()); + _subtitle_view->Show (); + } +} + +void +SubtitlePanel::fonts_dialog_clicked () +{ + if (_fonts_dialog) { + _fonts_dialog->Destroy (); + _fonts_dialog = 0; } + + SubtitleContentList c = _parent->selected_subtitle (); + assert (c.size() == 1); + + _fonts_dialog = new FontsDialog (this, c.front ()); + _fonts_dialog->Show (); } diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h index f82fb14e5..ef94adb54 100644 --- a/src/wx/subtitle_panel.h +++ b/src/wx/subtitle_panel.h @@ -22,6 +22,7 @@ class wxCheckBox; class wxSpinCtrl; class SubtitleView; +class FontsDialog; class SubtitlePanel : public ContentSubPanel { @@ -40,7 +41,8 @@ private: void y_scale_changed (); void language_changed (); void stream_changed (); - void view_clicked (); + void subtitle_view_clicked (); + void fonts_dialog_clicked (); void setup_sensitivity (); @@ -51,6 +53,8 @@ private: wxSpinCtrl* _y_scale; wxTextCtrl* _language; wxChoice* _stream; - wxButton* _view_button; - SubtitleView* _view; + wxButton* _subtitle_view_button; + SubtitleView* _subtitle_view; + wxButton* _fonts_dialog_button; + FontsDialog* _fonts_dialog; }; diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc index dc41db2fa..b58af3019 100644 --- a/src/wx/subtitle_view.cc +++ b/src/wx/subtitle_view.cc @@ -58,7 +58,7 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr< } wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); - sizer->Add (_list, 1, wxEXPAND); + sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); if (buttons) { diff --git a/src/wx/wscript b/src/wx/wscript index 38448cfb2..10d6f4f1d 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -28,6 +28,7 @@ sources = """ film_viewer.cc filter_dialog.cc filter_editor.cc + fonts_dialog.cc gain_calculator_dialog.cc hints_dialog.cc job_manager_view.cc |
