Subtitle rearrangements.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Apr 2016 15:34:22 +0000 (16:34 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 18 May 2016 10:50:29 +0000 (11:50 +0100)
25 files changed:
src/lib/content_part.h
src/lib/player.cc
src/lib/playlist.cc
src/lib/subtitle_content.cc
src/lib/subtitle_content.h
src/lib/text_subtitle_content.cc
src/lib/text_subtitle_content.h
src/lib/text_subtitle_decoder.cc
src/lib/types.h
src/wx/content_panel.cc
src/wx/content_panel.h
src/wx/dcp_panel.cc
src/wx/fonts_dialog.cc
src/wx/fonts_dialog.h
src/wx/hints_dialog.cc
src/wx/hints_dialog.h
src/wx/subtitle_panel.cc
src/wx/subtitle_panel.h
src/wx/text_subtitle_appearance_dialog.cc
src/wx/timeline.cc
src/wx/timeline_content_view.h
src/wx/timeline_subtitle_content_view.cc
src/wx/timeline_subtitle_content_view.h
src/wx/timing_panel.cc
src/wx/video_panel.cc

index b1282d98d96fb53e5c35d79a3d6b4df78b350e49..9ee26cbdb1d47378ac3502202aa473ffbfe5cd7b 100644 (file)
@@ -21,6 +21,7 @@
 #define DCPOMATIC_CONTENT_PART_H
 
 #include <boost/weak_ptr.hpp>
+#include <boost/thread/mutex.hpp>
 
 class Content;
 class Film;
index ca833208cee034b6113f904ed997f73e43aaa882..9c216c253eca301cf4066e2b6a73f51431f9ff8e 100644 (file)
@@ -219,9 +219,9 @@ Player::playlist_content_changed (weak_ptr<Content> 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
                ) {
 
index 9df7857b5cda85297ee00cbda307b9c7ef66d4b0..64599305031527def4cc8012d1ec4a797405399a 100644 (file)
@@ -130,7 +130,7 @@ Playlist::maybe_sequence ()
 
        DCPTime next;
        BOOST_FOREACH (shared_ptr<Content> 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;
                }
 
index bdc2b729cf8786757bc7bd3ce044534a7b8916a2..a6dcbf9aef40dea4763802cdc336dbc77967889a 100644 (file)
@@ -23,6 +23,7 @@
 #include "safe_stringstream.h"
 #include "font.h"
 #include "raw_convert.h"
+#include "content.h"
 #include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
 #include <boost/foreach.hpp>
@@ -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<const Film> film)
        : ContentPart (parent, film)
@@ -55,18 +59,32 @@ SubtitleContent::SubtitleContent (Content* parent, shared_ptr<const Film> 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<const Film> 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<int>("Red").get_value_or(255),
+               node->optional_number_child<int>("Green").get_value_or(255),
+               node->optional_number_child<int>("Blue").get_value_or(255)
+               )
+       , _outline (node->optional_bool_child("Outline").get_value_or(false))
+       , _outline_colour (
+               node->optional_number_child<int>("OutlineRed").get_value_or(255),
+               node->optional_number_child<int>("OutlineGreen").get_value_or(255),
+               node->optional_number_child<int>("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<string> (_subtitle_x_scale));
        root->add_child("SubtitleYScale")->add_child_text (raw_convert<string> (_subtitle_y_scale));
        root->add_child("SubtitleLanguage")->add_child_text (_subtitle_language);
+       root->add_child("Red")->add_child_text (raw_convert<string> (_colour.r));
+       root->add_child("Green")->add_child_text (raw_convert<string> (_colour.g));
+       root->add_child("Blue")->add_child_text (raw_convert<string> (_colour.b));
+       root->add_child("Outline")->add_child_text (raw_convert<string> (_outline));
+       root->add_child("OutlineRed")->add_child_text (raw_convert<string> (_outline_colour.r));
+       root->add_child("OutlineGreen")->add_child_text (raw_convert<string> (_outline_colour.g));
+       root->add_child("OutlineBlue")->add_child_text (raw_convert<string> (_outline_colour.b));
 
        for (list<shared_ptr<Font> >::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<string> (subtitle_x_scale())
+       s << raw_convert<string> (subtitle_x_scale())
          << "_" << raw_convert<string> (subtitle_y_scale())
          << "_" << raw_convert<string> (subtitle_x_offset())
          << "_" << raw_convert<string> (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);
 }
index f9d5336f2d6c0fdcfdaee380421307317d424256..5982cc52c0e36aa7eed6b6c39ba90785f4b2f0cf 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "content_part.h"
 #include <libcxml/cxml.h>
+#include <dcp/types.h>
 #include <boost/signals2.hpp>
 
 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> 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<boost::shared_ptr<Font> > _fonts;
+       dcp::Colour _colour;
+       bool _outline;
+       dcp::Colour _outline_colour;
        std::list<boost::signals2::connection> _font_connections;
 };
 
index 88890ebdc455184b40ea8c57ba1278d8b23ef314..c7dd19d0318f0db1f3a783205273db5bc1cda1d9 100644 (file)
@@ -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<const Film> 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<const Film> film, cxml::ConstNodePtr node, int version)
        : Content (film, node)
        , _length (node->number_child<ContentTime::Type> ("Length"))
-       , _frame_rate (node->optional_number_child<double>("SubtitleVideoFrameRate"))
-       , _colour (
-               node->optional_number_child<int>("Red").get_value_or(255),
-               node->optional_number_child<int>("Green").get_value_or(255),
-               node->optional_number_child<int>("Blue").get_value_or(255)
-               )
-       , _outline (node->optional_bool_child("Outline").get_value_or(false))
-       , _outline_colour (
-               node->optional_number_child<int>("OutlineRed").get_value_or(255),
-               node->optional_number_child<int>("OutlineGreen").get_value_or(255),
-               node->optional_number_child<int>("OutlineBlue").get_value_or(255)
-               )
 {
        subtitle.reset (new SubtitleContent (this, film, node, version));
 }
@@ -74,11 +55,11 @@ TextSubtitleContent::examine (boost::shared_ptr<Job> 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<Font> (new Font (font_id)));
+       subtitle->add_font (shared_ptr<Font> (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<string> (_length.get ()));
-       if (_frame_rate) {
-               node->add_child("SubtitleVideoFrameRate")->add_child_text (raw_convert<string> (_frame_rate.get()));
-       }
-       node->add_child("Red")->add_child_text (raw_convert<string> (_colour.r));
-       node->add_child("Green")->add_child_text (raw_convert<string> (_colour.g));
-       node->add_child("Blue")->add_child_text (raw_convert<string> (_colour.b));
-       node->add_child("Outline")->add_child_text (raw_convert<string> (_outline));
-       node->add_child("OutlineRed")->add_child_text (raw_convert<string> (_outline_colour.r));
-       node->add_child("OutlineGreen")->add_child_text (raw_convert<string> (_outline_colour.g));
-       node->add_child("OutlineBlue")->add_child_text (raw_convert<string> (_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);
-}
index a2ef5d98abed2eb15dd8e720c9a4cb34d7ae9882..76440ba9b2b5d959ebc1c648d8a750133f86fc7e 100644 (file)
 
 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<TextSubtitleContent> (Content::shared_from_this ());
        }
 
-       /* Content */
        void examine (boost::shared_ptr<Job>);
        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<double> _frame_rate;
-       dcp::Colour _colour;
-       bool _outline;
-       dcp::Colour _outline_colour;
 };
