diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-21 15:16:18 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-21 15:16:18 +0100 |
| commit | cbd4450197a083bf58bda510e626f73ba583cb66 (patch) | |
| tree | 2be308772512539570beab36beab02bde72d6d4b /src/wx | |
| parent | 1013175d5f6adfa0e6a7442e4c9aebb893787748 (diff) | |
Basics of multiple captions per content so that DCPContent can
hold subs and closed captions.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/caption_appearance_dialog.cc | 43 | ||||
| -rw-r--r-- | src/wx/caption_appearance_dialog.h | 3 | ||||
| -rw-r--r-- | src/wx/caption_panel.cc | 61 | ||||
| -rw-r--r-- | src/wx/caption_panel.h | 1 | ||||
| -rw-r--r-- | src/wx/caption_view.cc | 12 | ||||
| -rw-r--r-- | src/wx/caption_view.h | 4 | ||||
| -rw-r--r-- | src/wx/content_panel.cc | 4 | ||||
| -rw-r--r-- | src/wx/dcp_panel.cc | 2 | ||||
| -rw-r--r-- | src/wx/fonts_dialog.cc | 13 | ||||
| -rw-r--r-- | src/wx/fonts_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/player_information.cc | 2 | ||||
| -rw-r--r-- | src/wx/timeline.cc | 16 | ||||
| -rw-r--r-- | src/wx/timeline_labels_view.cc | 14 | ||||
| -rw-r--r-- | src/wx/timeline_labels_view.h | 4 | ||||
| -rw-r--r-- | src/wx/timeline_text_content_view.cc | 5 | ||||
| -rw-r--r-- | src/wx/timeline_text_content_view.h | 5 | ||||
| -rw-r--r-- | src/wx/timing_panel.cc | 2 |
17 files changed, 109 insertions, 88 deletions
diff --git a/src/wx/caption_appearance_dialog.cc b/src/wx/caption_appearance_dialog.cc index 9377fa6ef..af01dcbe8 100644 --- a/src/wx/caption_appearance_dialog.cc +++ b/src/wx/caption_appearance_dialog.cc @@ -39,9 +39,10 @@ int const CaptionAppearanceDialog::NONE = 0; int const CaptionAppearanceDialog::OUTLINE = 1; int const CaptionAppearanceDialog::SHADOW = 2; -CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<Content> content) +CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<Content> content, shared_ptr<CaptionContent> caption) : wxDialog (parent, wxID_ANY, _("Caption appearance")) , _content (content) + , _caption (caption) { shared_ptr<FFmpegContent> ff = dynamic_pointer_cast<FFmpegContent> (content); if (ff) { @@ -126,7 +127,7 @@ CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<C _effect->Append (_("Outline")); _effect->Append (_("Shadow"));; - optional<dcp::Colour> colour = _content->caption->colour(); + optional<dcp::Colour> colour = _caption->colour(); _force_colour->SetValue (static_cast<bool>(colour)); if (colour) { _colour->SetColour (wxColour (colour->r, colour->g, colour->b)); @@ -134,7 +135,7 @@ CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<C _colour->SetColour (wxColour (255, 255, 255)); } - optional<dcp::Effect> effect = _content->caption->effect(); + optional<dcp::Effect> effect = _caption->effect(); _force_effect->SetValue (static_cast<bool>(effect)); if (effect) { switch (*effect) { @@ -152,7 +153,7 @@ CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<C _effect->SetSelection (NONE); } - optional<dcp::Colour> effect_colour = _content->caption->effect_colour(); + optional<dcp::Colour> effect_colour = _caption->effect_colour(); _force_effect_colour->SetValue (static_cast<bool>(effect_colour)); if (effect_colour) { _effect_colour->SetColour (wxColour (effect_colour->r, effect_colour->g, effect_colour->b)); @@ -160,7 +161,7 @@ CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<C _effect_colour->SetColour (wxColour (0, 0, 0)); } - optional<ContentTime> fade_in = _content->caption->fade_in(); + optional<ContentTime> fade_in = _caption->fade_in(); _force_fade_in->SetValue (static_cast<bool>(fade_in)); if (fade_in) { _fade_in->set (*fade_in, _content->active_video_frame_rate()); @@ -168,7 +169,7 @@ CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<C _fade_in->set (ContentTime(), _content->active_video_frame_rate()); } - optional<ContentTime> fade_out = _content->caption->fade_out(); + optional<ContentTime> fade_out = _caption->fade_out(); _force_fade_out->SetValue (static_cast<bool>(fade_out)); if (fade_out) { _fade_out->set (*fade_out, _content->active_video_frame_rate ()); @@ -176,7 +177,7 @@ CaptionAppearanceDialog::CaptionAppearanceDialog (wxWindow* parent, shared_ptr<C _fade_out->set (ContentTime(), _content->active_video_frame_rate ()); } - _outline_width->SetValue (_content->caption->outline_width ()); + _outline_width->SetValue (_caption->outline_width ()); _force_colour->Bind (wxEVT_CHECKBOX, bind (&CaptionAppearanceDialog::setup_sensitivity, this)); _force_effect_colour->Bind (wxEVT_CHECKBOX, bind (&CaptionAppearanceDialog::setup_sensitivity, this)); @@ -206,42 +207,42 @@ CaptionAppearanceDialog::apply () { if (_force_colour->GetValue ()) { wxColour const c = _colour->GetColour (); - _content->caption->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue())); + _caption->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue())); } else { - _content->caption->unset_colour (); + _caption->unset_colour (); } if (_force_effect->GetValue()) { switch (_effect->GetSelection()) { case NONE: - _content->caption->set_effect (dcp::NONE); + _caption->set_effect (dcp::NONE); break; case OUTLINE: - _content->caption->set_effect (dcp::BORDER); + _caption->set_effect (dcp::BORDER); break; case SHADOW: - _content->caption->set_effect (dcp::SHADOW); + _caption->set_effect (dcp::SHADOW); break; } } else { - _content->caption->unset_effect (); + _caption->unset_effect (); } if (_force_effect_colour->GetValue ()) { wxColour const ec = _effect_colour->GetColour (); - _content->caption->set_effect_colour (dcp::Colour (ec.Red(), ec.Green(), ec.Blue())); + _caption->set_effect_colour (dcp::Colour (ec.Red(), ec.Green(), ec.Blue())); } else { - _content->caption->unset_effect_colour (); + _caption->unset_effect_colour (); } if (_force_fade_in->GetValue ()) { - _content->caption->set_fade_in (_fade_in->get (_content->active_video_frame_rate ())); + _caption->set_fade_in (_fade_in->get (_content->active_video_frame_rate ())); } else { - _content->caption->unset_fade_in (); + _caption->unset_fade_in (); } if (_force_fade_out->GetValue ()) { - _content->caption->set_fade_out (_fade_out->get (_content->active_video_frame_rate ())); + _caption->set_fade_out (_fade_out->get (_content->active_video_frame_rate ())); } else { - _content->caption->unset_fade_out (); + _caption->unset_fade_out (); } - _content->caption->set_outline_width (_outline_width->GetValue ()); + _caption->set_outline_width (_outline_width->GetValue ()); if (_stream) { for (map<RGBA, RGBAColourPicker*>::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) { @@ -272,7 +273,7 @@ CaptionAppearanceDialog::setup_sensitivity () _fade_in->Enable (_force_fade_in->GetValue ()); _fade_out->Enable (_force_fade_out->GetValue ()); - bool const can_outline_width = _effect->GetSelection() == OUTLINE && _content->caption->burn (); + bool const can_outline_width = _effect->GetSelection() == OUTLINE && _caption->burn (); _outline_width->Enable (can_outline_width); if (can_outline_width) { _outline_width->UnsetToolTip (); diff --git a/src/wx/caption_appearance_dialog.h b/src/wx/caption_appearance_dialog.h index ebb70047e..3fb993099 100644 --- a/src/wx/caption_appearance_dialog.h +++ b/src/wx/caption_appearance_dialog.h @@ -36,7 +36,7 @@ class wxWidget; class CaptionAppearanceDialog : public wxDialog { public: - CaptionAppearanceDialog (wxWindow* parent, boost::shared_ptr<Content> content); + CaptionAppearanceDialog (wxWindow* parent, boost::shared_ptr<Content> content, boost::shared_ptr<CaptionContent> caption); void apply (); @@ -60,6 +60,7 @@ private: std::map<RGBA, RGBAColourPicker*> _pickers; boost::shared_ptr<Content> _content; + boost::shared_ptr<CaptionContent> _caption; boost::shared_ptr<FFmpegSubtitleStream> _stream; boost::signals2::scoped_connection _content_connection; diff --git a/src/wx/caption_panel.cc b/src/wx/caption_panel.cc index ca341167d..5a3ac39ed 100644 --- a/src/wx/caption_panel.cc +++ b/src/wx/caption_panel.cc @@ -47,6 +47,7 @@ CaptionPanel::CaptionPanel (ContentPanel* p) : ContentSubPanel (p, _("Captions")) , _caption_view (0) , _fonts_dialog (0) + , _original_type (CAPTION_OPEN) { wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL); @@ -163,7 +164,7 @@ CaptionPanel::CaptionPanel (ContentPanel* p) _reference->Bind (wxEVT_CHECKBOX, boost::bind (&CaptionPanel::reference_clicked, this)); _use->Bind (wxEVT_CHECKBOX, boost::bind (&CaptionPanel::use_toggled, this)); - _type->Bind (wxEVT_CHOICE, boost::bind (&CaptionPanel::type_changed, this)); + _type->Bind (wxEVT_CHOICE, boost::bind (&CaptionPanel::type_changed, this)); _burn->Bind (wxEVT_CHECKBOX, boost::bind (&CaptionPanel::burn_toggled, this)); _x_offset->Bind (wxEVT_SPINCTRL, boost::bind (&CaptionPanel::x_offset_changed, this)); _y_offset->Bind (wxEVT_SPINCTRL, boost::bind (&CaptionPanel::y_offset_changed, this)); @@ -217,11 +218,11 @@ CaptionPanel::film_content_changed (int property) } setup_sensitivity (); } else if (property == CaptionContentProperty::USE) { - checked_set (_use, scs ? scs->caption->use() : false); + checked_set (_use, scs ? scs->caption_of_original_type(_original_type)->use() : false); setup_sensitivity (); } else if (property == CaptionContentProperty::TYPE) { if (scs) { - switch (scs->caption->type()) { + switch (scs->caption_of_original_type(_original_type)->type()) { case CAPTION_OPEN: _type->SetSelection (0); break; @@ -236,29 +237,29 @@ CaptionPanel::film_content_changed (int property) } setup_sensitivity (); } else if (property == CaptionContentProperty::BURN) { - checked_set (_burn, scs ? scs->caption->burn() : false); + checked_set (_burn, scs ? scs->caption_of_original_type(_original_type)->burn() : false); } else if (property == CaptionContentProperty::X_OFFSET) { - checked_set (_x_offset, scs ? lrint (scs->caption->x_offset() * 100) : 0); + checked_set (_x_offset, scs ? lrint (scs->caption_of_original_type(_original_type)->x_offset() * 100) : 0); } else if (property == CaptionContentProperty::Y_OFFSET) { - checked_set (_y_offset, scs ? lrint (scs->caption->y_offset() * 100) : 0); + checked_set (_y_offset, scs ? lrint (scs->caption_of_original_type(_original_type)->y_offset() * 100) : 0); } else if (property == CaptionContentProperty::X_SCALE) { - checked_set (_x_scale, scs ? lrint (scs->caption->x_scale() * 100) : 100); + checked_set (_x_scale, scs ? lrint (scs->caption_of_original_type(_original_type)->x_scale() * 100) : 100); } else if (property == CaptionContentProperty::Y_SCALE) { - checked_set (_y_scale, scs ? lrint (scs->caption->y_scale() * 100) : 100); + checked_set (_y_scale, scs ? lrint (scs->caption_of_original_type(_original_type)->y_scale() * 100) : 100); } else if (property == CaptionContentProperty::LINE_SPACING) { - checked_set (_line_spacing, scs ? lrint (scs->caption->line_spacing() * 100) : 100); + checked_set (_line_spacing, scs ? lrint (scs->caption_of_original_type(_original_type)->line_spacing() * 100) : 100); } else if (property == CaptionContentProperty::LANGUAGE) { - checked_set (_language, scs ? scs->caption->language() : ""); - } else if (property == DCPContentProperty::REFERENCE_SUBTITLE) { + checked_set (_language, scs ? scs->caption_of_original_type(_original_type)->language() : ""); + } else if (property == DCPContentProperty::REFERENCE_CAPTION) { if (scs) { shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (scs); - checked_set (_reference, dcp ? dcp->reference_subtitle () : false); + checked_set (_reference, dcp ? dcp->reference_caption(_original_type) : false); } else { checked_set (_reference, false); } setup_sensitivity (); - } else if (property == DCPContentProperty::HAS_SUBTITLES) { + } else if (property == DCPContentProperty::CAPTIONS) { setup_sensitivity (); } } @@ -267,7 +268,7 @@ void CaptionPanel::use_toggled () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption()) { - i->caption->set_use (_use->GetValue()); + i->caption_of_original_type(_original_type)->set_use (_use->GetValue()); } } @@ -277,10 +278,10 @@ CaptionPanel::type_changed () BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption()) { switch (_type->GetSelection()) { case 0: - i->caption->set_type (CAPTION_OPEN); + i->caption_of_original_type(_original_type)->set_type (CAPTION_OPEN); break; case 1: - i->caption->set_type (CAPTION_CLOSED); + i->caption_of_original_type(_original_type)->set_type (CAPTION_CLOSED); break; } } @@ -290,7 +291,7 @@ void CaptionPanel::burn_toggled () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption ()) { - i->caption->set_burn (_burn->GetValue()); + i->caption_of_original_type(_original_type)->set_burn (_burn->GetValue()); } } @@ -307,7 +308,7 @@ CaptionPanel::setup_sensitivity () shared_ptr<const DCPContent> dc = boost::dynamic_pointer_cast<const DCPContent> (i); shared_ptr<const DCPSubtitleContent> dsc = boost::dynamic_pointer_cast<const DCPSubtitleContent> (i); if (fc) { - if (fc->caption) { + if (!fc->caption.empty()) { ++ffmpeg_subs; ++any_subs; } @@ -325,7 +326,7 @@ CaptionPanel::setup_sensitivity () } string why_not; - bool const can_reference = dcp && dcp->can_reference_subtitle (why_not); + bool const can_reference = dcp && dcp->can_reference_caption (_original_type, why_not); setup_refer_button (_reference, _reference_note, dcp, can_reference, why_not); bool const reference = _reference->GetValue (); @@ -373,7 +374,7 @@ void CaptionPanel::x_offset_changed () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption ()) { - i->caption->set_x_offset (_x_offset->GetValue() / 100.0); + i->caption_of_original_type(_original_type)->set_x_offset (_x_offset->GetValue() / 100.0); } } @@ -381,7 +382,7 @@ void CaptionPanel::y_offset_changed () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption ()) { - i->caption->set_y_offset (_y_offset->GetValue() / 100.0); + i->caption_of_original_type(_original_type)->set_y_offset (_y_offset->GetValue() / 100.0); } } @@ -390,7 +391,7 @@ CaptionPanel::x_scale_changed () { ContentList c = _parent->selected_caption (); if (c.size() == 1) { - c.front()->caption->set_x_scale (_x_scale->GetValue() / 100.0); + c.front()->caption_of_original_type(_original_type)->set_x_scale (_x_scale->GetValue() / 100.0); } } @@ -398,7 +399,7 @@ void CaptionPanel::y_scale_changed () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption ()) { - i->caption->set_y_scale (_y_scale->GetValue() / 100.0); + i->caption_of_original_type(_original_type)->set_y_scale (_y_scale->GetValue() / 100.0); } } @@ -406,7 +407,7 @@ void CaptionPanel::line_spacing_changed () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption ()) { - i->caption->set_line_spacing (_line_spacing->GetValue() / 100.0); + i->caption_of_original_type(_original_type)->set_line_spacing (_line_spacing->GetValue() / 100.0); } } @@ -414,7 +415,7 @@ void CaptionPanel::language_changed () { BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_caption ()) { - i->caption->set_language (wx_to_std (_language->GetValue())); + i->caption_of_original_type(_original_type)->set_language (wx_to_std (_language->GetValue())); } } @@ -432,7 +433,7 @@ CaptionPanel::content_selection_changed () film_content_changed (CaptionContentProperty::LANGUAGE); film_content_changed (CaptionContentProperty::FONTS); film_content_changed (CaptionContentProperty::TYPE); - film_content_changed (DCPContentProperty::REFERENCE_SUBTITLE); + film_content_changed (DCPContentProperty::REFERENCE_CAPTION); } void @@ -449,7 +450,7 @@ CaptionPanel::caption_view_clicked () shared_ptr<Decoder> decoder = decoder_factory (c.front(), _parent->film()->log(), false); if (decoder) { - _caption_view = new CaptionView (this, _parent->film(), c.front(), decoder, _parent->film_viewer()); + _caption_view = new CaptionView (this, _parent->film(), c.front(), c.front()->caption_of_original_type(_original_type), decoder, _parent->film_viewer()); _caption_view->Show (); } } @@ -465,7 +466,7 @@ CaptionPanel::fonts_dialog_clicked () ContentList c = _parent->selected_caption (); DCPOMATIC_ASSERT (c.size() == 1); - _fonts_dialog = new FontsDialog (this, c.front ()); + _fonts_dialog = new FontsDialog (this, c.front(), c.front()->caption_of_original_type(_original_type)); _fonts_dialog->Show (); } @@ -482,7 +483,7 @@ CaptionPanel::reference_clicked () return; } - d->set_reference_subtitle (_reference->GetValue ()); + d->set_reference_caption (_original_type, _reference->GetValue ()); } void @@ -491,7 +492,7 @@ CaptionPanel::appearance_dialog_clicked () ContentList c = _parent->selected_caption (); DCPOMATIC_ASSERT (c.size() == 1); - CaptionAppearanceDialog* d = new CaptionAppearanceDialog (this, c.front()); + CaptionAppearanceDialog* d = new CaptionAppearanceDialog (this, c.front(), c.front()->caption_of_original_type(_original_type)); if (d->ShowModal () == wxID_OK) { d->apply (); } diff --git a/src/wx/caption_panel.h b/src/wx/caption_panel.h index 38501e4d4..8adb85e15 100644 --- a/src/wx/caption_panel.h +++ b/src/wx/caption_panel.h @@ -69,4 +69,5 @@ private: wxButton* _fonts_dialog_button; FontsDialog* _fonts_dialog; wxButton* _appearance_dialog_button; + CaptionType _original_type; }; diff --git a/src/wx/caption_view.cc b/src/wx/caption_view.cc index c57f9161e..e6e63efff 100644 --- a/src/wx/caption_view.cc +++ b/src/wx/caption_view.cc @@ -35,7 +35,7 @@ using boost::shared_ptr; using boost::bind; using boost::dynamic_pointer_cast; -CaptionView::CaptionView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<Decoder> decoder, FilmViewer* viewer) +CaptionView::CaptionView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<CaptionContent> caption, shared_ptr<Decoder> decoder, FilmViewer* viewer) : wxDialog (parent, wxID_ANY, _("Captions"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , _content (content) , _film_viewer (viewer) @@ -85,8 +85,14 @@ CaptionView::CaptionView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Co _subs = 0; _frc = film->active_frame_rate_change (content->position()); - decoder->caption->PlainStart.connect (bind (&CaptionView::data_start, this, _1)); - decoder->caption->Stop.connect (bind (&CaptionView::data_stop, this, _1)); + + /* Find the decoder that is being used for our CaptionContent and attach to it */ + BOOST_FOREACH (shared_ptr<CaptionDecoder> i, decoder->caption) { + if (i->content() == caption) { + i->PlainStart.connect (bind (&CaptionView::data_start, this, _1)); + i->Stop.connect (bind (&CaptionView::data_stop, this, _1)); + } + } while (!decoder->pass ()) {} SetSizerAndFit (sizer); } diff --git a/src/wx/caption_view.h b/src/wx/caption_view.h index 34fec1905..71c492ad6 100644 --- a/src/wx/caption_view.h +++ b/src/wx/caption_view.h @@ -29,7 +29,9 @@ class FilmViewer; class CaptionView : public wxDialog { public: - CaptionView (wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Content> content, boost::shared_ptr<Decoder>, FilmViewer* viewer); + CaptionView ( + wxWindow *, boost::shared_ptr<Film>, boost::shared_ptr<Content> content, boost::shared_ptr<CaptionContent> caption, boost::shared_ptr<Decoder>, FilmViewer* viewer + ); private: void data_start (ContentTextCaption cts); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 5a4873716..40501f717 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -196,7 +196,7 @@ ContentPanel::selected_caption () ContentList sc; BOOST_FOREACH (shared_ptr<Content> i, selected ()) { - if (i->caption) { + if (!i->caption.empty()) { sc.push_back (i); } } @@ -447,7 +447,7 @@ ContentPanel::setup_sensitivity () _video_panel->Enable (_generally_sensitive && video_selection.size() > 0); _audio_panel->Enable (_generally_sensitive && audio_selection.size() > 0); - _caption_panel->Enable (_generally_sensitive && selection.size() == 1 && selection.front()->caption); + _caption_panel->Enable (_generally_sensitive && selection.size() == 1 && !selection.front()->caption.empty()); _timing_panel->Enable (_generally_sensitive); } diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index fcec93a31..51881030f 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -438,7 +438,7 @@ DCPPanel::film_content_changed (int property) property == VideoContentProperty::SCALE || property == DCPContentProperty::REFERENCE_VIDEO || property == DCPContentProperty::REFERENCE_AUDIO || - property == DCPContentProperty::REFERENCE_SUBTITLE) { + property == DCPContentProperty::REFERENCE_CAPTION) { setup_dcp_name (); setup_sensitivity (); } diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index 528b3999b..269dad678 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -34,9 +34,10 @@ using std::string; using std::cout; using boost::shared_ptr; -FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<Content> content) +FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<Content> content, shared_ptr<CaptionContent> caption) : wxDialog (parent, wxID_ANY, _("Fonts")) , _content (content) + , _caption (caption) { _fonts = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (550, 200), wxLC_REPORT | wxLC_SINGLE_SEL); @@ -99,13 +100,14 @@ void FontsDialog::setup () { shared_ptr<Content> content = _content.lock (); - if (!content) { + shared_ptr<CaptionContent> caption = _caption.lock (); + if (!content || !caption) { return; } _fonts->DeleteAllItems (); size_t n = 0; - BOOST_FOREACH (shared_ptr<Font> i, content->caption->fonts ()) { + BOOST_FOREACH (shared_ptr<Font> i, caption->fonts ()) { wxListItem item; item.SetId (n); _fonts->InsertItem (item); @@ -138,14 +140,15 @@ void FontsDialog::edit_clicked () { shared_ptr<Content> content = _content.lock (); - if (!content) { + shared_ptr<CaptionContent> caption = _caption.lock (); + if (!content || !caption) { return; } int const item = _fonts->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); string const id = wx_to_std (_fonts->GetItemText (item, 0)); shared_ptr<Font> font; - BOOST_FOREACH (shared_ptr<Font> i, content->caption->fonts()) { + BOOST_FOREACH (shared_ptr<Font> i, caption->fonts()) { if (i->id() == id) { font = i; } diff --git a/src/wx/fonts_dialog.h b/src/wx/fonts_dialog.h index e251ddab1..6c6873ea3 100644 --- a/src/wx/fonts_dialog.h +++ b/src/wx/fonts_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -25,11 +25,12 @@ #include <boost/filesystem.hpp> class Content; +class CaptionContent; class FontsDialog : public wxDialog { public: - FontsDialog (wxWindow* parent, boost::shared_ptr<Content>); + FontsDialog (wxWindow* parent, boost::shared_ptr<Content>, boost::shared_ptr<CaptionContent> caption); private: void setup (); @@ -38,6 +39,7 @@ private: void edit_clicked (); boost::weak_ptr<Content> _content; + boost::weak_ptr<CaptionContent> _caption; wxListCtrl* _fonts; wxButton* _edit; }; diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index aab8c2cd5..c2bf77259 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -131,7 +131,7 @@ PlayerInformation::triggered_update () if (dcp->audio && !dcp->audio->streams().empty()) { checked_set (_dcp[r++], wxString::Format(_("Audio channels: %d"), dcp->audio->streams().front()->channels())); } - if (dcp->caption) { + if (!dcp->caption.empty()) { checked_set (_dcp[r++], _("Subtitles: yes")); } else { checked_set (_dcp[r++], _("Subtitles: no")); diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index d3b291a9b..f7a31117b 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -228,8 +228,8 @@ Timeline::recreate_views () _views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, i))); } - if (i->caption) { - _views.push_back (shared_ptr<TimelineView> (new TimelineTextContentView (*this, i))); + BOOST_FOREACH (shared_ptr<CaptionContent> j, i->caption) { + _views.push_back (shared_ptr<TimelineView> (new TimelineTextContentView (*this, i, j))); } if (dynamic_pointer_cast<AtmosMXFContent> (i)) { @@ -334,9 +334,9 @@ Timeline::assign_tracks () /* Tracks are: Video (mono or left-eye) Video (right-eye) - Subtitle 1 - Subtitle 2 - Subtitle N + Caption 1 + Caption 2 + Caption N Atmos Audio 1 Audio 2 @@ -373,9 +373,9 @@ Timeline::assign_tracks () _tracks = max (_tracks, 1); - /* Subtitle */ + /* Captions */ - int const subtitle_tracks = place<TimelineTextContentView> (_views, _tracks); + int const caption_tracks = place<TimelineTextContentView> (_views, _tracks); /* Atmos */ @@ -405,7 +405,7 @@ Timeline::assign_tracks () _labels_view->set_3d (have_3d); _labels_view->set_audio_tracks (audio_tracks); - _labels_view->set_subtitle_tracks (subtitle_tracks); + _labels_view->set_caption_tracks (caption_tracks); _labels_view->set_atmos (have_atmos); _time_axis_view->set_y (tracks()); diff --git a/src/wx/timeline_labels_view.cc b/src/wx/timeline_labels_view.cc index 43adfc936..af9cb771e 100644 --- a/src/wx/timeline_labels_view.cc +++ b/src/wx/timeline_labels_view.cc @@ -32,13 +32,13 @@ TimelineLabelsView::TimelineLabelsView (Timeline& tl) : TimelineView (tl) , _threed (true) , _audio_tracks (0) - , _subtitle_tracks (0) + , _caption_tracks (0) , _atmos (true) { wxString labels[] = { _("Video"), _("Audio"), - _("Subtitles"), + _("Captions"), _("Atmos") }; @@ -70,9 +70,9 @@ TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> > gc->DrawText (_("Video"), 0, (ty + fy) / 2 - 8); fy = ty; - if (_subtitle_tracks) { - ty = fy + _subtitle_tracks * h; - gc->DrawText (_("Subtitles"), 0, (ty + fy) / 2 - 8); + if (_caption_tracks) { + ty = fy + _caption_tracks * h; + gc->DrawText (_("Captions"), 0, (ty + fy) / 2 - 8); fy = ty; } @@ -101,9 +101,9 @@ TimelineLabelsView::set_audio_tracks (int n) } void -TimelineLabelsView::set_subtitle_tracks (int n) +TimelineLabelsView::set_caption_tracks (int n) { - _subtitle_tracks = n; + _caption_tracks = n; } void diff --git a/src/wx/timeline_labels_view.h b/src/wx/timeline_labels_view.h index 25302cc33..646d93a58 100644 --- a/src/wx/timeline_labels_view.h +++ b/src/wx/timeline_labels_view.h @@ -31,7 +31,7 @@ public: void set_3d (bool s); void set_audio_tracks (int n); - void set_subtitle_tracks (int n); + void set_caption_tracks (int n); void set_atmos (bool s); private: @@ -40,6 +40,6 @@ private: int _width; bool _threed; int _audio_tracks; - int _subtitle_tracks; + int _caption_tracks; bool _atmos; }; diff --git a/src/wx/timeline_text_content_view.cc b/src/wx/timeline_text_content_view.cc index bb874449e..30158941c 100644 --- a/src/wx/timeline_text_content_view.cc +++ b/src/wx/timeline_text_content_view.cc @@ -24,8 +24,9 @@ using boost::shared_ptr; -TimelineTextContentView::TimelineTextContentView (Timeline& tl, shared_ptr<Content> c) +TimelineTextContentView::TimelineTextContentView (Timeline& tl, shared_ptr<Content> c, shared_ptr<CaptionContent> caption) : TimelineContentView (tl, c) + , _caption (caption) { } @@ -55,5 +56,5 @@ TimelineTextContentView::active () const { shared_ptr<Content> c = _content.lock (); DCPOMATIC_ASSERT (c); - return c->caption && c->caption->use(); + return _caption->use(); } diff --git a/src/wx/timeline_text_content_view.h b/src/wx/timeline_text_content_view.h index 540a90607..4f69f2aef 100644 --- a/src/wx/timeline_text_content_view.h +++ b/src/wx/timeline_text_content_view.h @@ -21,6 +21,7 @@ #include "timeline_content_view.h" class TextContent; +class CaptionContent; /** @class TimelineTextContentView * @brief Timeline view for TextContent. @@ -28,10 +29,12 @@ class TextContent; class TimelineTextContentView : public TimelineContentView { public: - TimelineTextContentView (Timeline& tl, boost::shared_ptr<Content> c); + TimelineTextContentView (Timeline& tl, boost::shared_ptr<Content>, boost::shared_ptr<CaptionContent>); private: bool active () const; wxColour background_colour () const; wxColour foreground_colour () const; + + boost::shared_ptr<CaptionContent> _caption; }; diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 9b516ccfa..9bb608cb2 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -282,7 +282,7 @@ TimingPanel::film_content_changed (int property) ++count_ac; content = i; } - if (i->caption && i->video_frame_rate()) { + if (!i->caption.empty() && i->video_frame_rate()) { ++count_sc; content = i; } |
