*/
+#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"
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
--- /dev/null
+/*
+ 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;
+};
#include "util.h"
#include "subrip.h"
#include "film.h"
+#include "font.h"
#include <dcp/raw_convert.h>
#include "i18n.h"
boost::mutex::scoped_lock lm (_mutex);
_length = len;
+ _fonts.push_back (shared_ptr<Font> (new Font ()));
}
string
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)
#include "content.h"
+class Font;
+
class SubtitleContentProperty
{
public:
static int const SUBTITLE_Y_SCALE;
static int const USE_SUBTITLES;
static int const SUBTITLE_LANGUAGE;
+ static int const FONTS;
};
/** @class SubtitleContent
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;
--- /dev/null
+/*
+ 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;
+ }
+}
+
--- /dev/null
+/*
+ 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;
+};
#include "wx_util.h"
#include "subtitle_view.h"
#include "content_panel.h"
+#include "fonts_dialog.h"
using std::vector;
using std::string;
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);
_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
_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
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 ();
}
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 ();
}
class wxCheckBox;
class wxSpinCtrl;
class SubtitleView;
+class FontsDialog;
class SubtitlePanel : public ContentSubPanel
{
void y_scale_changed ();
void language_changed ();
void stream_changed ();
- void view_clicked ();
+ void subtitle_view_clicked ();
+ void fonts_dialog_clicked ();
void setup_sensitivity ();
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;
};
}
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) {
film_viewer.cc
filter_dialog.cc
filter_editor.cc
+ fonts_dialog.cc
gain_calculator_dialog.cc
hints_dialog.cc
job_manager_view.cc