index 36e44cc99012936979cdb84bee26bb65a74bfdf1..94604cd714aae108dfd297ce6ed3a96ba5fd78e9 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "text_subtitle_decoder.h"
 #include "text_subtitle_content.h"
+#include "subtitle_content.h"
 #include <dcp/subtitle_string.h>
 #include <boost/foreach.hpp>
 #include <iostream>
@@ -60,9 +61,6 @@ TextSubtitleDecoder::pass (PassReason, bool)
 
        /* XXX: we are ignoring positioning specified in the file */
 
-       shared_ptr<const TextSubtitleContent> content = dynamic_pointer_cast<const TextSubtitleContent> (_subtitle_content);
-       DCPOMATIC_ASSERT (content);
-
        list<dcp::SubtitleString> 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)
                                        )
index 33bad1d24455fc03938f175cd3f1bf3be7c06b1c..2bc6fa3a42894821042ca2109eda9e0165cfb5c1 100644 (file)
@@ -49,7 +49,6 @@ namespace xmlpp {
 
 typedef std::vector<boost::shared_ptr<Content> > ContentList;
 typedef std::vector<boost::shared_ptr<AudioContent> > AudioContentList;
-typedef std::vector<boost::shared_ptr<SubtitleContent> > SubtitleContentList;
 typedef std::vector<boost::shared_ptr<FFmpegContent> > FFmpegContentList;
 
 typedef int64_t Frame;
index 55dd671e9061bd6683d7f6a3667d7951ae4957ef..ad489489796d958c404281fcd3899cdc5e650116 100644 (file)
@@ -178,15 +178,14 @@ ContentPanel::selected_audio ()
        return ac;
 }
 
