Introduce the idea of unknown original subtitle type to clean up the GUI a bit.
authorCarl Hetherington <cth@carlh.net>
Mon, 23 Jul 2018 15:42:28 +0000 (16:42 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 23 Jul 2018 15:42:28 +0000 (16:42 +0100)
src/lib/dcp_content.cc
src/lib/dcp_subtitle_content.cc
src/lib/ffmpeg_content.cc
src/lib/string_text_file_content.cc
src/lib/text_content.cc
src/lib/text_content.h
src/lib/types.cc
src/lib/types.h
src/wx/text_panel.cc

index 5371fbc11ca170a3649df461e063388f6c356475..b6a66f90ac8423650af4c82fc33381c48bdb43f7 100644 (file)
@@ -193,7 +193,7 @@ DCPContent::examine (shared_ptr<Job> job)
                _name = examiner->name ();
                for (int i = 0; i < TEXT_COUNT; ++i) {
                        if (examiner->has_text(static_cast<TextType>(i))) {
-                               text.push_back (shared_ptr<TextContent>(new TextContent(this, static_cast<TextType>(i))));
+                               text.push_back (shared_ptr<TextContent>(new TextContent(this, static_cast<TextType>(i), static_cast<TextType>(i))));
                        }
                }
                texts = text.size ();
index 5acc51ac4da1d8bc0119ae66fbc0513b383ba66c..a8e98d4264b3d82f12293b9f22c6eccbeebe4ceb 100644 (file)
@@ -40,7 +40,7 @@ using dcp::raw_convert;
 DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path)
        : Content (film, path)
 {
-       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE)));
+       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_OPEN_SUBTITLE)));
 }
 
 DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
index fc2a3ff4080070196e57c417193be92e129b9efb..ebcbcc47ea008bcf1245f020af6483b4cde77cbb 100644 (file)
@@ -304,7 +304,7 @@ FFmpegContent::examine (shared_ptr<Job> job)
                _subtitle_streams = examiner->subtitle_streams ();
                if (!_subtitle_streams.empty ()) {
                        text.clear ();
-                       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE)));
+                       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)));
                        _subtitle_stream = _subtitle_streams.front ();
                }
 
index 2698dbb6d733fad73da91e07cf1d4cbfed301cb0..9c941c2bb14842c813a6d78f7a3f2b54218bfeec 100644 (file)
 using std::string;
 using std::cout;
 using boost::shared_ptr;
+using boost::optional;
 using dcp::raw_convert;
 
 StringTextFileContent::StringTextFileContent (shared_ptr<const Film> film, boost::filesystem::path path)
        : Content (film, path)
 {
-       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE)));
+       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)));
 }
 
 StringTextFileContent::StringTextFileContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
index 011c42f35fff5318ef2ad528608708250970141a..761ffc6b729dffce64e23397bc48f5c5b7f5dcfc 100644 (file)
@@ -57,7 +57,7 @@ int const TextContentProperty::FADE_OUT = 513;
 int const TextContentProperty::OUTLINE_WIDTH = 514;
 int const TextContentProperty::TYPE = 515;
 
-TextContent::TextContent (Content* parent, TextType original_type)
+TextContent::TextContent (Content* parent, TextType type, TextType original_type)
        : ContentPart (parent)
        , _use (false)
        , _burn (false)
@@ -67,7 +67,7 @@ TextContent::TextContent (Content* parent, TextType original_type)
        , _y_scale (1)
        , _line_spacing (1)
        , _outline_width (2)
