Fix supporter name.
[dcpomatic.git] / src / wx / subtitle_panel.cc
index 52b23f5a20069eab46138bbd436be696f45ef319..840d3dad57c058ae8e8d993481b2b395d69c8235 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/dcp_subtitle_decoder.h"
 #include "lib/dcp_content.h"
 #include "lib/subtitle_content.h"
+#include "lib/decoder_factory.h"
 #include <wx/spinctrl.h>
 #include <boost/foreach.hpp>
 
@@ -244,6 +245,7 @@ SubtitlePanel::setup_sensitivity ()
                shared_ptr<const DCPSubtitleContent> dsc = boost::dynamic_pointer_cast<const DCPSubtitleContent> (i);
                if (fc) {
                        if (fc->subtitle) {
+                               DCPOMATIC_ASSERT (fc->subtitle_stream());
                                /* This content has some subtitles; check the selected stream to decide what type */
                                if (fc->subtitle_stream()->has_text()) {
                                        ++text_subs;
@@ -384,17 +386,8 @@ SubtitlePanel::subtitle_view_clicked ()
        ContentList c = _parent->selected_subtitle ();
        DCPOMATIC_ASSERT (c.size() == 1);
 
-       shared_ptr<Decoder> decoder;
-
-       shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
-       if (sr) {
-               decoder.reset (new TextSubtitleDecoder (sr));
-       }
-
-       shared_ptr<DCPSubtitleContent> dc = dynamic_pointer_cast<DCPSubtitleContent> (c.front ());
-       if (dc) {
-               decoder.reset (new DCPSubtitleDecoder (dc));
-       }
+       list<shared_ptr<ImageDecoder> > image_decoders;
+       shared_ptr<Decoder> decoder = decoder_factory (c.front(), image_decoders, _parent->film()->log(), false);
 
        if (decoder) {
                _subtitle_view = new SubtitleView (this, _parent->film(), decoder, c.front()->position ());
@@ -439,15 +432,33 @@ SubtitlePanel::appearance_dialog_clicked ()
        ContentList c = _parent->selected_subtitle ();
        DCPOMATIC_ASSERT (c.size() == 1);
 
-       shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
-       if (sr) {
-               TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, sr);
+       bool text = false;
+       bool image = false;
+
+       if (
+               dynamic_pointer_cast<TextSubtitleContent> (c.front()) ||
+               dynamic_pointer_cast<DCPContent> (c.front()) ||
+               dynamic_pointer_cast<DCPSubtitleContent> (c.front())) {
+
+               text = true;
+       }
+
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c.front());
+       if (fc) {
+               if (fc->subtitle_stream()->has_text()) {
+                       text = true;
+               } else if (fc->subtitle_stream()->has_image()) {
+                       image = true;
+               }
+       }
+
+       if (text) {
+               TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, c.front()->subtitle);
                if (d->ShowModal () == wxID_OK) {
                        d->apply ();
                }
                d->Destroy ();
-       } else {
-               shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c.front ());
+       } else if (image) {
                DCPOMATIC_ASSERT (fc);
                ImageSubtitleColourDialog* d = new ImageSubtitleColourDialog (this, fc, fc->subtitle_stream ());
                if (d->ShowModal() == wxID_OK) {