Allow changes to colours of FFmpeg subtitles (#795).
authorCarl Hetherington <cth@carlh.net>
Fri, 26 Feb 2016 21:06:27 +0000 (21:06 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 26 Feb 2016 21:06:27 +0000 (21:06 +0000)
20 files changed:
ChangeLog
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_examiner.cc
src/lib/ffmpeg_examiner.h
src/lib/ffmpeg_subtitle_stream.cc
src/lib/ffmpeg_subtitle_stream.h
src/lib/player.cc
src/lib/rgba.cc [new file with mode: 0644]
src/lib/rgba.h [new file with mode: 0644]
src/lib/wscript
src/wx/image_subtitle_colour_dialog.cc [new file with mode: 0644]
src/wx/image_subtitle_colour_dialog.h [new file with mode: 0644]
src/wx/rgba_colour_picker.cc [new file with mode: 0644]
src/wx/rgba_colour_picker.h [new file with mode: 0644]
src/wx/subtitle_panel.cc
src/wx/subtitle_panel.h
src/wx/table_dialog.h
src/wx/wscript

index b9c394e5accc7740f302d62f6690c5e25d4c745e..ba37cfe1de0823bd46f37cc7be04a4a176262dbb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-26  Carl Hetherington  <cth@carlh.net>
+
+       * Allow changes to colours of subtitles embedded
+       into video files (#795).
+
 2016-02-25  Carl Hetherington  <cth@carlh.net>
 
        * Plot all video and subtitle content on single tracks
index 9cd0395f2f6b22c02846a5f6d77859d1d0e9ef0d..789fd735fd42f46a24aed8488d13480389391545 100644 (file)
@@ -505,3 +505,14 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
                p.push_back (UserProperty (_("Video"), _("Bits per pixel"), raw_convert<string> (_bits_per_pixel.get ())));
        }
 }
+
+/** Our subtitle streams have colour maps, which can be changed, but
+ *  they have no way of signalling that change.  As a hack, we have this
+ *  method which callers can use when they've modified one of our subtitle
+ *  streams.
+ */
+void
+FFmpegContent::signal_subtitle_stream_changed ()
+{
+       signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
+}
index c7dc374fdcd526df74ea5e0941080283eb169cb4..e9cb3dacf911577105be1d91ad7e5e5dcf87cc1d 100644 (file)
@@ -37,6 +37,7 @@ class FFmpegContentProperty : public VideoContentProperty
 {
 public:
        static int const SUBTITLE_STREAMS;
+       /** The chosen subtitle stream, or something about it */
        static int const SUBTITLE_STREAM;
        static int const FILTERS;
 };
@@ -105,6 +106,8 @@ public:
        std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
        std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const;
 
+       void signal_subtitle_stream_changed ();
+
 protected:
        void add_properties (std::list<UserProperty> &) const;
 
index 294c0da8c22d0b0e7bcb8ad682645247efa4be30..a7cfb44ac5b9b26feaaca70f09363f585b32d193 100644 (file)
@@ -65,6 +65,7 @@ using std::list;
 using std::min;
 using std::pair;
 using std::max;
+using std::map;
 using boost::shared_ptr;
 using boost::is_any_of;
 using boost::split;
@@ -489,6 +490,17 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP
           (i.e. first byte B, second G, third R, fourth A)
        */
        uint32_t const * palette = (uint32_t *) rect->pict.data[1];
+       /* And the stream has a map of those palette colours to colours
+          chosen by the user; created a `mapped' palette from those settings.
+       */
+       map<RGBA, RGBA> colour_map = ffmpeg_content()->subtitle_stream()->colours ();
+       vector<RGBA> mapped_palette (rect->nb_colors);
+       for (int i = 0; i < rect->nb_colors; ++i) {
+               RGBA c ((palette[i] & 0xff0000) >> 16, (palette[i] & 0xff00) >> 8, palette[i] & 0xff, (palette[i] & 0xff000000) >> 24);
+               DCPOMATIC_ASSERT (colour_map.find(c) != colour_map.end());
+               mapped_palette[i] = colour_map[c];
+       }
+
        /* Start of the output data */
        uint32_t* out_p = (uint32_t *) image->data()[0];
 
@@ -496,8 +508,9 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP
                uint8_t* sub_line_p = sub_p;
                uint32_t* out_line_p = out_p;
                for (int x = 0; x < rect->w; ++x) {
-                       uint32_t const p = palette[*sub_line_p++];
-                       *out_line_p++ = ((p & 0xff) << 16) | (p & 0xff00) | ((p & 0xff0000) >> 16) | (p & 0xff000000);
+                       RGBA const p = mapped_palette[*sub_line_p++];
+                       /* XXX: this seems to be wrong to me (isn't the output image RGBA?) but it looks right on screen */
+                       *out_line_p++ = (p.a << 24) | (p.r << 16) | (p.g << 8) | p.b;
                }
                sub_p += rect->pict.linesize[0];
                out_p += image->stride()[0] / sizeof (uint32_t);
index 29cc69063c12fd60360aa64c061103a939845f46..850b8ba5facb2dae7d400d1c8a53c0584ea38b3d 100644 (file)
@@ -246,6 +246,23 @@ FFmpegExaminer::subtitle_packet (AVCodecContext* context, shared_ptr<FFmpegSubti
                                _last_subtitle_start[stream] = SubtitleStart (id, image, period.from);
                        }
                }
