From 775ae0e37bbec115d742feade0adc614a9a2301c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Apr 2016 16:34:22 +0100 Subject: [PATCH] Subtitle rearrangements. --- src/lib/content_part.h | 1 + src/lib/player.cc | 6 +- src/lib/playlist.cc | 2 +- src/lib/subtitle_content.cc | 91 +++++++++++++++++++---- src/lib/subtitle_content.h | 33 +++++++- src/lib/text_subtitle_content.cc | 80 +------------------- src/lib/text_subtitle_content.h | 43 ----------- src/lib/text_subtitle_decoder.cc | 10 +-- src/lib/types.h | 1 - src/wx/content_panel.cc | 9 +-- src/wx/content_panel.h | 2 +- src/wx/dcp_panel.cc | 1 + src/wx/fonts_dialog.cc | 13 ++-- src/wx/fonts_dialog.h | 8 +- src/wx/hints_dialog.cc | 5 +- src/wx/hints_dialog.h | 3 +- src/wx/subtitle_panel.cc | 65 ++++++++-------- src/wx/subtitle_panel.h | 2 +- src/wx/text_subtitle_appearance_dialog.cc | 15 ++-- src/wx/timeline.cc | 5 +- src/wx/timeline_content_view.h | 5 +- src/wx/timeline_subtitle_content_view.cc | 13 ++-- src/wx/timeline_subtitle_content_view.h | 7 +- src/wx/timing_panel.cc | 9 +-- src/wx/video_panel.cc | 2 +- 25 files changed, 205 insertions(+), 226 deletions(-) diff --git a/src/lib/content_part.h b/src/lib/content_part.h index b1282d98d..9ee26cbdb 100644 --- a/src/lib/content_part.h +++ b/src/lib/content_part.h @@ -21,6 +21,7 @@ #define DCPOMATIC_CONTENT_PART_H #include +#include class Content; class Film; diff --git a/src/lib/player.cc b/src/lib/player.cc index ca833208c..9c216c253 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -219,9 +219,9 @@ Player::playlist_content_changed (weak_ptr w, int property, bool freque property == ContentProperty::PATH || property == VideoContentProperty::VIDEO_FRAME_TYPE || property == DCPContentProperty::CAN_BE_PLAYED || - property == TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR || - property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE || - property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR || + property == SubtitleContentProperty::SUBTITLE_COLOUR || + property == SubtitleContentProperty::SUBTITLE_OUTLINE || + property == SubtitleContentProperty::SUBTITLE_OUTLINE_COLOUR || property == FFmpegContentProperty::SUBTITLE_STREAM ) { diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 9df7857b5..645993050 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -130,7 +130,7 @@ Playlist::maybe_sequence () DCPTime next; BOOST_FOREACH (shared_ptr i, _content) { - if (!i->subtitle || !i->subtitle->has_subtitles() || find (placed.begin(), placed.end(), i) != placed.end()) { + if (!i->subtitle || find (placed.begin(), placed.end(), i) != placed.end()) { continue; } diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index bdc2b729c..a6dcbf9ae 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -23,6 +23,7 @@ #include "safe_stringstream.h" #include "font.h" #include "raw_convert.h" +#include "content.h" #include #include #include @@ -46,6 +47,9 @@ int const SubtitleContentProperty::BURN_SUBTITLES = 505; int const SubtitleContentProperty::SUBTITLE_LANGUAGE = 506; int const SubtitleContentProperty::FONTS = 507; int const SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE = 508; +int const SubtitleContentProperty::SUBTITLE_COLOUR = 509; +int const SubtitleContentProperty::SUBTITLE_OUTLINE = 510; +int const SubtitleContentProperty::SUBTITLE_OUTLINE_COLOUR = 511; SubtitleContent::SubtitleContent (Content* parent, shared_ptr film) : ContentPart (parent, film) @@ -55,18 +59,32 @@ SubtitleContent::SubtitleContent (Content* parent, shared_ptr film) , _subtitle_y_offset (0) , _subtitle_x_scale (1) , _subtitle_y_scale (1) + , _colour (255, 255, 255) + , _outline (false) + , _outline_colour (0, 0, 0) { } SubtitleContent::SubtitleContent (Content* parent, shared_ptr film, cxml::ConstNodePtr node, int version) - : ContentParet (parent, film) + : ContentPart (parent, film) , _use_subtitles (false) , _burn_subtitles (false) , _subtitle_x_offset (0) , _subtitle_y_offset (0) , _subtitle_x_scale (1) , _subtitle_y_scale (1) + , _colour ( + node->optional_number_child("Red").get_value_or(255), + node->optional_number_child("Green").get_value_or(255), + node->optional_number_child("Blue").get_value_or(255) + ) + , _outline (node->optional_bool_child("Outline").get_value_or(false)) + , _outline_colour ( + node->optional_number_child("OutlineRed").get_value_or(255), + node->optional_number_child("OutlineGreen").get_value_or(255), + node->optional_number_child("OutlineBlue").get_value_or(255) + ) { if (version >= 32) { _use_subtitles = node->bool_child ("UseSubtitles"); @@ -173,6 +191,13 @@ SubtitleContent::as_xml (xmlpp::Node* root) const root->add_child("SubtitleXScale")->add_child_text (raw_convert (_subtitle_x_scale)); root->add_child("SubtitleYScale")->add_child_text (raw_convert (_subtitle_y_scale)); root->add_child("SubtitleLanguage")->add_child_text (_subtitle_language); + root->add_child("Red")->add_child_text (raw_convert (_colour.r)); + root->add_child("Green")->add_child_text (raw_convert (_colour.g)); + root->add_child("Blue")->add_child_text (raw_convert (_colour.b)); + root->add_child("Outline")->add_child_text (raw_convert (_outline)); + root->add_child("OutlineRed")->add_child_text (raw_convert (_outline_colour.r)); + root->add_child("OutlineGreen")->add_child_text (raw_convert (_outline_colour.g)); + root->add_child("OutlineBlue")->add_child_text (raw_convert (_outline_colour.b)); for (list >::const_iterator i = _fonts.begin(); i != _fonts.end(); ++i) { (*i)->as_xml (root->add_child("Font")); @@ -186,7 +211,7 @@ SubtitleContent::set_use_subtitles (bool u) boost::mutex::scoped_lock lm (_mutex); _use_subtitles = u; } - signal_changed (SubtitleContentProperty::USE_SUBTITLES); + _parent->signal_changed (SubtitleContentProperty::USE_SUBTITLES); } void @@ -196,7 +221,7 @@ SubtitleContent::set_burn_subtitles (bool b) boost::mutex::scoped_lock lm (_mutex); _burn_subtitles = b; } - signal_changed (SubtitleContentProperty::BURN_SUBTITLES); + _parent->signal_changed (SubtitleContentProperty::BURN_SUBTITLES); } void @@ -206,7 +231,7 @@ SubtitleContent::set_subtitle_x_offset (double o) boost::mutex::scoped_lock lm (_mutex); _subtitle_x_offset = o; } - signal_changed (SubtitleContentProperty::SUBTITLE_X_OFFSET); + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_X_OFFSET); } void @@ -216,7 +241,7 @@ SubtitleContent::set_subtitle_y_offset (double o) boost::mutex::scoped_lock lm (_mutex); _subtitle_y_offset = o; } - signal_changed (SubtitleContentProperty::SUBTITLE_Y_OFFSET); + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_Y_OFFSET); } void @@ -226,7 +251,7 @@ SubtitleContent::set_subtitle_x_scale (double s) boost::mutex::scoped_lock lm (_mutex); _subtitle_x_scale = s; } - signal_changed (SubtitleContentProperty::SUBTITLE_X_SCALE); + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_X_SCALE); } void @@ -236,7 +261,7 @@ SubtitleContent::set_subtitle_y_scale (double s) boost::mutex::scoped_lock lm (_mutex); _subtitle_y_scale = s; } - signal_changed (SubtitleContentProperty::SUBTITLE_Y_SCALE); + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_Y_SCALE); } void @@ -246,15 +271,14 @@ SubtitleContent::set_subtitle_language (string language) boost::mutex::scoped_lock lm (_mutex); _subtitle_language = language; } - signal_changed (SubtitleContentProperty::SUBTITLE_LANGUAGE); + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_LANGUAGE); } string SubtitleContent::identifier () const { SafeStringStream s; - s << Content::identifier() - << "_" << raw_convert (subtitle_x_scale()) + s << raw_convert (subtitle_x_scale()) << "_" << raw_convert (subtitle_y_scale()) << "_" << raw_convert (subtitle_x_offset()) << "_" << raw_convert (subtitle_y_offset()); @@ -299,11 +323,50 @@ SubtitleContent::connect_to_fonts () void SubtitleContent::font_changed () { - signal_changed (SubtitleContentProperty::FONTS); + _parent->signal_changed (SubtitleContentProperty::FONTS); +} + +void +SubtitleContent::set_colour (dcp::Colour colour) +{ + { + boost::mutex::scoped_lock lm (_mutex); + if (_colour == colour) { + return; + } + + _colour = colour; + } + + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_COLOUR); +} + +void +SubtitleContent::set_outline (bool o) +{ + { + boost::mutex::scoped_lock lm (_mutex); + if (_outline == o) { + return; + } + + _outline = o; + } + + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_OUTLINE); } -bool -SubtitleContent::has_subtitles () const +void +SubtitleContent::set_outline_colour (dcp::Colour colour) { - return has_text_subtitles() || has_image_subtitles(); + { + boost::mutex::scoped_lock lm (_mutex); + if (_outline_colour == colour) { + return; + } + + _outline_colour = colour; + } + + _parent->signal_changed (SubtitleContentProperty::SUBTITLE_OUTLINE_COLOUR); } diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h index f9d5336f2..5982cc52c 100644 --- a/src/lib/subtitle_content.h +++ b/src/lib/subtitle_content.h @@ -22,6 +22,7 @@ #include "content_part.h" #include +#include #include class Font; @@ -38,6 +39,9 @@ public: static int const SUBTITLE_LANGUAGE; static int const FONTS; static int const SUBTITLE_VIDEO_FRAME_RATE; + static int const SUBTITLE_COLOUR; + static int const SUBTITLE_OUTLINE; + static int const SUBTITLE_OUTLINE_COLOUR; }; class SubtitleContent : public ContentPart @@ -50,7 +54,10 @@ public: void as_xml (xmlpp::Node *) const; std::string identifier () const; - bool has_subtitles () const; + bool has_image_subtitles () const { + /* XXX */ + return true; + } void add_font (boost::shared_ptr font); @@ -102,6 +109,27 @@ public: return _subtitle_language; } + void set_colour (dcp::Colour); + + dcp::Colour colour () const { + boost::mutex::scoped_lock lm (_mutex); + return _colour; + } + + void set_outline (bool); + + bool outline () const { + boost::mutex::scoped_lock lm (_mutex); + return _outline; + } + + void set_outline_colour (dcp::Colour); + + dcp::Colour outline_colour () const { + boost::mutex::scoped_lock lm (_mutex); + return _outline_colour; + } + protected: /** subtitle language (e.g. "German") or empty if it is not known */ std::string _subtitle_language; @@ -126,6 +154,9 @@ private: /** y scale factor to apply to subtitles */ double _subtitle_y_scale; std::list > _fonts; + dcp::Colour _colour; + bool _outline; + dcp::Colour _outline_colour; std::list _font_connections; }; diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_subtitle_content.cc index 88890ebdc..c7dd19d03 100644 --- a/src/lib/text_subtitle_content.cc +++ b/src/lib/text_subtitle_content.cc @@ -35,34 +35,15 @@ using boost::shared_ptr; std::string const TextSubtitleContent::font_id = "font"; -int const TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR = 300; -int const TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE = 301; -int const TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR = 302; - TextSubtitleContent::TextSubtitleContent (shared_ptr film, boost::filesystem::path path) : Content (film, path) - , _colour (255, 255, 255) - , _outline (false) - , _outline_colour (0, 0, 0) { - subtitle.reset (new SubtitleContent (this, film, path)); + subtitle.reset (new SubtitleContent (this, film)); } TextSubtitleContent::TextSubtitleContent (shared_ptr film, cxml::ConstNodePtr node, int version) : Content (film, node) , _length (node->number_child ("Length")) - , _frame_rate (node->optional_number_child("SubtitleVideoFrameRate")) - , _colour ( - node->optional_number_child("Red").get_value_or(255), - node->optional_number_child("Green").get_value_or(255), - node->optional_number_child("Blue").get_value_or(255) - ) - , _outline (node->optional_bool_child("Outline").get_value_or(false)) - , _outline_colour ( - node->optional_number_child("OutlineRed").get_value_or(255), - node->optional_number_child("OutlineGreen").get_value_or(255), - node->optional_number_child("OutlineBlue").get_value_or(255) - ) { subtitle.reset (new SubtitleContent (this, film, node, version)); } @@ -74,11 +55,11 @@ TextSubtitleContent::examine (boost::shared_ptr job) TextSubtitle s (shared_from_this ()); /* Default to turning these subtitles on */ - set_use_subtitles (true); + subtitle->set_use_subtitles (true); boost::mutex::scoped_lock lm (_mutex); _length = s.length (); - add_font (shared_ptr (new Font (font_id))); + subtitle->add_font (shared_ptr (new Font (font_id))); } string @@ -100,16 +81,6 @@ TextSubtitleContent::as_xml (xmlpp::Node* node) const Content::as_xml (node); subtitle->as_xml (node); node->add_child("Length")->add_child_text (raw_convert (_length.get ())); - if (_frame_rate) { - node->add_child("SubtitleVideoFrameRate")->add_child_text (raw_convert (_frame_rate.get())); - } - node->add_child("Red")->add_child_text (raw_convert (_colour.r)); - node->add_child("Green")->add_child_text (raw_convert (_colour.g)); - node->add_child("Blue")->add_child_text (raw_convert (_colour.b)); - node->add_child("Outline")->add_child_text (raw_convert (_outline)); - node->add_child("OutlineRed")->add_child_text (raw_convert (_outline_colour.r)); - node->add_child("OutlineGreen")->add_child_text (raw_convert (_outline_colour.g)); - node->add_child("OutlineBlue")->add_child_text (raw_convert (_outline_colour.b)); } DCPTime @@ -145,48 +116,3 @@ TextSubtitleContent::subtitle_video_frame_rate () const */ return film()->active_frame_rate_change(position()).source; } - -void -TextSubtitleContent::set_colour (dcp::Colour colour) -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_colour == colour) { - return; - } - - _colour = colour; - } - - signal_changed (TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR); -} - -void -TextSubtitleContent::set_outline (bool o) -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_outline == o) { - return; - } - - _outline = o; - } - - signal_changed (TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE); -} - -void -TextSubtitleContent::set_outline_colour (dcp::Colour colour) -{ - { - boost::mutex::scoped_lock lm (_mutex); - if (_outline_colour == colour) { - return; - } - - _outline_colour = colour; - } - - signal_changed (TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR); -} diff --git a/src/lib/text_subtitle_content.h b/src/lib/text_subtitle_content.h index a2ef5d98a..76440ba9b 100644 --- a/src/lib/text_subtitle_content.h +++ b/src/lib/text_subtitle_content.h @@ -21,14 +21,6 @@ class Job; -class TextSubtitleContentProperty -{ -public: - static int const TEXT_SUBTITLE_COLOUR; - static int const TEXT_SUBTITLE_OUTLINE; - static int const TEXT_SUBTITLE_OUTLINE_COLOUR; -}; - /** @class TextSubtitleContent * @brief SubRip or SSA subtitles. */ @@ -42,54 +34,19 @@ public: return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - /* Content */ void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *) const; DCPTime full_length () const; - /* SubtitleContent */ - - bool has_text_subtitles () const { - return true; - } - - bool has_image_subtitles () const { - return false; - } - double subtitle_video_frame_rate () const; void set_subtitle_video_frame_rate (double r); - void set_colour (dcp::Colour); - - dcp::Colour colour () const { - boost::mutex::scoped_lock lm (_mutex); - return _colour; - } - - void set_outline (bool); - - bool outline () const { - boost::mutex::scoped_lock lm (_mutex); - return _outline; - } - - void set_outline_colour (dcp::Colour); - - dcp::Colour outline_colour () const { - boost::mutex::scoped_lock lm (_mutex); - return _outline_colour; - } - static std::string const font_id; private: ContentTime _length; /** Video frame rate that this content has been prepared for, if known */ boost::optional _frame_rate; - dcp::Colour _colour; - bool _outline; - dcp::Colour _outline_colour; }; diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_subtitle_decoder.cc index 36e44cc99..94604cd71 100644 --- a/src/lib/text_subtitle_decoder.cc +++ b/src/lib/text_subtitle_decoder.cc @@ -19,6 +19,7 @@ #include "text_subtitle_decoder.h" #include "text_subtitle_content.h" +#include "subtitle_content.h" #include #include #include @@ -60,9 +61,6 @@ TextSubtitleDecoder::pass (PassReason, bool) /* XXX: we are ignoring positioning specified in the file */ - shared_ptr content = dynamic_pointer_cast (_subtitle_content); - DCPOMATIC_ASSERT (content); - list out; /* Highest line index in this subtitle */ @@ -81,7 +79,7 @@ TextSubtitleDecoder::pass (PassReason, bool) j.italic, j.bold, /* force the colour to whatever is configured */ - content->colour(), + _subtitle_content->colour(), j.font_size.points (72 * 11), 1.0, dcp::Time (_subtitles[_next].from.all_as_seconds(), 1000), @@ -95,8 +93,8 @@ TextSubtitleDecoder::pass (PassReason, bool) dcp::VALIGN_TOP, dcp::DIRECTION_LTR, j.text, - content->outline() ? dcp::BORDER : dcp::NONE, - content->outline_colour(), + _subtitle_content->outline() ? dcp::BORDER : dcp::NONE, + _subtitle_content->outline_colour(), dcp::Time (0, 1000), dcp::Time (0, 1000) ) diff --git a/src/lib/types.h b/src/lib/types.h index 33bad1d24..2bc6fa3a4 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -49,7 +49,6 @@ namespace xmlpp { typedef std::vector > ContentList; typedef std::vector > AudioContentList; -typedef std::vector > SubtitleContentList; typedef std::vector > FFmpegContentList; typedef int64_t Frame; diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 55dd671e9..ad4894897 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -178,15 +178,14 @@ ContentPanel::selected_audio () return ac; } -SubtitleContentList +ContentList ContentPanel::selected_subtitle () { - SubtitleContentList sc; + ContentList sc; BOOST_FOREACH (shared_ptr i, selected ()) { - shared_ptr t = dynamic_pointer_cast (i); - if (t) { - sc.push_back (t); + if (i->subtitle) { + sc.push_back (i); } } diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index e735213d3..f4e2dbae2 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -61,7 +61,7 @@ public: ContentList selected (); ContentList selected_video (); AudioContentList selected_audio (); - SubtitleContentList selected_subtitle (); + ContentList selected_subtitle (); FFmpegContentList selected_ffmpeg (); void add_file_clicked (); diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 42d2f1537..c62767c9d 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -30,6 +30,7 @@ #include "lib/ffmpeg_content.h" #include "lib/audio_processor.h" #include "lib/video_content.h" +#include "lib/subtitle_content.h" #include "lib/dcp_content.h" #include #include diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc index b79580d7c..3f8bca239 100644 --- a/src/wx/fonts_dialog.cc +++ b/src/wx/fonts_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2016 Carl Hetherington 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 @@ -22,6 +22,7 @@ #include "system_font_dialog.h" #include "font_files_dialog.h" #include "lib/font.h" +#include "lib/content.h" #include "lib/subtitle_content.h" #include #include @@ -32,7 +33,7 @@ using std::string; using std::cout; using boost::shared_ptr; -FontsDialog::FontsDialog (wxWindow* parent, shared_ptr content) +FontsDialog::FontsDialog (wxWindow* parent, shared_ptr content) : wxDialog (parent, wxID_ANY, _("Fonts")) , _content (content) { @@ -96,14 +97,14 @@ FontsDialog::FontsDialog (wxWindow* parent, shared_ptr content) void FontsDialog::setup () { - shared_ptr content = _content.lock (); + shared_ptr content = _content.lock (); if (!content) { return; } _fonts->DeleteAllItems (); size_t n = 0; - BOOST_FOREACH (shared_ptr i, content->fonts ()) { + BOOST_FOREACH (shared_ptr i, content->subtitle->fonts ()) { wxListItem item; item.SetId (n); _fonts->InsertItem (item); @@ -133,7 +134,7 @@ FontsDialog::setup_sensitivity () void FontsDialog::edit_clicked () { - shared_ptr content = _content.lock (); + shared_ptr content = _content.lock (); if (!content) { return; } @@ -141,7 +142,7 @@ FontsDialog::edit_clicked () 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; - BOOST_FOREACH (shared_ptr i, content->fonts()) { + BOOST_FOREACH (shared_ptr i, content->subtitle->fonts()) { if (i->id() == id) { font = i; } diff --git a/src/wx/fonts_dialog.h b/src/wx/fonts_dialog.h index e04dc9937..723414a6b 100644 --- a/src/wx/fonts_dialog.h +++ b/src/wx/fonts_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2016 Carl Hetherington 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 @@ -23,12 +23,12 @@ #include #include -class SubtitleContent; +class Content; class FontsDialog : public wxDialog { public: - FontsDialog (wxWindow* parent, boost::shared_ptr); + FontsDialog (wxWindow* parent, boost::shared_ptr); private: void setup (); @@ -36,7 +36,7 @@ private: void selection_changed (); void edit_clicked (); - boost::weak_ptr _content; + boost::weak_ptr _content; wxListCtrl* _fonts; wxButton* _edit; }; diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc index 2cf109e55..75643c312 100644 --- a/src/wx/hints_dialog.cc +++ b/src/wx/hints_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington 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 @@ -17,12 +17,13 @@ */ +#include "hints_dialog.h" #include "lib/film.h" #include "lib/ratio.h" #include "lib/video_content.h" #include "lib/subtitle_content.h" #include "lib/font.h" -#include "hints_dialog.h" +#include "lib/content.h" #include #include #include diff --git a/src/wx/hints_dialog.h b/src/wx/hints_dialog.h index f4ef00aa2..abf718e8f 100644 --- a/src/wx/hints_dialog.h +++ b/src/wx/hints_dialog.h @@ -17,8 +17,9 @@ */ -#include #include +#include +#include class wxRichTextCtrl; class Film; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index a53679673..6b910afae 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington 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 @@ -32,6 +32,7 @@ #include "lib/text_subtitle_decoder.h" #include "lib/dcp_subtitle_decoder.h" #include "lib/dcp_content.h" +#include "lib/subtitle_content.h" #include #include @@ -157,14 +158,14 @@ void SubtitlePanel::film_content_changed (int property) { FFmpegContentList fc = _parent->selected_ffmpeg (); - SubtitleContentList sc = _parent->selected_subtitle (); + ContentList sc = _parent->selected_subtitle (); shared_ptr fcs; if (fc.size() == 1) { fcs = fc.front (); } - shared_ptr scs; + shared_ptr scs; if (sc.size() == 1) { scs = sc.front (); } @@ -185,20 +186,20 @@ SubtitlePanel::film_content_changed (int property) } setup_sensitivity (); } else if (property == SubtitleContentProperty::USE_SUBTITLES) { - checked_set (_use, scs ? scs->use_subtitles() : false); + checked_set (_use, scs ? scs->subtitle->use_subtitles() : false); setup_sensitivity (); } else if (property == SubtitleContentProperty::BURN_SUBTITLES) { - checked_set (_burn, scs ? scs->burn_subtitles() : false); + checked_set (_burn, scs ? scs->subtitle->burn_subtitles() : false); } else if (property == SubtitleContentProperty::SUBTITLE_X_OFFSET) { - checked_set (_x_offset, scs ? lrint (scs->subtitle_x_offset() * 100) : 0); + checked_set (_x_offset, scs ? lrint (scs->subtitle->subtitle_x_offset() * 100) : 0); } else if (property == SubtitleContentProperty::SUBTITLE_Y_OFFSET) { - checked_set (_y_offset, scs ? lrint (scs->subtitle_y_offset() * 100) : 0); + checked_set (_y_offset, scs ? lrint (scs->subtitle->subtitle_y_offset() * 100) : 0); } else if (property == SubtitleContentProperty::SUBTITLE_X_SCALE) { - checked_set (_x_scale, scs ? lrint (scs->subtitle_x_scale() * 100) : 100); + checked_set (_x_scale, scs ? lrint (scs->subtitle->subtitle_x_scale() * 100) : 100); } else if (property == SubtitleContentProperty::SUBTITLE_Y_SCALE) { - checked_set (_y_scale, scs ? lrint (scs->subtitle_y_scale() * 100) : 100); + checked_set (_y_scale, scs ? lrint (scs->subtitle->subtitle_y_scale() * 100) : 100); } else if (property == SubtitleContentProperty::SUBTITLE_LANGUAGE) { - checked_set (_language, scs ? scs->subtitle_language() : ""); + checked_set (_language, scs ? scs->subtitle->subtitle_language() : ""); } else if (property == DCPContentProperty::REFERENCE_SUBTITLE) { if (scs) { shared_ptr dcp = dynamic_pointer_cast (scs); @@ -214,16 +215,16 @@ SubtitlePanel::film_content_changed (int property) void SubtitlePanel::use_toggled () { - BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { - i->set_use_subtitles (_use->GetValue()); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->subtitle->set_use_subtitles (_use->GetValue()); } } void SubtitlePanel::burn_toggled () { - BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { - i->set_burn_subtitles (_burn->GetValue()); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->subtitle->set_burn_subtitles (_burn->GetValue()); } } @@ -235,13 +236,13 @@ SubtitlePanel::setup_sensitivity () int text_subs = 0; int dcp_subs = 0; int image_subs = 0; - SubtitleContentList sel = _parent->selected_subtitle (); - BOOST_FOREACH (shared_ptr i, sel) { + ContentList sel = _parent->selected_subtitle (); + BOOST_FOREACH (shared_ptr i, sel) { shared_ptr fc = boost::dynamic_pointer_cast (i); shared_ptr sc = boost::dynamic_pointer_cast (i); shared_ptr dsc = boost::dynamic_pointer_cast (i); if (fc) { - if (fc->has_subtitles ()) { + if (fc->subtitle) { ++ffmpeg_subs; ++any_subs; } @@ -255,10 +256,10 @@ SubtitlePanel::setup_sensitivity () ++any_subs; } - if (i->has_image_subtitles ()) { + if (i->subtitle->has_image_subtitles ()) { ++image_subs; /* We must burn image subtitles at the moment */ - i->set_burn_subtitles (true); + i->subtitle->set_burn_subtitles (true); } } @@ -312,41 +313,41 @@ SubtitlePanel::stream_changed () void SubtitlePanel::x_offset_changed () { - BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { - i->set_subtitle_x_offset (_x_offset->GetValue() / 100.0); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->subtitle->set_subtitle_x_offset (_x_offset->GetValue() / 100.0); } } void SubtitlePanel::y_offset_changed () { - BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { - i->set_subtitle_y_offset (_y_offset->GetValue() / 100.0); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->subtitle->set_subtitle_y_offset (_y_offset->GetValue() / 100.0); } } void SubtitlePanel::x_scale_changed () { - SubtitleContentList c = _parent->selected_subtitle (); + ContentList c = _parent->selected_subtitle (); if (c.size() == 1) { - c.front()->set_subtitle_x_scale (_x_scale->GetValue() / 100.0); + c.front()->subtitle->set_subtitle_x_scale (_x_scale->GetValue() / 100.0); } } void SubtitlePanel::y_scale_changed () { - BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { - i->set_subtitle_y_scale (_y_scale->GetValue() / 100.0); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->subtitle->set_subtitle_y_scale (_y_scale->GetValue() / 100.0); } } void SubtitlePanel::language_changed () { - BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { - i->set_subtitle_language (wx_to_std (_language->GetValue())); + BOOST_FOREACH (shared_ptr i, _parent->selected_subtitle ()) { + i->subtitle->set_subtitle_language (wx_to_std (_language->GetValue())); } } @@ -373,7 +374,7 @@ SubtitlePanel::subtitle_view_clicked () _subtitle_view = 0; } - SubtitleContentList c = _parent->selected_subtitle (); + ContentList c = _parent->selected_subtitle (); DCPOMATIC_ASSERT (c.size() == 1); shared_ptr decoder; @@ -402,7 +403,7 @@ SubtitlePanel::fonts_dialog_clicked () _fonts_dialog = 0; } - SubtitleContentList c = _parent->selected_subtitle (); + ContentList c = _parent->selected_subtitle (); DCPOMATIC_ASSERT (c.size() == 1); _fonts_dialog = new FontsDialog (this, c.front ()); @@ -428,7 +429,7 @@ SubtitlePanel::reference_clicked () void SubtitlePanel::appearance_dialog_clicked () { - SubtitleContentList c = _parent->selected_subtitle (); + ContentList c = _parent->selected_subtitle (); DCPOMATIC_ASSERT (c.size() == 1); shared_ptr sr = dynamic_pointer_cast (c.front ()); diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h index 3dbae9909..f72b3c248 100644 --- a/src/wx/subtitle_panel.h +++ b/src/wx/subtitle_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington 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 diff --git a/src/wx/text_subtitle_appearance_dialog.cc b/src/wx/text_subtitle_appearance_dialog.cc index bdab2c615..63df4fc20 100644 --- a/src/wx/text_subtitle_appearance_dialog.cc +++ b/src/wx/text_subtitle_appearance_dialog.cc @@ -19,6 +19,7 @@ #include "text_subtitle_appearance_dialog.h" #include "lib/text_subtitle_content.h" +#include "lib/subtitle_content.h" #include #include @@ -42,17 +43,19 @@ TextSubtitleAppearanceDialog::TextSubtitleAppearanceDialog (wxWindow* parent, sh 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)); + _colour->SetColour (wxColour (_content->subtitle->colour().r, _content->subtitle->colour().g, _content->subtitle->colour().b)); + _outline->SetValue (_content->subtitle->outline ()); + _outline_colour->SetColour ( + wxColour (_content->subtitle->outline_colour().r, _content->subtitle->outline_colour().g, _content->subtitle->outline_colour().b) + ); } void TextSubtitleAppearanceDialog::apply () { wxColour const c = _colour->GetColour (); - _content->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue())); - _content->set_outline (_outline->GetValue ()); + _content->subtitle->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue())); + _content->subtitle->set_outline (_outline->GetValue ()); wxColour const oc = _outline_colour->GetColour (); - _content->set_outline_colour (dcp::Colour (oc.Red(), oc.Green(), oc.Blue())); + _content->subtitle->set_outline_colour (dcp::Colour (oc.Red(), oc.Green(), oc.Blue())); } diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 31981deea..56af6f771 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -154,9 +154,8 @@ Timeline::recreate_views () _views.push_back (shared_ptr (new TimelineAudioContentView (*this, i))); } - shared_ptr sc = dynamic_pointer_cast (i); - if (sc && sc->has_subtitles ()) { - _views.push_back (shared_ptr (new TimelineSubtitleContentView (*this, sc))); + if (i->subtitle) { + _views.push_back (shared_ptr (new TimelineSubtitleContentView (*this, i))); } } diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h index b1b8ecd5d..046f0fecf 100644 --- a/src/wx/timeline_content_view.h +++ b/src/wx/timeline_content_view.h @@ -47,13 +47,16 @@ public: virtual wxColour background_colour () const = 0; virtual wxColour foreground_colour () const = 0; +protected: + + boost::weak_ptr _content; + private: void do_paint (wxGraphicsContext* gc, std::list > overlaps); int y_pos (int t) const; void content_changed (int p); - boost::weak_ptr _content; boost::optional _track; bool _selected; diff --git a/src/wx/timeline_subtitle_content_view.cc b/src/wx/timeline_subtitle_content_view.cc index 2b6f8c4a9..83360ac42 100644 --- a/src/wx/timeline_subtitle_content_view.cc +++ b/src/wx/timeline_subtitle_content_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington 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 @@ -19,12 +19,12 @@ #include "timeline_subtitle_content_view.h" #include "lib/subtitle_content.h" +#include "lib/content.h" using boost::shared_ptr; -TimelineSubtitleContentView::TimelineSubtitleContentView (Timeline& tl, shared_ptr c) +TimelineSubtitleContentView::TimelineSubtitleContentView (Timeline& tl, shared_ptr c) : TimelineContentView (tl, c) - , _subtitle_content (c) { } @@ -32,7 +32,6 @@ TimelineSubtitleContentView::TimelineSubtitleContentView (Timeline& tl, shared_p wxColour TimelineSubtitleContentView::background_colour () const { - shared_ptr sc = _subtitle_content.lock (); if (!active ()) { return wxColour (210, 210, 210, 128); } @@ -43,7 +42,6 @@ TimelineSubtitleContentView::background_colour () const wxColour TimelineSubtitleContentView::foreground_colour () const { - shared_ptr sc = _subtitle_content.lock (); if (!active ()) { return wxColour (180, 180, 180, 128); } @@ -54,6 +52,7 @@ TimelineSubtitleContentView::foreground_colour () const bool TimelineSubtitleContentView::active () const { - shared_ptr sc = _subtitle_content.lock (); - return sc && sc->use_subtitles(); + shared_ptr c = _content.lock (); + DCPOMATIC_ASSERT (c); + return c->subtitle && c->subtitle->use_subtitles(); } diff --git a/src/wx/timeline_subtitle_content_view.h b/src/wx/timeline_subtitle_content_view.h index 6b59912a3..d2b6a5a3c 100644 --- a/src/wx/timeline_subtitle_content_view.h +++ b/src/wx/timeline_subtitle_content_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington 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 @@ -27,13 +27,10 @@ class SubtitleContent; class TimelineSubtitleContentView : public TimelineContentView { public: - TimelineSubtitleContentView (Timeline& tl, boost::shared_ptr c); + TimelineSubtitleContentView (Timeline& tl, boost::shared_ptr c); private: bool active () const; wxColour background_colour () const; wxColour foreground_colour () const; - - boost::weak_ptr _subtitle_content; }; - diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 241b0f706..18a07add4 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -264,21 +264,20 @@ TimingPanel::film_content_changed (int property) int count_ac = 0; shared_ptr ac; int count_sc = 0; - shared_ptr sc; + shared_ptr sc; BOOST_FOREACH (shared_ptr i, _parent->selected ()) { if (i->video) { check_vc.insert (i->video->video_frame_rate ()); vc = i; } shared_ptr at = dynamic_pointer_cast (i); - if (at) { + if (i->audio) { ++count_ac; ac = at; } - shared_ptr st = dynamic_pointer_cast (i); - if (st) { + if (i->subtitle) { ++count_sc; - sc = st; + sc = i; } } diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index f6f234a0d..718c3dd86 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -408,7 +408,7 @@ VideoPanel::edit_colour_conversion_clicked () return; } - ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->yuv ()); + ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->video->yuv ()); d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front ().conversion)); d->ShowModal (); vc.front()->video->set_colour_conversion (d->get ()); -- 2.30.2