-       , _type (original_type)
+       , _type (type)
        , _original_type (original_type)
 {
 
@@ -121,7 +121,6 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
        , _line_spacing (node->optional_number_child<double>("LineSpacing").get_value_or (1))
        , _outline_width (node->optional_number_child<int>("OutlineWidth").get_value_or (2))
        , _type (TEXT_OPEN_SUBTITLE)
-       , _original_type (TEXT_OPEN_SUBTITLE)
 {
        if (version >= 37) {
                _use = node->bool_child ("Use");
@@ -226,7 +225,9 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
        connect_to_fonts ();
 
        _type = string_to_text_type (node->optional_string_child("Type").get_value_or("open"));
-       _original_type = string_to_text_type (node->optional_string_child("OriginalType").get_value_or("open"));
+       if (node->optional_string_child("OriginalType")) {
+               _original_type = string_to_text_type (node->optional_string_child("OriginalType").get());
+       }
 }
 
 TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)
index 5aacc7ecf7182f38ebcd7685d308ab93cab79b86..e5981acafe90edda62f7aa389dbc1fd6f16efc13 100644 (file)
@@ -58,7 +58,7 @@ public:
 class TextContent : public ContentPart
 {
 public:
-       TextContent (Content* parent, TextType original_type);
+       TextContent (Content* parent, TextType type, TextType original_type);
        TextContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
 
        void as_xml (xmlpp::Node *) const;
index d25c9aba4bf2557072704e7f3236a9b358f9a910..b193ac9cf90400699151495890ae5d05ff2a5fb2 100644 (file)
@@ -96,7 +96,9 @@ Crop::as_xml (xmlpp::Node* node) const
 TextType
 string_to_text_type (string s)
 {
-       if (s == "open-subtitle") {
+       if (s == "unknown") {
+               return TEXT_UNKNOWN;
+       } else if (s == "open-subtitle") {
                return TEXT_OPEN_SUBTITLE;
        } else if (s == "closed") {
                return TEXT_CLOSED_CAPTION;
@@ -109,6 +111,8 @@ string
 text_type_to_string (TextType t)
 {
        switch (t) {
+       case TEXT_UNKNOWN:
+               return "unknown";
        case TEXT_OPEN_SUBTITLE:
                return "open-subtitle";
        case TEXT_CLOSED_CAPTION:
@@ -122,6 +126,8 @@ string
 text_type_to_name (TextType t)
 {
        switch (t) {
+       case TEXT_UNKNOWN:
+               return _("Timed text");
        case TEXT_OPEN_SUBTITLE:
                return _("Open subtitles");
        case TEXT_CLOSED_CAPTION:
index 02d71e2973c159bc6e1480df367996d558d9f599..42e2e3eecd2c8d6801e3b6563ecdcf53a5b116d4 100644 (file)
@@ -144,6 +144,7 @@ enum ReelType
  */
 enum TextType
 {
+       TEXT_UNKNOWN,
        TEXT_OPEN_SUBTITLE,
        TEXT_CLOSED_CAPTION,
        TEXT_COUNT
index 81ea9c9418f0cd831406f095a7fbb5c75570947b..980dd36cb1c3d4312f5b9a7e0759edd8f75972fe 100644 (file)
@@ -42,8 +42,10 @@ using std::string;
 using std::list;
 using std::cout;
 using boost::shared_ptr;
+using boost::optional;
 using boost::dynamic_pointer_cast;
 
+/** @param t Original text type of the content, if known */
 TextPanel::TextPanel (ContentPanel* p, TextType t)
        : ContentSubPanel (p, std_to_wx(text_type_to_name(t)))
        , _text_view (0)
@@ -52,7 +54,12 @@ TextPanel::TextPanel (ContentPanel* p, TextType t)
 {
        wxBoxSizer* reference_sizer = new wxBoxSizer (wxVERTICAL);
 
-       _reference = new wxCheckBox (this, wxID_ANY, _("Use this DCP's subtitle as OV and make VF"));
+       wxString refer = _("Use this DCP's subtitle as OV and make VF");
+       if (t == TEXT_CLOSED_CAPTION) {
+               refer = _("Use this DCP's closed caption as OV and make VF");
+       }
+
+       _reference = new wxCheckBox (this, wxID_ANY, refer);
        reference_sizer->Add (_reference, 0, wxLEFT | wxRIGHT | wxTOP, DCPOMATIC_SIZER_GAP);
 
        _reference_note = new wxStaticText (this, wxID_ANY, _(""));