Allow specification of KDM annotation text (#296).
[dcpomatic.git] / src / wx / kdm_dialog.cc
index c15156eee436e11b24eb02155f7f87691ec20703..c88a1ac409d2ea0f92fec70cffe515cc94dc668e 100644 (file)
@@ -37,6 +37,7 @@
 #include "lib/kdm_util.h"
 #include "lib/screen.h"
 #include <libcxml/cxml.h>
+#include <dcp/cpl.h>
 #include <dcp/exceptions.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
@@ -127,8 +128,9 @@ KDMDialog::KDMDialog (wxWindow* parent, shared_ptr<const Film> film)
        _screens->ScreensChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
        _timing->TimingChanged.connect (boost::bind (&KDMDialog::setup_sensitivity, this));
        _make->Bind (wxEVT_BUTTON, boost::bind (&KDMDialog::make_clicked, this));
-       _cpl->Changed.connect(boost::bind(&KDMDialog::setup_sensitivity, this));
+       _cpl->Changed.connect(boost::bind(&KDMDialog::cpl_changed, this));
 
+       cpl_changed();
        setup_sensitivity ();
 
        SetSizer (overall_sizer);
@@ -137,6 +139,20 @@ KDMDialog::KDMDialog (wxWindow* parent, shared_ptr<const Film> film)
 }
 
 
+void
+KDMDialog::cpl_changed()
+{
+       try {
+               dcp::CPL cpl(_cpl->cpl());
+               if (auto text = cpl.annotation_text()) {
+                       _output->set_annotation_text(*text);
+               }
+       } catch (...) {}
+
+       setup_sensitivity();
+}
+
+
 void
 KDMDialog::setup_sensitivity ()
 {