-SubtitleContentList
+ContentList
 ContentPanel::selected_subtitle ()
 {
-       SubtitleContentList sc;
+       ContentList sc;
 
        BOOST_FOREACH (shared_ptr<Content> i, selected ()) {
-               shared_ptr<SubtitleContent> t = dynamic_pointer_cast<SubtitleContent> (i);
-               if (t) {
-                       sc.push_back (t);
+               if (i->subtitle) {
+                       sc.push_back (i);
                }
        }
 
index e735213d3860c3b108928e93903ada20ebd9f913..f4e2dbae283f9efa5fa6361e6fcf32548925a362 100644 (file)
@@ -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 ();
index 42d2f153701fa056029c70a932fc9001801d0a37..c62767c9d608381fa838a957edef321956d8812e 100644 (file)
@@ -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 <dcp/key.h>
 #include <dcp/raw_convert.h>
index b79580d7cf9ad5dec487e5ca4bd86f6ced062f81..3f8bca239551a5ef94666a2db61f1ec0372bec26 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2016 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
@@ -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 <wx/wx.h>
 #include <boost/foreach.hpp>
@@ -32,7 +33,7 @@ using std::string;
 using std::cout;
 using boost::shared_ptr;
 
-FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<SubtitleContent> content)
+FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<Content> content)
        : wxDialog (parent, wxID_ANY, _("Fonts"))
        , _content (content)
 {
@@ -96,14 +97,14 @@ FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<SubtitleContent> content)
 void
 FontsDialog::setup ()
 {
-       shared_ptr<SubtitleContent> content = _content.lock ();
+       shared_ptr<Content> content = _content.lock ();
        if (!content) {
                return;
        }
 
        _fonts->DeleteAllItems ();
        size_t n = 0;
-       BOOST_FOREACH (shared_ptr<Font> i, content->fonts ()) {
+       BOOST_FOREACH (shared_ptr<Font> 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<SubtitleContent> content = _content.lock ();
+       shared_ptr<Content> 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> font;
-       BOOST_FOREACH (shared_ptr<Font> i, content->fonts()) {
+       BOOST_FOREACH (shared_ptr<Font> i, content->subtitle->fonts()) {
                if (i->id() == id) {
                        font = i;
                }
index e04dc9937035407362eb25ac8c7401a8686dd6f9..723414a6baee836dce224936d248277001adfb7b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2016 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
 #include <boost/weak_ptr.hpp>
 #include <boost/filesystem.hpp>
 
-class SubtitleContent;
+class Content;
 
 class FontsDialog : public wxDialog
 {
 public:
-       FontsDialog (wxWindow* parent, boost::shared_ptr<SubtitleContent>);
+       FontsDialog (wxWindow* parent, boost::shared_ptr<Content>);
 
 private:
        void setup ();
@@ -36,7 +36,7 @@ private:
        void selection_changed ();
        void edit_clicked ();
 
-       boost::weak_ptr<SubtitleContent> _content;
+       boost::weak_ptr<Content> _content;
        wxListCtrl* _fonts;
        wxButton* _edit;
 };
index 2cf109e5512a944f2c05293e348a4378b2b2bb6e..75643c312f38deffb104b0766ceaba7d4da01c27 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 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
 
 */
 
+#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 <wx/richtext/richtextctrl.h>
 #include <boost/algorithm/string.hpp>
 #include <boost/foreach.hpp>
index f4ef00aa2edcfbb820fe23b16147ba0eeeec08bb..abf718e8f4c009b820fabd6f338da30a10caeda0 100644 (file)
@@ -17,8 +17,9 @@
 
 */
 
-#include <boost/weak_ptr.hpp>
 #include <wx/wx.h>
+#include <boost/weak_ptr.hpp>
+#include <boost/signals2.hpp>
 
 class wxRichTextCtrl;
 class Film;
index a53679673f649e90dd88d40517b260b223da5dd6..6b910afae8cd519582790cdaf0f435ac46692366 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 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
@@ -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 <wx/spinctrl.h>
 #include <boost/foreach.hpp>
 
@@ -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<FFmpegContent> fcs;
        if (fc.size() == 1) {
                fcs = fc.front ();
        }
 
-       shared_ptr<SubtitleContent> scs;
+       shared_ptr<Content> 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<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (scs);
@@ -214,16 +215,16 @@ SubtitlePanel::film_content_changed (int property)
 void
 SubtitlePanel::use_toggled ()
 {
-       BOOST_FOREACH (shared_ptr<SubtitleContent> i, _parent->selected_subtitle ()) {
-               i->set_use_subtitles (_use->GetValue());
+       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_subtitle ()) {
+               i->subtitle->set_use_subtitles (_use->GetValue());
        }
 }
 
 void
 SubtitlePanel::burn_toggled ()
 {
-       BOOST_FOREACH (shared_ptr<SubtitleContent> i, _parent->selected_subtitle ()) {
-               i->set_burn_subtitles (_burn->GetValue());
+       BOOST_FOREACH (shared_ptr<Content> 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<SubtitleContent> i, sel) {
+       ContentList sel = _parent->selected_subtitle ();
+       BOOST_FOREACH (shared_ptr<Content> i, sel) {
                shared_ptr<const FFmpegContent> fc = boost::dynamic_pointer_cast<const FFmpegContent> (i);
                shared_ptr<const TextSubtitleContent> sc = boost::dynamic_pointer_cast<const TextSubtitleContent> (i);
                shared_ptr<const DCPSubtitleContent> dsc = boost::dynamic_pointer_cast<const DCPSubtitleContent> (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<SubtitleContent> i, _parent->selected_subtitle ()) {
-               i->set_subtitle_x_offset (_x_offset->GetValue() / 100.0);
+       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_subtitle ()) {
+               i->subtitle->set_subtitle_x_offset (_x_offset->GetValue() / 100.0);
        }
 }
 
 void
 SubtitlePanel::y_offset_changed ()
 {
-       BOOST_FOREACH (shared_ptr<SubtitleContent> i, _parent->selected_subtitle ()) {
-               i->set_subtitle_y_offset (_y_offset->GetValue() / 100.0);
+       BOOST_FOREACH (shared_ptr<Content> 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<SubtitleContent> i, _parent->selected_subtitle ()) {
-               i->set_subtitle_y_scale (_y_scale->GetValue() / 100.0);
+       BOOST_FOREACH (shared_ptr<Content> i, _parent->selected_subtitle ()) {
+               i->subtitle->set_subtitle_y_scale (_y_scale->GetValue() / 100.0);
        }
 }
 
 void
 SubtitlePanel::language_changed ()
 {
-       BOOST_FOREACH (shared_ptr<SubtitleContent> i, _parent->selected_subtitle ()) {
-               i->set_subtitle_language (wx_to_std (_language->GetValue()));
+       BOOST_FOREACH (shared_ptr<Content> 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<SubtitleDecoder> 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<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
index 3dbae990952825e05d205629909120434b618831..f72b3c2486c3f7f3e109441bfef6837b31f81bbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2016 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
index bdab2c615673f5d7246790781e3bb91154ed4379..63df4fc2066f67d5cca263842dd001c8bdb7058d 100644 (file)
@@ -19,6 +19,7 @@
 
 #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>
 
@@ -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()));
 }
index 31981deea7b4129e590715ca0a6146e2031f0839..56af6f771b22a08b39e7ae0f072308b3d7158374 100644 (file)
@@ -154,9 +154,8 @@ Timeline::recreate_views ()
                        _views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, i)));
                }
 
-               shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (i);
-               if (sc && sc->has_subtitles ()) {
-                       _views.push_back (shared_ptr<TimelineView> (new TimelineSubtitleContentView (*this, sc)));
+               if (i->subtitle) {
+                       _views.push_back (shared_ptr<TimelineView> (new TimelineSubtitleContentView (*this, i)));
                }
        }
 
index b1b8ecd5d44ffa0510e8c9272d8c887f60b5d1de..046f0fecf068de26de1ef0cb0a83ab16632a43d3 100644 (file)
@@ -47,13 +47,16 @@ public:
        virtual wxColour background_colour () const = 0;
        virtual wxColour foreground_colour () const = 0;
 
+protected:
+
+       boost::weak_ptr<Content> _content;
+
 private:
 
        void do_paint (wxGraphicsContext* gc, std::list<dcpomatic::Rect<int> > overlaps);
        int y_pos (int t) const;
        void content_changed (int p);
 
-       boost::weak_ptr<Content> _content;
        boost::optional<int> _track;
        bool _selected;
 
index 2b6f8c4a9273ad901ae8ac611b350529ce2a2809..83360ac42306b1d02edf189262f2b00a81c38ee8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 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
 
 #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<SubtitleContent> c)
+TimelineSubtitleContentView::TimelineSubtitleContentView (Timeline& tl, shared_ptr<Content> c)
        : TimelineContentView (tl, c)
-       , _subtitle_content (c)
 {
 
 }
@@ -32,7 +32,6 @@ TimelineSubtitleContentView::TimelineSubtitleContentView (Timeline& tl, shared_p
 wxColour
 TimelineSubtitleContentView::background_colour () const
 {
-       shared_ptr<SubtitleContent> 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<SubtitleContent> 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<SubtitleContent> sc = _subtitle_content.lock ();
-       return sc && sc->use_subtitles();
+       shared_ptr<Content> c = _content.lock ();
+       DCPOMATIC_ASSERT (c);
+       return c->subtitle && c->subtitle->use_subtitles();
 }
index 6b59912a3e48380f85daf01b7e79d62766af48fd..d2b6a5a3cd12fec08901091b9268b996cd24a928 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 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
@@ -27,13 +27,10 @@ class SubtitleContent;
 class TimelineSubtitleContentView : public TimelineContentView
 {
 public:
-       TimelineSubtitleContentView (Timeline& tl, boost::shared_ptr<SubtitleContent> c);
+       TimelineSubtitleContentView (Timeline& tl, boost::shared_ptr<Content> c);
 
 private:
        bool active () const;
        wxColour background_colour () const;
        wxColour foreground_colour () const;
-
-       boost::weak_ptr<SubtitleContent> _subtitle_content;
 };
-
index 241b0f70647e0c92c77a6e532ab78841c8f78c2b..18a07add48838792b4ee20679b0bbe5a73a4c404 100644 (file)
@@ -264,21 +264,20 @@ TimingPanel::film_content_changed (int property)
                int count_ac = 0;
                shared_ptr<const Content> ac;
                int count_sc = 0;
-               shared_ptr<const SubtitleContent> sc;
+               shared_ptr<const Content> sc;
                BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) {
                        if (i->video) {
                                check_vc.insert (i->video->video_frame_rate ());
                                vc = i;
                        }
                        shared_ptr<const AudioContent> at = dynamic_pointer_cast<const AudioContent> (i);
-                       if (at) {
+                       if (i->audio) {
                                ++count_ac;
                                ac = at;
                        }
-                       shared_ptr<const SubtitleContent> st = dynamic_pointer_cast<const SubtitleContent> (i);
-                       if (st) {
+                       if (i->subtitle) {
                                ++count_sc;
-                               sc = st;
+                               sc = i;
                        }
 
                }
index f6f234a0d2bce4a3eee372e8d513e437f4a93ac7..718c3dd86ce3e3f99dcae9d67f44af6afcf6d6af 100644 (file)
@@ -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 ());