+
+               for (unsigned int i = 0; i < sub.num_rects; ++i) {
+                       if (sub.rects[i]->type == SUBTITLE_BITMAP) {
+                               uint32_t* palette = (uint32_t *) sub.rects[i]->pict.data[1];
+                               for (int j = 0; j < sub.rects[i]->nb_colors; ++j) {
+                                       RGBA rgba  (
+                                               (palette[j] & 0x00ff0000) >> 16,
+                                               (palette[j] & 0x0000ff00) >> 8,
+                                               (palette[j] & 0x000000ff) >> 0,
+                                               (palette[j] & 0xff000000) >> 24
+                                               );
+
+                                       stream->set_colour (rgba, rgba);
+                               }
+                       }
+               }
+
                avsubtitle_free (&sub);
        }
 }
index a2a80b254e7e78179fcb4a52d9b8765591fe1299..f64ea8d799dd51af807eb6cfbb29aee374cb5d95 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
index 33759d86e544f348fc374238fc1cc741e2508033..eca3fda6fcac490b4bfe8ff6bb67fe6bffb2b4c6 100644 (file)
@@ -27,6 +27,7 @@ using std::string;
 using std::map;
 using std::list;
 using std::cout;
+using std::make_pair;
 
 /** Construct a SubtitleStream from a value returned from to_string().
  *  @param t String returned from to_string().
@@ -82,6 +83,10 @@ FFmpegSubtitleStream::FFmpegSubtitleStream (cxml::ConstNodePtr node, int version
                                        )
                                );
                }
+
+               BOOST_FOREACH (cxml::NodePtr i, node->node_children ("Colour")) {
+                       _colours[RGBA(i->node_child("From"))] = RGBA (i->node_child("To"));
+               }
        }
 }
 
@@ -92,6 +97,12 @@ FFmpegSubtitleStream::as_xml (xmlpp::Node* root) const
 
        as_xml (root, _image_subtitles, "ImageSubtitle");
        as_xml (root, _text_subtitles, "TextSubtitle");
+
+       for (map<RGBA, RGBA>::const_iterator i = _colours.begin(); i != _colours.end(); ++i) {
+               xmlpp::Node* node = root->add_child("Colour");
+               i->first.as_xml (node->add_child("From"));
+               i->second.as_xml (node->add_child("To"));
+       }
 }
 
 void
@@ -173,3 +184,15 @@ FFmpegSubtitleStream::add_offset (ContentTime offset)
                i->second.to += offset;
        }
 }
+
+map<RGBA, RGBA>
+FFmpegSubtitleStream::colours () const
+{
+       return _colours;
+}
+
+void
+FFmpegSubtitleStream::set_colour (RGBA from, RGBA to)
+{
+       _colours[from] = to;
+}
index 688aaa9938633aaf0984ce332277d16ac5c63543..175eeacef036eb26b75b34faf7596d1826a2d195 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "dcpomatic_time.h"
+#include "rgba.h"
 #include "ffmpeg_stream.h"
 
 class FFmpegSubtitleStream : public FFmpegStream
@@ -37,6 +38,7 @@ public:
        std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod period, bool starting) const;
        ContentTime find_subtitle_to (std::string id) const;
        void add_offset (ContentTime offset);
+       void set_colour (RGBA from, RGBA to);
 
        bool has_image_subtitles () const {
                return !_image_subtitles.empty ();
@@ -44,6 +46,7 @@ public:
        bool has_text_subtitles () const {
                return !_text_subtitles.empty ();
        }
+       std::map<RGBA, RGBA> colours () const;
 
 private:
 
@@ -54,4 +57,5 @@ private:
 
        PeriodMap _image_subtitles;
        PeriodMap _text_subtitles;
+       std::map<RGBA, RGBA> _colours;
 };
index 3e92eb3d9090040f94868e6dbc8a9203cb326d3f..30f36107f231cc05a724df4e380ab147ad69c875 100644 (file)
@@ -222,7 +222,8 @@ Player::playlist_content_changed (weak_ptr<Content> w, int property, bool freque
                property == DCPContentProperty::CAN_BE_PLAYED ||
                property == TextSubtitleContentProperty::TEXT_SUBTITLE_COLOUR ||
                property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE ||
-               property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR
+               property == TextSubtitleContentProperty::TEXT_SUBTITLE_OUTLINE_COLOUR ||
+               property == FFmpegContentProperty::SUBTITLE_STREAM
                ) {
 
                _have_valid_pieces = false;
diff --git a/src/lib/rgba.cc b/src/lib/rgba.cc
new file mode 100644 (file)
index 0000000..dac5841
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+    Copyright (C) 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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "rgba.h"
+#include <libxml++/libxml++.h>
+#include <boost/lexical_cast.hpp>
+
+using std::string;
+using boost::lexical_cast;
+
+RGBA::RGBA (cxml::ConstNodePtr node)
+{
+       r = node->number_child<int> ("R");
+       g = node->number_child<int> ("G");
+       b = node->number_child<int> ("B");
+       a = node->number_child<int> ("A");
+}
+
+void
+RGBA::as_xml (xmlpp::Node* parent) const
+{
+       parent->add_child("R")->add_child_text (lexical_cast<string> (int (r)));
+       parent->add_child("G")->add_child_text (lexical_cast<string> (int (g)));
+       parent->add_child("B")->add_child_text (lexical_cast<string> (int (b)));
+       parent->add_child("A")->add_child_text (lexical_cast<string> (int (a)));
+}
+
+bool
+RGBA::operator< (RGBA const & other) const
+{
+       if (r != other.r) {
+               return r < other.r;
+       }
+
+       if (g != other.g) {
+               return g < other.g;
+       }
+
+       if (b != other.b) {
+               return b < other.b;
+       }
+
+       return a < other.a;
+}
diff --git a/src/lib/rgba.h b/src/lib/rgba.h
new file mode 100644 (file)
index 0000000..f950187
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+    Copyright (C) 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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef DCPOMATIC_RGBA_H
+#define DCPOMATIC_RGBA_H
+
+#include <libcxml/cxml.h>
+#include <stdint.h>
+
+/** @class RGBA
+ *  @brief A 32-bit RGBA colour.
+ */
+
+class RGBA
+{
+public:
+       RGBA ()
+               : r (0)
+               , g (0)
+               , b (0)
+               , a (0)
+       {}
+
+       RGBA (uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_)
+               : r (r_)
+               , g (g_)
+               , b (b_)
+               , a (a_)
+       {}
+
+       RGBA (cxml::ConstNodePtr node);
+
+       void as_xml (xmlpp::Node* parent) const;
+
+       uint8_t r;
+       uint8_t g;
+       uint8_t b;
+       uint8_t a;
+
+       bool operator< (RGBA const & other) const;
+};
+
+#endif
index f6ca52fb772f9eb625025136c19e43f43581373f..8dd241a4d92852ee6baab7969bf0d354b1ee2705 100644 (file)
@@ -104,6 +104,7 @@ sources = """
           reel_writer.cc
           render_subtitles.cc
           resampler.cc
+          rgba.cc
           safe_stringstream.cc
           scoped_temporary.cc
           scp_uploader.cc
diff --git a/src/wx/image_subtitle_colour_dialog.cc b/src/wx/image_subtitle_colour_dialog.cc
new file mode 100644 (file)
index 0000000..58f5de2
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+    Copyright (C) 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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "image_subtitle_colour_dialog.h"
+#include "rgba_colour_picker.h"
+#include "lib/ffmpeg_subtitle_stream.h"
+#include "lib/ffmpeg_content.h"
+
+using std::map;
+using std::cout;
+using boost::shared_ptr;
+
+ImageSubtitleColourDialog::ImageSubtitleColourDialog (wxWindow* parent, shared_ptr<FFmpegContent> content, shared_ptr<FFmpegSubtitleStream> stream)
+       : TableDialog (parent, _("Subtitle colours"), 2, 1, true)
+       , _content (content)
+       , _stream (stream)
+{
+       map<RGBA, RGBA> colours = _stream->colours ();
+
+       wxStaticText* t = new wxStaticText (this, wxID_ANY, "");
+       t->SetLabelMarkup (_("<b>Original colour</b>"));
+       add (t);
+       t = new wxStaticText (this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
+       t->SetLabelMarkup (_("<b>New colour</b>"));
+       add (t, 1, wxALIGN_CENTER);
+
+       for (map<RGBA, RGBA>::const_iterator i = colours.begin(); i != colours.end(); ++i) {
+               wxPanel* from = new wxPanel (this, wxID_ANY);
+               from->SetBackgroundColour (wxColour (i->first.r, i->first.g, i->first.b, i->first.a));
+               add (from);
+               RGBAColourPicker* to = new RGBAColourPicker (this, i->second);
+               add (to);
+               _pickers[i->first] = to;
+       }
+
+       layout ();
+}
+
+void
+ImageSubtitleColourDialog::apply ()
+{
+       for (map<RGBA, RGBAColourPicker*>::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) {
+               _stream->set_colour (i->first, i->second->colour ());
+       }
+
+       _content->signal_subtitle_stream_changed ();
+}
diff --git a/src/wx/image_subtitle_colour_dialog.h b/src/wx/image_subtitle_colour_dialog.h
new file mode 100644 (file)
index 0000000..8103bf9
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+    Copyright (C) 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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "table_dialog.h"
+#include "lib/rgba.h"
+#include <map>
+
+class RGBAColourPicker;
+class FFmpegContent;
+class FFmpegSubtitleStream;
+
+class ImageSubtitleColourDialog : public TableDialog
+{
+public:
+       ImageSubtitleColourDialog (wxWindow* parent, boost::shared_ptr<FFmpegContent> content, boost::shared_ptr<FFmpegSubtitleStream> stream);
+
+       void apply ();
+
+private:
+       boost::shared_ptr<FFmpegContent> _content;
+       boost::shared_ptr<FFmpegSubtitleStream> _stream;
+       std::map<RGBA, RGBAColourPicker*> _pickers;
+};
diff --git a/src/wx/rgba_colour_picker.cc b/src/wx/rgba_colour_picker.cc
new file mode 100644 (file)
index 0000000..7e8c84b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "rgba_colour_picker.h"
+#include "wx_util.h"
+#include <wx/clrpicker.h>
+
+RGBAColourPicker::RGBAColourPicker (wxWindow* parent, RGBA colour)
+       : wxPanel (parent, wxID_ANY)
+{
+       wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
+
+       _picker = new wxColourPickerCtrl (this, wxID_ANY);
+       _picker->SetColour (wxColour (colour.r, colour.g, colour.b));
+       sizer->Add (_picker, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
+       sizer->Add (new wxStaticText (this, wxID_ANY, _("Alpha   0")), 0, wxALIGN_CENTRE_VERTICAL);
+       _alpha = new wxSlider (this, wxID_ANY, colour.a, 0, 255);
+       sizer->Add (_alpha, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
+       sizer->Add (new wxStaticText (this, wxID_ANY, _("255")), 0, wxALIGN_CENTRE_VERTICAL);
+
+       SetSizer (sizer);
+}
+
+RGBA
+RGBAColourPicker::colour () const
+{
+       wxColour const c = _picker->GetColour ();
+       return RGBA (c.Red(), c.Green(), c.Blue(), _alpha->GetValue());
+}
diff --git a/src/wx/rgba_colour_picker.h b/src/wx/rgba_colour_picker.h
new file mode 100644 (file)
index 0000000..e4e5876
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+    Copyright (C) 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
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/rgba.h"
+#include <wx/wx.h>
+
+class wxColourPickerCtrl;
+class wxSlider;
+
+class RGBAColourPicker : public wxPanel
+{
+public:
+       RGBAColourPicker (wxWindow* parent, RGBA colour);
+
+       RGBA colour () const;
+
+private:
+       wxColourPickerCtrl* _picker;
+       wxSlider* _alpha;
+};
index f02ad9bb70031a2c83ae3deefd7cddfcd73fcaad..9422bb89428625f874ffe9e8fc5918688b61b10b 100644 (file)
@@ -24,6 +24,7 @@
 #include "content_panel.h"
 #include "fonts_dialog.h"
 #include "text_subtitle_appearance_dialog.h"
+#include "image_subtitle_colour_dialog.h"
 #include "lib/ffmpeg_content.h"
 #include "lib/text_subtitle_content.h"
 #include "lib/ffmpeg_subtitle_stream.h"
@@ -285,7 +286,7 @@ SubtitlePanel::setup_sensitivity ()
        _stream->Enable (!reference && ffmpeg_subs == 1);
        _subtitle_view_button->Enable (!reference && (text_subs == 1 || dcp_subs == 1));
        _fonts_dialog_button->Enable (!reference && (text_subs == 1 || dcp_subs == 1));
-       _appearance_dialog_button->Enable (!reference && text_subs == 1);
+       _appearance_dialog_button->Enable (!reference && (ffmpeg_subs == 1 || text_subs == 1));
 }
 
 void
@@ -433,11 +434,19 @@ SubtitlePanel::appearance_dialog_clicked ()
        DCPOMATIC_ASSERT (c.size() == 1);
 
        shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ());
-       DCPOMATIC_ASSERT (sr);
-
-       TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, sr);
-       if (d->ShowModal () == wxID_OK) {
-               d->apply ();
+       if (sr) {
+               TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, sr);
+               if (d->ShowModal () == wxID_OK) {
+                       d->apply ();
+               }
+               d->Destroy ();
+       } else {
+               shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c.front ());
+               DCPOMATIC_ASSERT (fc);
+               ImageSubtitleColourDialog* d = new ImageSubtitleColourDialog (this, fc, fc->subtitle_stream ());
+               if (d->ShowModal() == wxID_OK) {
+                       d->apply ();
+               }
+               d->Destroy ();
        }
-       d->Destroy ();
 }
index e3fd7cd75617e91c29a767cbfab3fd20a7b0a7d9..3dbae990952825e05d205629909120434b618831 100644 (file)
@@ -23,7 +23,6 @@ class wxCheckBox;
 class wxSpinCtrl;
 class SubtitleView;
 class FontsDialog;
-class SubtitleAppearanceDialog;
 
 class SubtitlePanel : public ContentSubPanel
 {
index 55572103118a6c826ba84daec39ebdbd9f950b3c..9e1d09d5737e7c9fb0f7e18f86950da8cf551a15 100644 (file)
@@ -29,8 +29,8 @@ public:
 
 protected:
        template<class T>
-       T* add (T* w) {
-               _table->Add (w, 1, wxEXPAND);
+       T* add (T* w, int proportion = 1, int flag = wxEXPAND) {
+               _table->Add (w, proportion, flag);
                return w;
        }
 
index c5c4d39ce0c1741587b078ef151ddc2cefc3b5b8..d01e8eda8448fbe096b4a35d39bcf119030c7fab 100644 (file)
@@ -41,6 +41,7 @@ sources = """
           dcp_panel.cc
           email_dialog.cc
           image_sequence_dialog.cc
+          image_subtitle_colour_dialog.cc
           isdcf_metadata_dialog.cc
           dir_picker_ctrl.cc
           dolby_doremi_certificate_panel.cc
@@ -68,6 +69,7 @@ sources = """
           preset_colour_conversion_dialog.cc
           repeat_dialog.cc
           report_problem_dialog.cc
+          rgba_colour_picker.cc
           screen_dialog.cc
           screens_panel.cc
           self_dkdm_dialog.cc