summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-04-26 15:29:21 +0100
committerCarl Hetherington <cth@carlh.net>2017-04-27 10:55:07 +0100
commitba8a5a15cc27988e2bbc6acd470d8532f1d8e99f (patch)
tree375bd068bbd86760f85fcd1264c1d8d76f2f1240 /src/wx
parentf5a2789fcab274f2beda4a1e4ff59567158c9686 (diff)
Initial work on removing storage of subtitle times.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/image_subtitle_colour_dialog.cc96
-rw-r--r--src/wx/image_subtitle_colour_dialog.h42
-rw-r--r--src/wx/subtitle_panel.cc65
-rw-r--r--src/wx/subtitle_view.cc27
-rw-r--r--src/wx/subtitle_view.h4
-rw-r--r--src/wx/text_subtitle_appearance_dialog.cc139
-rw-r--r--src/wx/text_subtitle_appearance_dialog.h56
-rw-r--r--src/wx/wscript3
8 files changed, 33 insertions, 399 deletions
diff --git a/src/wx/image_subtitle_colour_dialog.cc b/src/wx/image_subtitle_colour_dialog.cc
deleted file mode 100644
index 0d102f239..000000000
--- a/src/wx/image_subtitle_colour_dialog.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "image_subtitle_colour_dialog.h"
-#include "rgba_colour_picker.h"
-#include "wx_util.h"
-#include "lib/ffmpeg_subtitle_stream.h"
-#include "lib/ffmpeg_content.h"
-
-using std::map;
-using std::cout;
-using boost::shared_ptr;
-using boost::bind;
-
-ImageSubtitleColourDialog::ImageSubtitleColourDialog (wxWindow* parent, shared_ptr<FFmpegContent> content, shared_ptr<FFmpegSubtitleStream> stream)
- : wxDialog (parent, wxID_ANY, _("Subtitle colours"))
- , _content (content)
- , _stream (stream)
-{
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
- SetSizer (overall_sizer);
-
- wxScrolled<wxPanel>* colours_panel = new wxScrolled<wxPanel> (this);
- colours_panel->EnableScrolling (false, true);
- colours_panel->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_ALWAYS);
- colours_panel->SetScrollRate (0, 16);
-
- wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- table->AddGrowableCol (1, 1);
-
- map<RGBA, RGBA> colours = _stream->colours ();
-
- wxStaticText* t = new wxStaticText (colours_panel, wxID_ANY, "");
- t->SetLabelMarkup (_("<b>Original colour</b>"));
- table->Add (t, 1, wxEXPAND);
- t = new wxStaticText (colours_panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
- t->SetLabelMarkup (_("<b>New colour</b>"));
- table->Add (t, 1, wxALIGN_CENTER);
-
- for (map<RGBA, RGBA>::const_iterator i = colours.begin(); i != colours.end(); ++i) {
- wxPanel* from = new wxPanel (colours_panel, wxID_ANY);
- from->SetBackgroundColour (wxColour (i->first.r, i->first.g, i->first.b, i->first.a));
- table->Add (from, 1, wxEXPAND);
- RGBAColourPicker* to = new RGBAColourPicker (colours_panel, i->second);
- table->Add (to, 1, wxEXPAND);
- _pickers[i->first] = to;
- }
-
- colours_panel->SetSizer (table);
-
- overall_sizer->Add (colours_panel, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-
- wxButton* restore = new wxButton (this, wxID_ANY, _("Restore to original colours"));
- restore->Bind (wxEVT_BUTTON, bind (&ImageSubtitleColourDialog::restore, this));
- overall_sizer->Add (restore, 0, wxALL, DCPOMATIC_SIZER_X_GAP);
-
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
- if (buttons) {
- overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
- }
-}
-
-void
-ImageSubtitleColourDialog::apply ()
-{
- for (map<RGBA, RGBAColourPicker*>::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) {
- _stream->set_colour (i->first, i->second->colour ());
- }
-
- _content->signal_subtitle_stream_changed ();
-}
-
-void
-ImageSubtitleColourDialog::restore ()
-{
- for (map<RGBA, RGBAColourPicker*>::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) {
- i->second->set (i->first);
- }
-}
diff --git a/src/wx/image_subtitle_colour_dialog.h b/src/wx/image_subtitle_colour_dialog.h
deleted file mode 100644
index 133c3b22b..000000000
--- a/src/wx/image_subtitle_colour_dialog.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "table_dialog.h"
-#include "lib/rgba.h"
-#include <map>
-
-class RGBAColourPicker;
-class FFmpegContent;
-class FFmpegSubtitleStream;
-
-class ImageSubtitleColourDialog : public wxDialog
-{
-public:
- ImageSubtitleColourDialog (wxWindow* parent, boost::shared_ptr<FFmpegContent> content, boost::shared_ptr<FFmpegSubtitleStream> stream);
-
- void apply ();
-
-private:
- void restore ();
-
- boost::shared_ptr<FFmpegContent> _content;
- boost::shared_ptr<FFmpegSubtitleStream> _stream;
- std::map<RGBA, RGBAColourPicker*> _pickers;
-};
diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc
index 810cdf488..845b82198 100644
--- a/src/wx/subtitle_panel.cc
+++ b/src/wx/subtitle_panel.cc
@@ -24,8 +24,7 @@
#include "subtitle_view.h"
#include "content_panel.h"
#include "fonts_dialog.h"
-#include "text_subtitle_appearance_dialog.h"
-#include "image_subtitle_colour_dialog.h"
+#include "subtitle_appearance_dialog.h"
#include "lib/ffmpeg_content.h"
#include "lib/text_subtitle_content.h"
#include "lib/ffmpeg_subtitle_stream.h"
@@ -251,8 +250,6 @@ SubtitlePanel::setup_sensitivity ()
{
int any_subs = 0;
int ffmpeg_subs = 0;
- int text_subs = 0;
- int image_subs = 0;
ContentList sel = _parent->selected_subtitle ();
BOOST_FOREACH (shared_ptr<Content> i, sel) {
/* These are the content types that could include subtitles */
@@ -262,30 +259,15 @@ SubtitlePanel::setup_sensitivity ()
shared_ptr<const DCPSubtitleContent> dsc = boost::dynamic_pointer_cast<const DCPSubtitleContent> (i);
if (fc) {
if (fc->subtitle) {
- DCPOMATIC_ASSERT (fc->subtitle_stream());
- /* This content has some subtitles; check the selected stream to decide what type */
- if (fc->subtitle_stream()->has_text()) {
- ++text_subs;
- } else if (fc->subtitle_stream()->has_image()) {
- ++image_subs;
- }
++ffmpeg_subs;
++any_subs;
}
} else if (sc || dc || dsc) {
/* XXX: in the future there could be bitmap subs from DCPs */
- ++text_subs;
++any_subs;
}
}
- if (image_subs) {
- BOOST_FOREACH (shared_ptr<Content> i, sel) {
- /* We must burn image subtitles at the moment */
- i->subtitle->set_burn (true);
- }
- }
-
/* Decide whether we can reference these subs */
shared_ptr<DCPContent> dcp;
@@ -302,16 +284,16 @@ SubtitlePanel::setup_sensitivity ()
/* Set up sensitivity */
_use->Enable (!reference && any_subs > 0);
bool const use = _use->GetValue ();
- _burn->Enable (!reference && any_subs > 0 && use && image_subs == 0);
+ _burn->Enable (!reference && any_subs > 0 && use);
_x_offset->Enable (!reference && any_subs > 0 && use);
_y_offset->Enable (!reference && any_subs > 0 && use);
_x_scale->Enable (!reference && any_subs > 0 && use);
_y_scale->Enable (!reference && any_subs > 0 && use);
- _line_spacing->Enable (!reference && text_subs > 0 && use);
+ _line_spacing->Enable (!reference && use);
_language->Enable (!reference && any_subs > 0 && use);
_stream->Enable (!reference && ffmpeg_subs == 1);
- _subtitle_view_button->Enable (!reference && text_subs == 1);
- _fonts_dialog_button->Enable (!reference && text_subs == 1);
+ _subtitle_view_button->Enable (!reference);
+ _fonts_dialog_button->Enable (!reference);
_appearance_dialog_button->Enable (!reference && any_subs > 0 && use);
}
@@ -458,38 +440,9 @@ SubtitlePanel::appearance_dialog_clicked ()
ContentList c = _parent->selected_subtitle ();
DCPOMATIC_ASSERT (c.size() == 1);
- bool text = false;
- bool image = false;
-
- if (
- dynamic_pointer_cast<TextSubtitleContent> (c.front()) ||
- dynamic_pointer_cast<DCPContent> (c.front()) ||
- dynamic_pointer_cast<DCPSubtitleContent> (c.front())) {
-
- text = true;
- }
-
- shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c.front());
- if (fc) {
- if (fc->subtitle_stream()->has_text()) {
- text = true;
- } else if (fc->subtitle_stream()->has_image()) {
- image = true;
- }
- }
-
- if (text) {
- TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, c.front());
- if (d->ShowModal () == wxID_OK) {
- d->apply ();
- }
- d->Destroy ();
- } else if (image) {
- DCPOMATIC_ASSERT (fc);
- ImageSubtitleColourDialog* d = new ImageSubtitleColourDialog (this, fc, fc->subtitle_stream ());
- if (d->ShowModal() == wxID_OK) {
- d->apply ();
- }
- d->Destroy ();
+ SubtitleAppearanceDialog* d = new SubtitleAppearanceDialog (this, c.front());
+ if (d->ShowModal () == wxID_OK) {
+ d->apply ();
}
+ d->Destroy ();
}
diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc
index 7c66f1db2..bb336d16b 100644
--- a/src/wx/subtitle_view.cc
+++ b/src/wx/subtitle_view.cc
@@ -78,22 +78,35 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<
_subs = 0;
_frc = film->active_frame_rate_change (position);
- decoder->subtitle->TextData.connect (bind (&SubtitleView::data, this, _1));
+ decoder->subtitle->TextStart.connect (bind (&SubtitleView::data_start, this, _1));
+ decoder->subtitle->Stop.connect (bind (&SubtitleView::data_stop, this, _1));
while (!decoder->pass ()) {}
SetSizerAndFit (sizer);
}
void
-SubtitleView::data (ContentTextSubtitle cts)
+SubtitleView::data_start (ContentTextSubtitle cts)
{
- for (list<dcp::SubtitleString>::const_iterator i = cts.subs.begin(); i != cts.subs.end(); ++i) {
+ BOOST_FOREACH (dcp::SubtitleString const & i, cts.subs) {
wxListItem list_item;
list_item.SetId (_subs);
_list->InsertItem (list_item);
- ContentTimePeriod const p = cts.period ();
- _list->SetItem (_subs, 0, std_to_wx (p.from.timecode (_frc->source)));
- _list->SetItem (_subs, 1, std_to_wx (p.to.timecode (_frc->source)));
- _list->SetItem (_subs, 2, std_to_wx (i->text ()));
+ _list->SetItem (_subs, 0, std_to_wx (cts.from().timecode (_frc->source)));
+ _list->SetItem (_subs, 2, std_to_wx (i.text ()));
++_subs;
}
+
+ _last_count = cts.subs.size ();
+}
+
+void
+SubtitleView::data_stop (ContentTime time)
+{
+ if (!_last_count) {
+ return;
+ }
+
+ for (int i = _subs - *_last_count; i < _subs; ++i) {
+ _list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source)));
+ }
}
diff --git a/src/wx/subtitle_view.h b/src/wx/subtitle_view.h
index f88bb490f..43a622705 100644
--- a/src/wx/subtitle_view.h
+++ b/src/wx/subtitle_view.h
@@ -31,9 +31,11 @@ public:
SubtitleView (wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Decoder>, DCPTime position);
private:
- void data (ContentTextSubtitle cts);
+ void data_start (ContentTextSubtitle cts);
+ void data_stop (ContentTime time);
wxListCtrl* _list;
int _subs;
boost::optional<FrameRateChange> _frc;
+ boost::optional<int> _last_count;
};
diff --git a/src/wx/text_subtitle_appearance_dialog.cc b/src/wx/text_subtitle_appearance_dialog.cc
deleted file mode 100644
index 6f47d66eb..000000000
--- a/src/wx/text_subtitle_appearance_dialog.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "text_subtitle_appearance_dialog.h"
-#include "lib/text_subtitle_content.h"
-#include "lib/subtitle_content.h"
-#include <wx/wx.h>
-#include <wx/clrpicker.h>
-#include <wx/spinctrl.h>
-#include <wx/gbsizer.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)
- : wxDialog (parent, wxID_ANY, _("Subtitle appearance"))
- , _content (content)
-{
- wxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
- SetSizer (overall_sizer);
-
- _table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-
- overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-
- 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));
- ++r;
-
- add_label_to_sizer (_table, this, _("Effect"), true, wxGBPosition (r, 0));
- _effect = new wxChoice (this, wxID_ANY);
- _table->Add (_effect, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_sizer (_table, this, _("Effect colour"), true, wxGBPosition (r, 0));
- _effect_colour = new wxColourPickerCtrl (this, wxID_ANY);
- _table->Add (_effect_colour, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_sizer (_table, this, _("Outline width"), true, wxGBPosition (r, 0));
- _outline_width = new wxSpinCtrl (this, wxID_ANY);
- _table->Add (_outline_width, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_sizer (_table, this, _("Fade in time"), true, wxGBPosition (r, 0));
- _fade_in = new Timecode<ContentTime> (this);
- _table->Add (_fade_in, wxGBPosition (r, 1));
- ++r;
-
- add_label_to_sizer (_table, this, _("Fade out time"), true, wxGBPosition (r, 0));
- _fade_out = new Timecode<ContentTime> (this);
- _table->Add (_fade_out, wxGBPosition (r, 1));
- ++r;
-
- wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
- if (buttons) {
- overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
- }
-
- overall_sizer->Layout ();
- overall_sizer->SetSizeHints (this);
-
- /* 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 (OUTLINE);
- } else if (_content->subtitle->shadow()) {
- _effect->SetSelection (SHADOW);
- } else {
- _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_CHOICE, bind (&TextSubtitleAppearanceDialog::setup_sensitivity, this));
- _content_connection = _content->Changed.connect (bind (&TextSubtitleAppearanceDialog::setup_sensitivity, this));
-
- setup_sensitivity ();
-}
-
-void
-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() == 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->UnsetToolTip ();
- } else {
- _outline_width->SetToolTip (_("Outline width cannot be set unless you are burning in subtitles"));
- }
-}
diff --git a/src/wx/text_subtitle_appearance_dialog.h b/src/wx/text_subtitle_appearance_dialog.h
deleted file mode 100644
index 10169fb50..000000000
--- a/src/wx/text_subtitle_appearance_dialog.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "timecode.h"
-#include <wx/wx.h>
-#include <boost/shared_ptr.hpp>
-#include <boost/signals2.hpp>
-
-class wxRadioButton;
-class wxColourPickerCtrl;
-class wxGridBagSizer;
-class Content;
-
-class TextSubtitleAppearanceDialog : public wxDialog
-{
-public:
- TextSubtitleAppearanceDialog (wxWindow* parent, boost::shared_ptr<Content> content);
-
- void apply ();
-
-private:
- void setup_sensitivity ();
-
- wxColourPickerCtrl* _colour;
- wxChoice* _effect;
- wxColourPickerCtrl* _effect_colour;
- Timecode<ContentTime>* _fade_in;
- Timecode<ContentTime>* _fade_out;
- wxSpinCtrl* _outline_width;
- wxGridBagSizer* _table;
-
- boost::shared_ptr<Content> _content;
-
- boost::signals2::scoped_connection _content_connection;
-
- static int const NONE;
- static int const OUTLINE;
- static int const SHADOW;
-};
diff --git a/src/wx/wscript b/src/wx/wscript
index fc4dfc19a..87fb27610 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -44,7 +44,6 @@ sources = """
dcp_panel.cc
email_dialog.cc
image_sequence_dialog.cc
- image_subtitle_colour_dialog.cc
isdcf_metadata_dialog.cc
dir_picker_ctrl.cc
dolby_doremi_certificate_panel.cc
@@ -84,12 +83,12 @@ sources = """
self_dkdm_dialog.cc
server_dialog.cc
servers_list_dialog.cc
+ subtitle_appearance_dialog.cc
subtitle_panel.cc
subtitle_view.cc
system_font_dialog.cc
table_dialog.cc
templates_dialog.cc
- text_subtitle_appearance_dialog.cc
time_picker.cc
timecode.cc
timeline.cc